Class: Bfwd::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/bf_ruby2/models/subscription.rb

Overview

Subscription

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Subscription

Initializes the object

Parameters:

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

    Model attributes in the form of hash



257
258
259
260
261
262
263
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/bf_ruby2/models/subscription.rb', line 257

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'created')
    self.created = attributes[:'created']
  end

  if attributes.has_key?(:'changedBy')
    self.changed_by = attributes[:'changedBy']
  end

  if attributes.has_key?(:'updated')
    self.updated = attributes[:'updated']
  end

  if attributes.has_key?(:'metadata')
    self. = attributes[:'metadata']
  end

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'versionID')
    self.version_id = attributes[:'versionID']
  end

  if attributes.has_key?(:'crmID')
    self.crm_id = attributes[:'crmID']
  end

  if attributes.has_key?(:'accountID')
    self. = attributes[:'accountID']
  end

  if attributes.has_key?(:'organizationID')
    self.organization_id = attributes[:'organizationID']
  end

  if attributes.has_key?(:'productID')
    self.product_id = attributes[:'productID']
  end

  if attributes.has_key?(:'productRatePlanID')
    self.product_rate_plan_id = attributes[:'productRatePlanID']
  end

  if attributes.has_key?(:'parentID')
    self.parent_id = attributes[:'parentID']
  end

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.has_key?(:'type')
    self.type = attributes[:'type']
  end

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

  if attributes.has_key?(:'currentPeriodStart')
    self.current_period_start = attributes[:'currentPeriodStart']
  end

  if attributes.has_key?(:'currentPeriodEnd')
    self.current_period_end = attributes[:'currentPeriodEnd']
  end

  if attributes.has_key?(:'contractStart')
    self.contract_start = attributes[:'contractStart']
  end

  if attributes.has_key?(:'subscriptionEnd')
    self.subscription_end = attributes[:'subscriptionEnd']
  end

  if attributes.has_key?(:'currentPeriodEndExplicit')
    self.current_period_end_explicit = attributes[:'currentPeriodEndExplicit']
  end

  if attributes.has_key?(:'initialPeriodStart')
    self.initial_period_start = attributes[:'initialPeriodStart']
  end

  if attributes.has_key?(:'successfulPeriods')
    self.successful_periods = attributes[:'successfulPeriods']
  end

  if attributes.has_key?(:'totalPeriods')
    self.total_periods = attributes[:'totalPeriods']
  end

  if attributes.has_key?(:'trialEnd')
    self.trial_end = attributes[:'trialEnd']
  end

  if attributes.has_key?(:'dunning')
    self.dunning = attributes[:'dunning']
  else
    self.dunning = false
  end

  if attributes.has_key?(:'locked')
    self.locked = attributes[:'locked']
  end

  if attributes.has_key?(:'managedBy')
    self.managed_by = attributes[:'managedBy']
  end

  if attributes.has_key?(:'versionStart')
    self.version_start = attributes[:'versionStart']
  end

  if attributes.has_key?(:'versionEnd')
    self.version_end = attributes[:'versionEnd']
  end

  if attributes.has_key?(:'versionNumber')
    self.version_number = attributes[:'versionNumber']
  end

  if attributes.has_key?(:'creditEnabled')
    self.credit_enabled = attributes[:'creditEnabled']
  else
    self.credit_enabled = false
  end

  if attributes.has_key?(:'aggregateAllSubscriptionsOnAccount')
    self. = attributes[:'aggregateAllSubscriptionsOnAccount']
  else
    self. = false
  end

  if attributes.has_key?(:'pricingComponentValues')
    if (value = attributes[:'pricingComponentValues']).is_a?(Array)
      self.pricing_component_values = value
    end
  end

  if attributes.has_key?(:'paymentMethodSubscriptionLinks')
    if (value = attributes[:'paymentMethodSubscriptionLinks']).is_a?(Array)
      self.payment_method_subscription_links = value
    end
  end

  if attributes.has_key?(:'fixedTerms')
    if (value = attributes[:'fixedTerms']).is_a?(Array)
      self.fixed_terms = value
    end
  end

  if attributes.has_key?(:'currentTime')
    self.current_time = attributes[:'currentTime']
  end

  if attributes.has_key?(:'timeOffset')
    self.time_offset = attributes[:'timeOffset']
  end

  if attributes.has_key?(:'paymentTerms')
    self.payment_terms = attributes[:'paymentTerms']
  end

  if attributes.has_key?(:'purchaseOrder')
    self.purchase_order = attributes[:'purchaseOrder']
  end

  if attributes.has_key?(:'failedPaymentBehaviour')
    self.failed_payment_behaviour = attributes[:'failedPaymentBehaviour']
  end

end

Instance Attribute Details

#account_idObject

href="\"POST\",\"GET\"">description“:”“,”verbs“:



40
41
42
# File 'lib/bf_ruby2/models/subscription.rb', line 40

def 
  @account_id
end

#aggregate_all_subscriptions_on_accountObject

{ "default":"true", "description":"Whether the subscription will aggregate all other subscriptions on the account.","verbs":["GET", "PUT", "POST"]}



115
116
117
# File 'lib/bf_ruby2/models/subscription.rb', line 115

def 
  
end

#changed_byObject

{ "description" : "ID of the user who last updated the entity.", "verbs":[] }



22
23
24
# File 'lib/bf_ruby2/models/subscription.rb', line 22

def changed_by
  @changed_by
end

#contract_startObject

of the contracted period. This will be after a trial, if one exists“,”verbs“:



73
74
75
# File 'lib/bf_ruby2/models/subscription.rb', line 73

def contract_start
  @contract_start
end

#createdObject

{ "description" : "The UTC DateTime when the object was created.", "verbs":[] }



19
20
21
# File 'lib/bf_ruby2/models/subscription.rb', line 19

def created
  @created
end

#credit_enabledObject

{ "default":"true", "description":"Can credit-notes be used to pay outstanding invoices for this subscription.","verbs":["GET", "PUT", "POST"]}



112
113
114
# File 'lib/bf_ruby2/models/subscription.rb', line 112

def credit_enabled
  @credit_enabled
end

#crm_idObject

href="\"POST\",\"PUT\",\"GET\"">description“:”“,”verbs“:



37
38
39
# File 'lib/bf_ruby2/models/subscription.rb', line 37

def crm_id
  @crm_id
end

#current_period_endObject

of the current period invoiced for. This can be manually updated to extend trials or delay invoice generation.“,”verbs“:



70
71
72
# File 'lib/bf_ruby2/models/subscription.rb', line 70

def current_period_end
  @current_period_end
end

#current_period_end_explicitObject

for the initial subscription period. Allows periods to align to a date or time regardless of purchase date/time.“,”verbs“:



79
80
81
# File 'lib/bf_ruby2/models/subscription.rb', line 79

def current_period_end_explicit
  @current_period_end_explicit
end

#current_period_startObject

of the current invoice period. At the end of this period, a new new invoice will be generated“,”verbs“:



67
68
69
# File 'lib/bf_ruby2/models/subscription.rb', line 67

def current_period_start
  @current_period_start
end

#current_timeObject

current time — from the point of view of the subscription.“,”verbs“:



126
127
128
# File 'lib/bf_ruby2/models/subscription.rb', line 126

def current_time
  @current_time
end

#descriptionObject

href="\"POST\",\"PUT\",\"GET\"">description“:”“,”verbs“:



58
59
60
# File 'lib/bf_ruby2/models/subscription.rb', line 58

def description
  @description
end

#dunningObject

{ "default":"false", "description":"Are there outstanding invoices which are currently in dunning.","verbs":["GET", "PUT", "POST"]}



94
95
96
# File 'lib/bf_ruby2/models/subscription.rb', line 94

def dunning
  @dunning
end

#failed_payment_behaviourObject

action that should be taken, should an invoice for some subscription to this rate plan remain unpaid despite the dunning period’s being exceeded.
<span class=\"label label-default\">CancelSubscription</span> &mdash; Demotes the subscription to the ‘Failed` state as soon as the dunning period is exceeded.
<span class=\"label label-default\">None</span> &mdash; The subscription is allowed to continue in the `AwaitingPayment` state indefinitely even if the dunning period is exceeded.For slow payment cycles &mdash; or when manual invoice remediation is common &mdash; <span class=\"label label-default\">None</span> is recommended.
In a heavily-automated SaaS environment, automatic cancellation via <span class=\"label label-default\">CancelSubscription</span> is recommended.“,”verbs“:



137
138
139
# File 'lib/bf_ruby2/models/subscription.rb', line 137

def failed_payment_behaviour
  @failed_payment_behaviour
end

#fixed_termsObject

of fixed terms that have been or are applied to the subscription“,”verbs“:



123
124
125
# File 'lib/bf_ruby2/models/subscription.rb', line 123

def fixed_terms
  @fixed_terms
end

#idObject

href="\"GET\"">description“:”“,”verbs“:



31
32
33
# File 'lib/bf_ruby2/models/subscription.rb', line 31

def id
  @id
end

#initial_period_startObject

of the first successful period“,”verbs“:



82
83
84
# File 'lib/bf_ruby2/models/subscription.rb', line 82

def initial_period_start
  @initial_period_start
end

#lockedObject

the subscription is locked, it will not be processed by the system","verbs":[]



97
98
99
# File 'lib/bf_ruby2/models/subscription.rb', line 97

def locked
  @locked
end

#managed_byObject

system is responsible for managing the subscription.","verbs":[]



100
101
102
# File 'lib/bf_ruby2/models/subscription.rb', line 100

def managed_by
  @managed_by
end

#metadataObject

{ "description" : "Add metadata.", "verbs“: }



28
29
30
# File 'lib/bf_ruby2/models/subscription.rb', line 28

def 
  
end

#nameObject

definable friendly name for the subscription.“,”verbs“:



55
56
57
# File 'lib/bf_ruby2/models/subscription.rb', line 55

def name
  @name
end

#organization_idObject

associated with the subscription.","verbs":[]



43
44
45
# File 'lib/bf_ruby2/models/subscription.rb', line 43

def organization_id
  @organization_id
end

#parent_idObject

href="\"GET\"">description“:”“,”verbs“:



52
53
54
# File 'lib/bf_ruby2/models/subscription.rb', line 52

def parent_id
  @parent_id
end

Returns the value of attribute payment_method_subscription_links.



120
121
122
# File 'lib/bf_ruby2/models/subscription.rb', line 120

def payment_method_subscription_links
  @payment_method_subscription_links
end

#payment_termsObject

Returns the value of attribute payment_terms.



131
132
133
# File 'lib/bf_ruby2/models/subscription.rb', line 131

def payment_terms
  @payment_terms
end

#pricing_component_valuesObject

quantities for each pricing component of the rate-plan. Values should be set for all pricing components of the rate-plan apart from the usage components. Usage components should be added when the usage is known, this is often after the end of the current billing cycle.","verbs":["GET", "POST"]



118
119
120
# File 'lib/bf_ruby2/models/subscription.rb', line 118

def pricing_component_values
  @pricing_component_values
end

#product_idObject

href="\"GET\"">description“:”“,”verbs“:



46
47
48
# File 'lib/bf_ruby2/models/subscription.rb', line 46

def product_id
  @product_id
end

#product_rate_plan_idObject

of the rate-plan being billed for.“,”verbs“:



49
50
51
# File 'lib/bf_ruby2/models/subscription.rb', line 49

def product_rate_plan_id
  @product_rate_plan_id
end

#purchase_orderObject

{ "default": " ", "description":"Purchase order associated with the subscription. If specified this is copied to any invoices issued for this subscription.“,”verbs“:}



134
135
136
# File 'lib/bf_ruby2/models/subscription.rb', line 134

def purchase_order
  @purchase_order
end

#stateObject

<span class=\"label label-default\">Provisioned</span> subscription can be updated to either <span class=\"label label-default\">Trial</span> or <span class=\"label label-default\">AwaitingPayment</span>, this will start the subscription. Any updates to the state of a non-<span class=\"label label-default\">Provisioned</span> will be ignored. To cancel or otherwise amend a subscription please use the explict amendment calls.", "description":"A <span class=\"label label-default\">Provisioned</span> subscription will not begin until marked as <span class=\"label label-default\">Trial</span> or <span class=\"label label-default\">AwaitingPayment</span>. Trial subscriptions transition to <span class=\"label label-default\">AwaitingPayment</span> when the trial period is over. On subscription renewal the state becomes <span class=\"label label-default\">AwaitingPayment</span>. Once outstanding invoices are paid the state changes to <span class=\"label label-default\">Paid</span>. A subscription is set as either <span class=\"label label-default\">Failed</span> or left as <span class=\"label label-default\">AwaitingPayment</span>, depending on the rate-plan configuration. If a subscription is non-recurring or fixed-term and ends naturally, it will be marked as <span class=\"label label-default\">Expired</span>. If all payment attempts have failed a subscription is marked as <span class=\"label label-default\">Cancelled</span> if it has been manually ended. Once a subscription is marked as <span class=\"label label-default\">Failed</span>, <span class=\"label label-default\">Expired</span>, or <span class=\"label label-default\">Cancelled</span> no invoices other than a final invoice will be issued. Note: Updating account card details will not lead to BillForward automatically retrying payment, manual payment attempts can be made.“,”verbs“:



64
65
66
# File 'lib/bf_ruby2/models/subscription.rb', line 64

def state
  @state
end

#subscription_endObject

a subscription will end. This may be in the future if the cancellation is at the end of the current period.“,”verbs“:



76
77
78
# File 'lib/bf_ruby2/models/subscription.rb', line 76

def subscription_end
  @subscription_end
end

#successful_periodsObject

of paid-for periods billing, excluding trials, since the subscription started.“,”verbs“:



85
86
87
# File 'lib/bf_ruby2/models/subscription.rb', line 85

def successful_periods
  @successful_periods
end

#time_offsetObject

far in the future is the entity (in seconds) compared to the BillForward server’s time.“,”verbs“:



129
130
131
# File 'lib/bf_ruby2/models/subscription.rb', line 129

def time_offset
  @time_offset
end

#total_periodsObject

number of subscription periods.“,”verbs“:



88
89
90
# File 'lib/bf_ruby2/models/subscription.rb', line 88

def total_periods
  @total_periods
end

#trial_endObject

end time of the trial period, if one existed“,”verbs“:



91
92
93
# File 'lib/bf_ruby2/models/subscription.rb', line 91

def trial_end
  @trial_end
end

#typeObject



61
62
63
# File 'lib/bf_ruby2/models/subscription.rb', line 61

def type
  @type
end

#updatedObject

{ "description" : "The UTC DateTime when the object was last updated.", "verbs":[] }



25
26
27
# File 'lib/bf_ruby2/models/subscription.rb', line 25

def updated
  @updated
end

#version_endObject

the current version of the subscription ended, null indicates current version.“,”verbs“:



106
107
108
# File 'lib/bf_ruby2/models/subscription.rb', line 106

def version_end
  @version_end
end

#version_idObject

href="\"GET\"">description“:”“,”verbs“:



34
35
36
# File 'lib/bf_ruby2/models/subscription.rb', line 34

def version_id
  @version_id
end

#version_numberObject

version number of the subscription, starts at 1.“,”verbs“:



109
110
111
# File 'lib/bf_ruby2/models/subscription.rb', line 109

def version_number
  @version_number
end

#version_startObject

the current version of the subscription started.“,”verbs“:



103
104
105
# File 'lib/bf_ruby2/models/subscription.rb', line 103

def version_start
  @version_start
end

Class Method Details

.attribute_mapObject

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



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/bf_ruby2/models/subscription.rb', line 162

def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'updated' => :'updated',
    :'metadata' => :'metadata',
    :'id' => :'id',
    :'version_id' => :'versionID',
    :'crm_id' => :'crmID',
    :'account_id' => :'accountID',
    :'organization_id' => :'organizationID',
    :'product_id' => :'productID',
    :'product_rate_plan_id' => :'productRatePlanID',
    :'parent_id' => :'parentID',
    :'name' => :'name',
    :'description' => :'description',
    :'type' => :'type',
    :'state' => :'state',
    :'current_period_start' => :'currentPeriodStart',
    :'current_period_end' => :'currentPeriodEnd',
    :'contract_start' => :'contractStart',
    :'subscription_end' => :'subscriptionEnd',
    :'current_period_end_explicit' => :'currentPeriodEndExplicit',
    :'initial_period_start' => :'initialPeriodStart',
    :'successful_periods' => :'successfulPeriods',
    :'total_periods' => :'totalPeriods',
    :'trial_end' => :'trialEnd',
    :'dunning' => :'dunning',
    :'locked' => :'locked',
    :'managed_by' => :'managedBy',
    :'version_start' => :'versionStart',
    :'version_end' => :'versionEnd',
    :'version_number' => :'versionNumber',
    :'credit_enabled' => :'creditEnabled',
    :'aggregate_all_subscriptions_on_account' => :'aggregateAllSubscriptionsOnAccount',
    :'pricing_component_values' => :'pricingComponentValues',
    :'payment_method_subscription_links' => :'paymentMethodSubscriptionLinks',
    :'fixed_terms' => :'fixedTerms',
    :'current_time' => :'currentTime',
    :'time_offset' => :'timeOffset',
    :'payment_terms' => :'paymentTerms',
    :'purchase_order' => :'purchaseOrder',
    :'failed_payment_behaviour' => :'failedPaymentBehaviour'
  }
end

.swagger_typesObject

Attribute type mapping.



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
# File 'lib/bf_ruby2/models/subscription.rb', line 209

def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'updated' => :'DateTime',
    :'metadata' => :'DynamicMetadata',
    :'id' => :'String',
    :'version_id' => :'String',
    :'crm_id' => :'String',
    :'account_id' => :'String',
    :'organization_id' => :'String',
    :'product_id' => :'String',
    :'product_rate_plan_id' => :'String',
    :'parent_id' => :'String',
    :'name' => :'String',
    :'description' => :'String',
    :'type' => :'String',
    :'state' => :'String',
    :'current_period_start' => :'DateTime',
    :'current_period_end' => :'DateTime',
    :'contract_start' => :'DateTime',
    :'subscription_end' => :'DateTime',
    :'current_period_end_explicit' => :'DateTime',
    :'initial_period_start' => :'DateTime',
    :'successful_periods' => :'Integer',
    :'total_periods' => :'Integer',
    :'trial_end' => :'DateTime',
    :'dunning' => :'BOOLEAN',
    :'locked' => :'String',
    :'managed_by' => :'String',
    :'version_start' => :'DateTime',
    :'version_end' => :'DateTime',
    :'version_number' => :'Integer',
    :'credit_enabled' => :'BOOLEAN',
    :'aggregate_all_subscriptions_on_account' => :'BOOLEAN',
    :'pricing_component_values' => :'Array<PricingComponentValue>',
    :'payment_method_subscription_links' => :'Array<PaymentMethodSubscriptionLink>',
    :'fixed_terms' => :'Array<FixedTerm>',
    :'current_time' => :'DateTime',
    :'time_offset' => :'Integer',
    :'payment_terms' => :'Integer',
    :'purchase_order' => :'String',
    :'failed_payment_behaviour' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
# File 'lib/bf_ruby2/models/subscription.rb', line 564

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      updated == o.updated &&
       == o. &&
      id == o.id &&
      version_id == o.version_id &&
      crm_id == o.crm_id &&
       == o. &&
      organization_id == o.organization_id &&
      product_id == o.product_id &&
      product_rate_plan_id == o.product_rate_plan_id &&
      parent_id == o.parent_id &&
      name == o.name &&
      description == o.description &&
      type == o.type &&
      state == o.state &&
      current_period_start == o.current_period_start &&
      current_period_end == o.current_period_end &&
      contract_start == o.contract_start &&
      subscription_end == o.subscription_end &&
      current_period_end_explicit == o.current_period_end_explicit &&
      initial_period_start == o.initial_period_start &&
      successful_periods == o.successful_periods &&
      total_periods == o.total_periods &&
      trial_end == o.trial_end &&
      dunning == o.dunning &&
      locked == o.locked &&
      managed_by == o.managed_by &&
      version_start == o.version_start &&
      version_end == o.version_end &&
      version_number == o.version_number &&
      credit_enabled == o.credit_enabled &&
       == o. &&
      pricing_component_values == o.pricing_component_values &&
      payment_method_subscription_links == o.payment_method_subscription_links &&
      fixed_terms == o.fixed_terms &&
      current_time == o.current_time &&
      time_offset == o.time_offset &&
      payment_terms == o.payment_terms &&
      purchase_order == o.purchase_order &&
      failed_payment_behaviour == o.failed_payment_behaviour
end

#_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



646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'lib/bf_ruby2/models/subscription.rb', line 646

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.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
    temp_model = Bfwd.const_get(type).new
    temp_model.build_from_hash(value)
  end
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



712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/bf_ruby2/models/subscription.rb', line 712

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

#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



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
# File 'lib/bf_ruby2/models/subscription.rb', line 625

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


612
613
614
# File 'lib/bf_ruby2/models/subscription.rb', line 612

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



618
619
620
# File 'lib/bf_ruby2/models/subscription.rb', line 618

def hash
  [created, changed_by, updated, , id, version_id, crm_id, , organization_id, product_id, product_rate_plan_id, parent_id, name, description, type, state, current_period_start, current_period_end, contract_start, subscription_end, current_period_end_explicit, initial_period_start, successful_periods, total_periods, trial_end, dunning, locked, managed_by, version_start, version_end, version_number, credit_enabled, , pricing_component_values, payment_method_subscription_links, fixed_terms, current_time, time_offset, payment_terms, purchase_order, failed_payment_behaviour].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
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
# File 'lib/bf_ruby2/models/subscription.rb', line 443

def list_invalid_properties
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push("invalid value for 'id', id cannot be nil.")
  end

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

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

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

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

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

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

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

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

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

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

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

  return 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



692
693
694
# File 'lib/bf_ruby2/models/subscription.rb', line 692

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



698
699
700
701
702
703
704
705
706
# File 'lib/bf_ruby2/models/subscription.rb', line 698

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



686
687
688
# File 'lib/bf_ruby2/models/subscription.rb', line 686

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



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/bf_ruby2/models/subscription.rb', line 498

def valid?
  return false if @id.nil?
  return false if @account_id.nil?
  return false if @organization_id.nil?
  return false if @product_id.nil?
  return false if @product_rate_plan_id.nil?
  return false if @name.nil?
  type_validator = EnumAttributeValidator.new('String', ["Subscription", "FixedTerm", "Trial"])
  return false unless type_validator.valid?(@type)
  return false if @state.nil?
  state_validator = EnumAttributeValidator.new('String', ["Trial", "Provisioned", "Paid", "AwaitingPayment", "Cancelled", "Failed", "Expired"])
  return false unless state_validator.valid?(@state)
  return false if @initial_period_start.nil?
  return false if @trial_end.nil?
  managed_by_validator = EnumAttributeValidator.new('String', ["BillForward", "Stripe"])
  return false unless managed_by_validator.valid?(@managed_by)
  return false if @version_start.nil?
  return false if @version_number.nil?
  return false if @current_time.nil?
  failed_payment_behaviour_validator = EnumAttributeValidator.new('String', ["CancelSubscription", "None"])
  return false unless failed_payment_behaviour_validator.valid?(@failed_payment_behaviour)
  return true
end