Class: AdvancedBilling::Site

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

Overview

Site 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(id: SKIP, name: SKIP, subdomain: SKIP, currency: SKIP, seller_id: SKIP, non_primary_currencies: SKIP, relationship_invoicing_enabled: SKIP, customer_hierarchy_enabled: SKIP, whopays_enabled: SKIP, whopays_default_payer: SKIP, allocation_settings: SKIP, default_payment_collection_method: SKIP, organization_address: SKIP, tax_configuration: SKIP, net_terms: SKIP, test: SKIP, additional_properties: {}) ⇒ Site

Returns a new instance of Site.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/advanced_billing/models/site.rb', line 127

def initialize(id: SKIP, name: SKIP, subdomain: SKIP, currency: SKIP,
               seller_id: SKIP, non_primary_currencies: SKIP,
               relationship_invoicing_enabled: SKIP,
               customer_hierarchy_enabled: SKIP, whopays_enabled: SKIP,
               whopays_default_payer: SKIP, allocation_settings: SKIP,
               default_payment_collection_method: SKIP,
               organization_address: SKIP, tax_configuration: SKIP,
               net_terms: SKIP, test: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @id = id unless id == SKIP
  @name = name unless name == SKIP
  @subdomain = subdomain unless subdomain == SKIP
  @currency = currency unless currency == SKIP
  @seller_id = seller_id unless seller_id == SKIP
  @non_primary_currencies = non_primary_currencies unless non_primary_currencies == SKIP
  unless relationship_invoicing_enabled == SKIP
    @relationship_invoicing_enabled =
      relationship_invoicing_enabled
  end
  unless customer_hierarchy_enabled == SKIP
    @customer_hierarchy_enabled =
      customer_hierarchy_enabled
  end
  @whopays_enabled = whopays_enabled unless whopays_enabled == SKIP
  @whopays_default_payer = whopays_default_payer unless whopays_default_payer == SKIP
  @allocation_settings = allocation_settings unless allocation_settings == SKIP
  unless default_payment_collection_method == SKIP
    @default_payment_collection_method =
      default_payment_collection_method
  end
  @organization_address = organization_address unless organization_address == SKIP
  @tax_configuration = tax_configuration unless tax_configuration == SKIP
  @net_terms = net_terms unless net_terms == SKIP
  @test = test unless test == SKIP
end

Instance Attribute Details

#allocation_settingsAllocationSettings

TODO: Write general description for this method

Returns:



54
55
56
# File 'lib/advanced_billing/models/site.rb', line 54

def allocation_settings
  @allocation_settings
end

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


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

def currency
  @currency
end

#customer_hierarchy_enabledTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


42
43
44
# File 'lib/advanced_billing/models/site.rb', line 42

def customer_hierarchy_enabled
  @customer_hierarchy_enabled
end

#default_payment_collection_methodString

TODO: Write general description for this method

Returns:

  • (String)


58
59
60
# File 'lib/advanced_billing/models/site.rb', line 58

def default_payment_collection_method
  @default_payment_collection_method
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def id
  @id
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#net_termsNetTerms

TODO: Write general description for this method

Returns:



70
71
72
# File 'lib/advanced_billing/models/site.rb', line 70

def net_terms
  @net_terms
end

#non_primary_currenciesArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


34
35
36
# File 'lib/advanced_billing/models/site.rb', line 34

def non_primary_currencies
  @non_primary_currencies
end

#organization_addressOrganizationAddress

TODO: Write general description for this method

Returns:



62
63
64
# File 'lib/advanced_billing/models/site.rb', line 62

def organization_address
  @organization_address
end

#relationship_invoicing_enabledTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


38
39
40
# File 'lib/advanced_billing/models/site.rb', line 38

def relationship_invoicing_enabled
  @relationship_invoicing_enabled
end

#seller_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


30
31
32
# File 'lib/advanced_billing/models/site.rb', line 30

def seller_id
  @seller_id
end

#subdomainString

TODO: Write general description for this method

Returns:

  • (String)


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

def subdomain
  @subdomain
end

#tax_configurationTaxConfiguration

TODO: Write general description for this method

Returns:



66
67
68
# File 'lib/advanced_billing/models/site.rb', line 66

def tax_configuration
  @tax_configuration
end

#testTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


74
75
76
# File 'lib/advanced_billing/models/site.rb', line 74

def test
  @test
end

#whopays_default_payerString

TODO: Write general description for this method

Returns:

  • (String)


50
51
52
# File 'lib/advanced_billing/models/site.rb', line 50

def whopays_default_payer
  @whopays_default_payer
end

#whopays_enabledTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


46
47
48
# File 'lib/advanced_billing/models/site.rb', line 46

def whopays_enabled
  @whopays_enabled
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/advanced_billing/models/site.rb', line 168

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  subdomain = hash.key?('subdomain') ? hash['subdomain'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  seller_id = hash.key?('seller_id') ? hash['seller_id'] : SKIP
  non_primary_currencies =
    hash.key?('non_primary_currencies') ? hash['non_primary_currencies'] : SKIP
  relationship_invoicing_enabled =
    hash.key?('relationship_invoicing_enabled') ? hash['relationship_invoicing_enabled'] : SKIP
  customer_hierarchy_enabled =
    hash.key?('customer_hierarchy_enabled') ? hash['customer_hierarchy_enabled'] : SKIP
  whopays_enabled =
    hash.key?('whopays_enabled') ? hash['whopays_enabled'] : SKIP
  whopays_default_payer =
    hash.key?('whopays_default_payer') ? hash['whopays_default_payer'] : SKIP
  allocation_settings = AllocationSettings.from_hash(hash['allocation_settings']) if
    hash['allocation_settings']
  default_payment_collection_method =
    hash.key?('default_payment_collection_method') ? hash['default_payment_collection_method'] : SKIP
  organization_address = OrganizationAddress.from_hash(hash['organization_address']) if
    hash['organization_address']
  tax_configuration = TaxConfiguration.from_hash(hash['tax_configuration']) if
    hash['tax_configuration']
  net_terms = NetTerms.from_hash(hash['net_terms']) if hash['net_terms']
  test = hash.key?('test') ? hash['test'] : SKIP

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

  # Create object from extracted values.
  Site.new(id: id,
           name: name,
           subdomain: subdomain,
           currency: currency,
           seller_id: seller_id,
           non_primary_currencies: non_primary_currencies,
           relationship_invoicing_enabled: relationship_invoicing_enabled,
           customer_hierarchy_enabled: customer_hierarchy_enabled,
           whopays_enabled: whopays_enabled,
           whopays_default_payer: whopays_default_payer,
           allocation_settings: allocation_settings,
           default_payment_collection_method: default_payment_collection_method,
           organization_address: organization_address,
           tax_configuration: tax_configuration,
           net_terms: net_terms,
           test: test,
           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/advanced_billing/models/site.rb', line 77

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['subdomain'] = 'subdomain'
  @_hash['currency'] = 'currency'
  @_hash['seller_id'] = 'seller_id'
  @_hash['non_primary_currencies'] = 'non_primary_currencies'
  @_hash['relationship_invoicing_enabled'] =
    'relationship_invoicing_enabled'
  @_hash['customer_hierarchy_enabled'] = 'customer_hierarchy_enabled'
  @_hash['whopays_enabled'] = 'whopays_enabled'
  @_hash['whopays_default_payer'] = 'whopays_default_payer'
  @_hash['allocation_settings'] = 'allocation_settings'
  @_hash['default_payment_collection_method'] =
    'default_payment_collection_method'
  @_hash['organization_address'] = 'organization_address'
  @_hash['tax_configuration'] = 'tax_configuration'
  @_hash['net_terms'] = 'net_terms'
  @_hash['test'] = 'test'
  @_hash
end

.nullablesObject

An array for nullable fields



123
124
125
# File 'lib/advanced_billing/models/site.rb', line 123

def self.nullables
  []
end

.optionalsObject

An array for optional fields



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/advanced_billing/models/site.rb', line 101

def self.optionals
  %w[
    id
    name
    subdomain
    currency
    seller_id
    non_primary_currencies
    relationship_invoicing_enabled
    customer_hierarchy_enabled
    whopays_enabled
    whopays_default_payer
    allocation_settings
    default_payment_collection_method
    organization_address
    tax_configuration
    net_terms
    test
  ]
end