Class: AdvancedBilling::CustomerChange

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/customer_change.rb

Overview

CustomerChange Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(payer = SKIP, shipping_address = SKIP, billing_address = SKIP, custom_fields = SKIP) ⇒ CustomerChange

Returns a new instance of CustomerChange.



53
54
55
56
57
58
59
# File 'lib/advanced_billing/models/customer_change.rb', line 53

def initialize(payer = SKIP, shipping_address = SKIP,
               billing_address = SKIP, custom_fields = SKIP)
  @payer = payer unless payer == SKIP
  @shipping_address = shipping_address unless shipping_address == SKIP
  @billing_address = billing_address unless billing_address == SKIP
  @custom_fields = custom_fields unless custom_fields == SKIP
end

Instance Attribute Details

#billing_addressCustomerBillingAddressChange

TODO: Write general description for this method



22
23
24
# File 'lib/advanced_billing/models/customer_change.rb', line 22

def billing_address
  @billing_address
end

#custom_fieldsCustomerCustomFieldsChange

TODO: Write general description for this method



26
27
28
# File 'lib/advanced_billing/models/customer_change.rb', line 26

def custom_fields
  @custom_fields
end

#payerCustomerPayerChange

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/advanced_billing/models/customer_change.rb', line 14

def payer
  @payer
end

#shipping_addressCustomerShippingAddressChange

TODO: Write general description for this method



18
19
20
# File 'lib/advanced_billing/models/customer_change.rb', line 18

def shipping_address
  @shipping_address
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/advanced_billing/models/customer_change.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payer = CustomerPayerChange.from_hash(hash['payer']) if hash['payer']
  shipping_address = CustomerShippingAddressChange.from_hash(hash['shipping_address']) if
    hash['shipping_address']
  billing_address = CustomerBillingAddressChange.from_hash(hash['billing_address']) if
    hash['billing_address']
  custom_fields = CustomerCustomFieldsChange.from_hash(hash['custom_fields']) if
    hash['custom_fields']

  # Create object from extracted values.
  CustomerChange.new(payer,
                     shipping_address,
                     billing_address,
                     custom_fields)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/advanced_billing/models/customer_change.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payer'] = 'payer'
  @_hash['shipping_address'] = 'shipping_address'
  @_hash['billing_address'] = 'billing_address'
  @_hash['custom_fields'] = 'custom_fields'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/advanced_billing/models/customer_change.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/advanced_billing/models/customer_change.rb', line 39

def self.optionals
  %w[
    payer
    shipping_address
    billing_address
    custom_fields
  ]
end