Class: Braintree::PayPalPurchaseUnitInput

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

#initialize(attributes) ⇒ PayPalPurchaseUnitInput

Returns a new instance of PayPalPurchaseUnitInput.



11
12
13
14
15
16
17
18
19
# File 'lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb', line 11

def initialize(attributes)
    @attrs = attributes.keys
    unless attributes[:amount]
        raise ArgumentError, "Expected hash to contain a :amount"
    end
    set_instance_variables_from_hash(attributes)
    @payee = attributes[:payee] ? PayPalPayeeInput.new(attributes[:payee]) : nil
    @amount = attributes[:amount] ? MonetaryAmountInput.new(attributes[:amount]) : nil
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



8
9
10
# File 'lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb', line 8

def amount
  @amount
end

#attrsObject (readonly)

Returns the value of attribute attrs.



7
8
9
# File 'lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb', line 7

def attrs
  @attrs
end

#payeeObject (readonly)

Returns the value of attribute payee.



9
10
11
# File 'lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb', line 9

def payee
  @payee
end

Instance Method Details

#inspectObject



20
21
22
23
# File 'lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb', line 20

def inspect
    inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
    "#<#{self.class} #{inspected_attributes.join(" ")}>"
end

#to_graphql_variablesObject



24
25
26
27
28
29
# File 'lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb', line 24

def to_graphql_variables
    variables = {}
    variables["amount"] = amount.to_graphql_variables if amount
    variables["payee"] = payee.to_graphql_variables if payee
    variables
end