Class: LinodeOpenapiClient::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/linode_openapi_client/models/account.rb

Overview

Account object.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Account

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



164
165
166
167
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/linode_openapi_client/models/account.rb', line 164

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `LinodeOpenapiClient::Account` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `LinodeOpenapiClient::Account`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'first_name')
    self.first_name = attributes[:'first_name']
  end

  if attributes.key?(:'zip')
    self.zip = attributes[:'zip']
  end

  if attributes.key?(:'address_2')
    self.address_2 = attributes[:'address_2']
  end

  if attributes.key?(:'capabilities')
    if (value = attributes[:'capabilities']).is_a?(Array)
      self.capabilities = value
    end
  end

  if attributes.key?(:'credit_card')
    self.credit_card = attributes[:'credit_card']
  end

  if attributes.key?(:'active_since')
    self.active_since = attributes[:'active_since']
  end

  if attributes.key?(:'balance')
    self.balance = attributes[:'balance']
  end

  if attributes.key?(:'city')
    self.city = attributes[:'city']
  end

  if attributes.key?(:'state')
    self.state = attributes[:'state']
  end

  if attributes.key?(:'country')
    self.country = attributes[:'country']
  end

  if attributes.key?(:'last_name')
    self.last_name = attributes[:'last_name']
  end

  if attributes.key?(:'euuid')
    self.euuid = attributes[:'euuid']
  end

  if attributes.key?(:'address_1')
    self.address_1 = attributes[:'address_1']
  end

  if attributes.key?(:'company')
    self.company = attributes[:'company']
  end

  if attributes.key?(:'phone')
    self.phone = attributes[:'phone']
  end

  if attributes.key?(:'active_promotions')
    if (value = attributes[:'active_promotions']).is_a?(Array)
      self.active_promotions = value
    end
  end

  if attributes.key?(:'tax_id')
    self.tax_id = attributes[:'tax_id']
  end

  if attributes.key?(:'balance_uninvoiced')
    self.balance_uninvoiced = attributes[:'balance_uninvoiced']
  end

  if attributes.key?(:'email')
    self.email = attributes[:'email']
  end

  if attributes.key?(:'billing_source')
    self.billing_source = attributes[:'billing_source']
  end
end

Instance Attribute Details

#active_promotionsObject

Returns the value of attribute active_promotions.



63
64
65
# File 'lib/linode_openapi_client/models/account.rb', line 63

def active_promotions
  @active_promotions
end

#active_sinceObject

Read-only The date and time the account was activated.



34
35
36
# File 'lib/linode_openapi_client/models/account.rb', line 34

def active_since
  @active_since
end

#address_1Object

First line of this Account’s billing address.



55
56
57
# File 'lib/linode_openapi_client/models/account.rb', line 55

def address_1
  @address_1
end

#address_2Object

Second line of this Account’s billing address.



26
27
28
# File 'lib/linode_openapi_client/models/account.rb', line 26

def address_2
  @address_2
end

#balanceObject

Read-only This Account’s balance, in US dollars.



37
38
39
# File 'lib/linode_openapi_client/models/account.rb', line 37

def balance
  @balance
end

#balance_uninvoicedObject

Read-only This Account’s current estimated invoice in US dollars. This is not your final invoice balance. Transfer charges are not included in the estimate.



69
70
71
# File 'lib/linode_openapi_client/models/account.rb', line 69

def balance_uninvoiced
  @balance_uninvoiced
end

#billing_sourceObject

Read-only The source of service charges for this Account, as determined by its relationship with Akamai. Accounts that are associated with Akamai-specific customers return a value of ‘akamai`. All other Accounts return a value of `linode`.



75
76
77
# File 'lib/linode_openapi_client/models/account.rb', line 75

def billing_source
  @billing_source
end

#capabilitiesObject

Read-only A list of capabilities your account supports.



29
30
31
# File 'lib/linode_openapi_client/models/account.rb', line 29

def capabilities
  @capabilities
end

#cityObject

The city for this Account’s billing address.



40
41
42
# File 'lib/linode_openapi_client/models/account.rb', line 40

def city
  @city
end

#companyObject

The company name associated with this Account. Must not include any of the following characters: ‘<` `>` `(` `)` `"` `=`



58
59
60
# File 'lib/linode_openapi_client/models/account.rb', line 58

def company
  @company
end

#countryObject

The two-letter ISO 3166 country code of this Account’s billing address.



46
47
48
# File 'lib/linode_openapi_client/models/account.rb', line 46

def country
  @country
end

#credit_cardObject

Returns the value of attribute credit_card.



31
32
33
# File 'lib/linode_openapi_client/models/account.rb', line 31

def credit_card
  @credit_card
end

#emailObject

The email address of the person associated with this Account.



72
73
74
# File 'lib/linode_openapi_client/models/account.rb', line 72

def email
  @email
end

#euuidObject

Read-only An external unique identifier for this account.



52
53
54
# File 'lib/linode_openapi_client/models/account.rb', line 52

def euuid
  @euuid
end

#first_nameObject

The first name of the person associated with this Account. Must not include any of the following characters: ‘<` `>` `(` `)` `"` `=`



20
21
22
# File 'lib/linode_openapi_client/models/account.rb', line 20

def first_name
  @first_name
end

#last_nameObject

The last name of the person associated with this Account. Must not include any of the following characters: ‘<` `>` `(` `)` `"` `=`



49
50
51
# File 'lib/linode_openapi_client/models/account.rb', line 49

def last_name
  @last_name
end

#phoneObject

The phone number associated with this Account.



61
62
63
# File 'lib/linode_openapi_client/models/account.rb', line 61

def phone
  @phone
end

#stateObject

If billing address is in the United States (US) or Canada (CA), only the two-letter ISO 3166 State or Province code are accepted. If entering a US military address, state abbreviations (AA, AE, AP) should be entered. If the address is outside the US or CA, this is the Province associated with the Account’s billing address.



43
44
45
# File 'lib/linode_openapi_client/models/account.rb', line 43

def state
  @state
end

#tax_idObject

The tax identification number associated with this Account, for tax calculations in some countries. If you do not live in a country that collects tax, this should be an empty string (‘""`).



66
67
68
# File 'lib/linode_openapi_client/models/account.rb', line 66

def tax_id
  @tax_id
end

#zipObject

The zip code of this Account’s billing address. The following restrictions apply: - Can only contain ASCII letters, numbers, and hyphens (‘-`). - Must not contain more than 9 letter or number characters.



23
24
25
# File 'lib/linode_openapi_client/models/account.rb', line 23

def zip
  @zip
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/linode_openapi_client/models/account.rb', line 545

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = LinodeOpenapiClient.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



126
127
128
# File 'lib/linode_openapi_client/models/account.rb', line 126

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/linode_openapi_client/models/account.rb', line 100

def self.attribute_map
  {
    :'first_name' => :'first_name',
    :'zip' => :'zip',
    :'address_2' => :'address_2',
    :'capabilities' => :'capabilities',
    :'credit_card' => :'credit_card',
    :'active_since' => :'active_since',
    :'balance' => :'balance',
    :'city' => :'city',
    :'state' => :'state',
    :'country' => :'country',
    :'last_name' => :'last_name',
    :'euuid' => :'euuid',
    :'address_1' => :'address_1',
    :'company' => :'company',
    :'phone' => :'phone',
    :'active_promotions' => :'active_promotions',
    :'tax_id' => :'tax_id',
    :'balance_uninvoiced' => :'balance_uninvoiced',
    :'email' => :'email',
    :'billing_source' => :'billing_source'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/linode_openapi_client/models/account.rb', line 521

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



157
158
159
160
# File 'lib/linode_openapi_client/models/account.rb', line 157

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/linode_openapi_client/models/account.rb', line 131

def self.openapi_types
  {
    :'first_name' => :'String',
    :'zip' => :'String',
    :'address_2' => :'String',
    :'capabilities' => :'Array<String>',
    :'credit_card' => :'PutAccountRequestCreditCard',
    :'active_since' => :'Time',
    :'balance' => :'Float',
    :'city' => :'String',
    :'state' => :'String',
    :'country' => :'String',
    :'last_name' => :'String',
    :'euuid' => :'String',
    :'address_1' => :'String',
    :'company' => :'String',
    :'phone' => :'String',
    :'active_promotions' => :'Array<AccountActivePromotionsInner>',
    :'tax_id' => :'String',
    :'balance_uninvoiced' => :'Float',
    :'email' => :'String',
    :'billing_source' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/linode_openapi_client/models/account.rb', line 481

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      first_name == o.first_name &&
      zip == o.zip &&
      address_2 == o.address_2 &&
      capabilities == o.capabilities &&
      credit_card == o.credit_card &&
      active_since == o.active_since &&
      balance == o.balance &&
      city == o.city &&
      state == o.state &&
      country == o.country &&
      last_name == o.last_name &&
      euuid == o.euuid &&
      address_1 == o.address_1 &&
      company == o.company &&
      phone == o.phone &&
      active_promotions == o.active_promotions &&
      tax_id == o.tax_id &&
      balance_uninvoiced == o.balance_uninvoiced &&
      email == o.email &&
      billing_source == o.billing_source
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/linode_openapi_client/models/account.rb', line 616

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


508
509
510
# File 'lib/linode_openapi_client/models/account.rb', line 508

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



514
515
516
# File 'lib/linode_openapi_client/models/account.rb', line 514

def hash
  [first_name, zip, address_2, capabilities, credit_card, active_since, balance, city, state, country, last_name, euuid, address_1, company, phone, active_promotions, tax_id, balance_uninvoiced, email, billing_source].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/linode_openapi_client/models/account.rb', line 264

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@first_name.nil? && @first_name.to_s.length > 50
    invalid_properties.push('invalid value for "first_name", the character length must be smaller than or equal to 50.')
  end

  if !@address_2.nil? && @address_2.to_s.length > 64
    invalid_properties.push('invalid value for "address_2", the character length must be smaller than or equal to 64.')
  end

  if !@city.nil? && @city.to_s.length > 24
    invalid_properties.push('invalid value for "city", the character length must be smaller than or equal to 24.')
  end

  if !@state.nil? && @state.to_s.length > 24
    invalid_properties.push('invalid value for "state", the character length must be smaller than or equal to 24.')
  end

  if !@last_name.nil? && @last_name.to_s.length > 50
    invalid_properties.push('invalid value for "last_name", the character length must be smaller than or equal to 50.')
  end

  if !@address_1.nil? && @address_1.to_s.length > 64
    invalid_properties.push('invalid value for "address_1", the character length must be smaller than or equal to 64.')
  end

  if !@company.nil? && @company.to_s.length > 128
    invalid_properties.push('invalid value for "company", the character length must be smaller than or equal to 128.')
  end

  if !@phone.nil? && @phone.to_s.length > 32
    invalid_properties.push('invalid value for "phone", the character length must be smaller than or equal to 32.')
  end

  if !@tax_id.nil? && @tax_id.to_s.length > 25
    invalid_properties.push('invalid value for "tax_id", the character length must be smaller than or equal to 25.')
  end

  if !@email.nil? && @email.to_s.length > 128
    invalid_properties.push('invalid value for "email", the character length must be smaller than or equal to 128.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



592
593
594
# File 'lib/linode_openapi_client/models/account.rb', line 592

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/linode_openapi_client/models/account.rb', line 598

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



586
587
588
# File 'lib/linode_openapi_client/models/account.rb', line 586

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/linode_openapi_client/models/account.rb', line 312

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@first_name.nil? && @first_name.to_s.length > 50
  return false if !@address_2.nil? && @address_2.to_s.length > 64
  return false if !@city.nil? && @city.to_s.length > 24
  return false if !@state.nil? && @state.to_s.length > 24
  return false if !@last_name.nil? && @last_name.to_s.length > 50
  return false if !@address_1.nil? && @address_1.to_s.length > 64
  return false if !@company.nil? && @company.to_s.length > 128
  return false if !@phone.nil? && @phone.to_s.length > 32
  return false if !@tax_id.nil? && @tax_id.to_s.length > 25
  return false if !@email.nil? && @email.to_s.length > 128
  billing_source_validator = EnumAttributeValidator.new('String', ["akamai", "linode"])
  return false unless billing_source_validator.valid?(@billing_source)
  true
end