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

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(payer: SKIP, shipping_address: SKIP, billing_address: SKIP, custom_fields: SKIP, additional_properties: {}) ⇒ CustomerChange

Returns a new instance of CustomerChange.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/advanced_billing/models/customer_change.rb', line 58

def initialize(payer: SKIP, shipping_address: SKIP, billing_address: SKIP,
               custom_fields: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @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_addressAddressChange

TODO: Write general description for this method

Returns:



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_addressAddressChange

TODO: Write general description for this method

Returns:



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.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/advanced_billing/models/customer_change.rb', line 72

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 = AddressChange.from_hash(hash['shipping_address']) if
    hash['shipping_address']
  billing_address = AddressChange.from_hash(hash['billing_address']) if
    hash['billing_address']
  custom_fields = CustomerCustomFieldsChange.from_hash(hash['custom_fields']) if
    hash['custom_fields']

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  CustomerChange.new(payer: payer,
                     shipping_address: shipping_address,
                     billing_address: billing_address,
                     custom_fields: custom_fields,
                     additional_properties: additional_properties)
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
52
53
54
55
56
# File 'lib/advanced_billing/models/customer_change.rb', line 49

def self.nullables
  %w[
    payer
    shipping_address
    billing_address
    custom_fields
  ]
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