Class: TogaiClient::RateCard

Inherits:
Object
  • Object
show all
Defined in:
lib/togai_client/models/rate_card.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ RateCard

Initializes the object



126
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
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
# File 'lib/togai_client/models/rate_card.rb', line 126

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::RateCard` 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 `TogaiClient::RateCard`. 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?(:'billable_id')
    self.billable_id = attributes[:'billable_id']
  else
    self.billable_id = nil
  end

  if attributes.key?(:'type')
    self.type = attributes[:'type']
  else
    self.type = nil
  end

  if attributes.key?(:'display_name')
    self.display_name = attributes[:'display_name']
  else
    self.display_name = nil
  end

  if attributes.key?(:'invoice_timing')
    self.invoice_timing = attributes[:'invoice_timing']
  else
    self.invoice_timing = nil
  end

  if attributes.key?(:'rate_card_details')
    self.rate_card_details = attributes[:'rate_card_details']
  else
    self.rate_card_details = nil
  end

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

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  else
    self.name = nil
  end

  if attributes.key?(:'reference_id')
    self.reference_id = attributes[:'reference_id']
  else
    self.reference_id = nil
  end

  if attributes.key?(:'reference_type')
    self.reference_type = attributes[:'reference_type']
  else
    self.reference_type = nil
  end

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

  if attributes.key?(:'price_plan_id')
    self.price_plan_id = attributes[:'price_plan_id']
  else
    self.price_plan_id = nil
  end

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

Instance Attribute Details

#account_idObject

Account identifier



46
47
48
# File 'lib/togai_client/models/rate_card.rb', line 46

def 
  @account_id
end

#billable_idObject

Billable identifier



19
20
21
# File 'lib/togai_client/models/rate_card.rb', line 19

def billable_id
  @billable_id
end

#currenciesObject

List of currencies supported by the rate card



40
41
42
# File 'lib/togai_client/models/rate_card.rb', line 40

def currencies
  @currencies
end

#display_nameObject

Display name of the rate card



24
25
26
# File 'lib/togai_client/models/rate_card.rb', line 24

def display_name
  @display_name
end

#invoice_timingObject

Returns the value of attribute invoice_timing.



26
27
28
# File 'lib/togai_client/models/rate_card.rb', line 26

def invoice_timing
  @invoice_timing
end

#nameObject

Returns the value of attribute name.



33
34
35
# File 'lib/togai_client/models/rate_card.rb', line 33

def name
  @name
end

#price_plan_idObject

Price plan identifier



43
44
45
# File 'lib/togai_client/models/rate_card.rb', line 43

def price_plan_id
  @price_plan_id
end

#rate_card_detailsObject

Returns the value of attribute rate_card_details.



28
29
30
# File 'lib/togai_client/models/rate_card.rb', line 28

def rate_card_details
  @rate_card_details
end

#reference_idObject

Returns the value of attribute reference_id.



35
36
37
# File 'lib/togai_client/models/rate_card.rb', line 35

def reference_id
  @reference_id
end

#reference_typeObject

Returns the value of attribute reference_type.



37
38
39
# File 'lib/togai_client/models/rate_card.rb', line 37

def reference_type
  @reference_type
end

#tagObject

Tag for rate card



31
32
33
# File 'lib/togai_client/models/rate_card.rb', line 31

def tag
  @tag
end

#typeObject

Returns the value of attribute type.



21
22
23
# File 'lib/togai_client/models/rate_card.rb', line 21

def type
  @type
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type



469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/togai_client/models/rate_card.rb', line 469

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 = TogaiClient.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



89
90
91
# File 'lib/togai_client/models/rate_card.rb', line 89

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/togai_client/models/rate_card.rb', line 71

def self.attribute_map
  {
    :'billable_id' => :'billableId',
    :'type' => :'type',
    :'display_name' => :'displayName',
    :'invoice_timing' => :'invoiceTiming',
    :'rate_card_details' => :'rateCardDetails',
    :'tag' => :'tag',
    :'name' => :'name',
    :'reference_id' => :'referenceId',
    :'reference_type' => :'referenceType',
    :'currencies' => :'currencies',
    :'price_plan_id' => :'pricePlanId',
    :'account_id' => :'accountId'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/togai_client/models/rate_card.rb', line 445

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_all_ofObject

List of class defined in allOf (OpenAPI v3)



118
119
120
121
122
# File 'lib/togai_client/models/rate_card.rb', line 118

def self.openapi_all_of
  [
  :'RateCardData'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



112
113
114
115
# File 'lib/togai_client/models/rate_card.rb', line 112

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

.openapi_typesObject

Attribute type mapping.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/togai_client/models/rate_card.rb', line 94

def self.openapi_types
  {
    :'billable_id' => :'String',
    :'type' => :'RateCardType',
    :'display_name' => :'String',
    :'invoice_timing' => :'InvoiceTiming',
    :'rate_card_details' => :'RateCardDetails',
    :'tag' => :'String',
    :'name' => :'String',
    :'reference_id' => :'String',
    :'reference_type' => :'String',
    :'currencies' => :'Array<String>',
    :'price_plan_id' => :'String',
    :'account_id' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/togai_client/models/rate_card.rb', line 413

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      billable_id == o.billable_id &&
      type == o.type &&
      display_name == o.display_name &&
      invoice_timing == o.invoice_timing &&
      rate_card_details == o.rate_card_details &&
      tag == o.tag &&
      name == o.name &&
      reference_id == o.reference_id &&
      reference_type == o.reference_type &&
      currencies == o.currencies &&
      price_plan_id == o.price_plan_id &&
       == o.
end

#_to_hash(value) ⇒ Hash

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



540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/togai_client/models/rate_card.rb', line 540

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

See Also:

  • `==` method


432
433
434
# File 'lib/togai_client/models/rate_card.rb', line 432

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.



438
439
440
# File 'lib/togai_client/models/rate_card.rb', line 438

def hash
  [billable_id, type, display_name, invoice_timing, rate_card_details, tag, name, reference_id, reference_type, currencies, price_plan_id, ].hash
end

#list_invalid_propertiesObject

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



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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/togai_client/models/rate_card.rb', line 210

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @billable_id.nil?
    invalid_properties.push('invalid value for "billable_id", billable_id cannot be nil.')
  end

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

  if @type.nil?
    invalid_properties.push('invalid value for "type", type cannot be nil.')
  end

  if @display_name.nil?
    invalid_properties.push('invalid value for "display_name", display_name cannot be nil.')
  end

  if @display_name.to_s.length > 255
    invalid_properties.push('invalid value for "display_name", the character length must be smaller than or equal to 255.')
  end

  if @invoice_timing.nil?
    invalid_properties.push('invalid value for "invoice_timing", invoice_timing cannot be nil.')
  end

  if @rate_card_details.nil?
    invalid_properties.push('invalid value for "rate_card_details", rate_card_details cannot be nil.')
  end

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

  if @name.nil?
    invalid_properties.push('invalid value for "name", name cannot be nil.')
  end

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

  if @reference_id.nil?
    invalid_properties.push('invalid value for "reference_id", reference_id cannot be nil.')
  end

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

  if @reference_type.nil?
    invalid_properties.push('invalid value for "reference_type", reference_type cannot be nil.')
  end

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

  if @price_plan_id.nil?
    invalid_properties.push('invalid value for "price_plan_id", price_plan_id cannot be nil.')
  end

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

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



516
517
518
# File 'lib/togai_client/models/rate_card.rb', line 516

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/togai_client/models/rate_card.rb', line 522

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



510
511
512
# File 'lib/togai_client/models/rate_card.rb', line 510

def to_s
  to_hash.to_s
end

#valid?Boolean

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



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/togai_client/models/rate_card.rb', line 282

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @billable_id.nil?
  return false if @billable_id.to_s.length > 50
  return false if @type.nil?
  return false if @display_name.nil?
  return false if @display_name.to_s.length > 255
  return false if @invoice_timing.nil?
  return false if @rate_card_details.nil?
  return false if !@tag.nil? && @tag.to_s.length > 50
  return false if @name.nil?
  return false if @name.to_s.length > 50
  return false if @reference_id.nil?
  return false if @reference_id.to_s.length > 50
  return false if @reference_type.nil?
  return false if @reference_type.to_s.length > 50
  return false if @price_plan_id.nil?
  return false if @price_plan_id.to_s.length > 50
  true
end