Class: Braintree::PayerInfoInput

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/graphql/inputs/payer_info_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) ⇒ PayerInfoInput

Returns a new instance of PayerInfoInput.



14
15
16
17
18
19
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 14

def initialize(attributes)
  @attrs = attributes.keys
  set_instance_variables_from_hash(attributes)
  @billing_address = attributes[:billing_address] ? BillingAddressInput.new(attributes[:billing_address]) : nil
  @shipping_address = attributes[:shipping_address] ? ShippingAddressInput.new(attributes[:shipping_address]) : nil
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



5
6
7
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 5

def attrs
  @attrs
end

#billing_addressObject (readonly)

Returns the value of attribute billing_address.



6
7
8
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 6

def billing_address
  @billing_address
end

#emailObject (readonly)

Returns the value of attribute email.



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

def email
  @email
end

#given_nameObject (readonly)

Returns the value of attribute given_name.



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

def given_name
  @given_name
end

#phone_country_codeObject (readonly)

Returns the value of attribute phone_country_code.



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

def phone_country_code
  @phone_country_code
end

#phone_numberObject (readonly)

Returns the value of attribute phone_number.



10
11
12
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 10

def phone_number
  @phone_number
end

#shipping_addressObject (readonly)

Returns the value of attribute shipping_address.



11
12
13
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 11

def shipping_address
  @shipping_address
end

#surnameObject (readonly)

Returns the value of attribute surname.



12
13
14
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 12

def surname
  @surname
end

Instance Method Details

#inspectObject



21
22
23
24
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 21

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

#to_graphql_variablesObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/braintree/graphql/inputs/payer_info_input.rb', line 26

def to_graphql_variables
  {
    "billingAddress" => billing_address&.to_graphql_variables,
    "email" => email,
    "givenName" => given_name,
    "phoneCountryCode" => phone_country_code,
    "phoneNumber" => phone_number,
    "shippingAddress" => shipping_address&.to_graphql_variables,
    "surname" => surname
  }.compact
end