Class: Bfwd::CreateSubscriptionRequest

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

Overview

Entity for requesting that a subscription be created.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CreateSubscriptionRequest

Initializes the object



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

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?(:'accountID')
    self. = attributes[:'accountID']
  end

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

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

  if attributes.has_key?(:'organizationID')
    self.organization_id = attributes[:'organizationID']
  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?(:'start')
    self.start = attributes[:'start']
  end

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

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

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

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

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

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

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

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

  if attributes.has_key?(:'metadata')
    self. = attributes[:'metadata']
  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?(:'contractStart')
    self.contract_start = attributes[:'contractStart']
  end

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

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

end

Instance Attribute Details

#_endObject

period ahead of the ‘start` time)","description":"ISO 8601 UTC DateTime (e.g. 2015-06-16T11:58:41Z) describing the date at which the subscription should finish its first service period.“,”verbs“:



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

def _end
  @_end
end

#account_idObject

of the BillForward Account who will own this subscription. You should ensure beforehand that the customer has had a BillForward Account created for them.“,”verbs“:



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

def 
  @account_id
end

#aggregate_all_subscriptions_on_accountObject

this subscription should become an ‘aggregating subscription’, collecting charges (starting now) from all other subscriptions (current and future) belonging to this BillForward Account.“,”verbs“:



54
55
56
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 54

def 
  
end

#align_period_with_aggregating_subscriptionObject

to override the ‘end` date to line up with the current period end of the ’aggregating subscription’ to which this subscription belongs.“,”verbs“:



57
58
59
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 57

def align_period_with_aggregating_subscription
  @align_period_with_aggregating_subscription
end

#contract_startObject

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



71
72
73
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 71

def contract_start
  @contract_start
end

#descriptionObject

of the created subscription. This is primarily for your benefit — for example, you could write here the mechanism through which you obtained this customer. (e.g. ‘Customer obtained through Lazy Wednesdays promotion’).“,”verbs“:



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

def description
  @description
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“:



74
75
76
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 74

def failed_payment_behaviour
  @failed_payment_behaviour
end

#metadataObject

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



63
64
65
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 63

def 
  
end

#nameObject

will be named after the rate plan to which the subscription subscribes)","description":"Name of the created subscription. This is primarily for your benefit &mdash; for example, to enable you to identify subscriptions at a glance in the BillForward web interface (e.g. ‘Customer 1425, [email protected], Premium membership’).“,”verbs“:



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

def name
  @name
end

#organization_idObject

using your authentication credentials)","description":"ID of the BillForward Organization within which the requested Subscription should be created. If omitted, this will be auto-populated using your authentication credentials.“,”verbs“:



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

def organization_id
  @organization_id
end

#parent_idObject

a subscription exists which ‘aggregates all subscriptions belonging to this BillForward Account’, refer to the ID of that subscription. Otherwise: null)","description":"ID of a parent subscription which will collect the charges raised by this subscription. The parent becomes responsible for paying those charges. If a subscription exists which ‘aggregates all subscriptions belonging to this BillForward Account’, then that parent will override any parent specified here.“,”verbs“:



51
52
53
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 51

def parent_id
  @parent_id
end

#payment_termsObject

Returns the value of attribute payment_terms.



65
66
67
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 65

def payment_terms
  @payment_terms
end

#prepayment_amountObject

{ "description":"How much prepayment should be taken upfront.", "verbs“:}



77
78
79
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 77

def prepayment_amount
  @prepayment_amount
end

#pricing_component_quantitiesObject

list)","description":"Quantities that this subscription possesses (upon beginning service), of pricing components upon the subscription’s rate plan. For example: you can set the subscription to begin its service with ‘5 widgets’ consumed. Otherwise the ‘default quantity’ will be observed instead, for each pricing component upon the rate plan.“,”verbs“:



60
61
62
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 60

def pricing_component_quantities
  @pricing_component_quantities
end

#productObject



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

def product
  @product
end

#product_rate_planObject

or name of the rate plan to which the subscription will be subscribing. Lookup by name is only possible if a ‘productID` is specified.“,”verbs“:



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

def product_rate_plan
  @product_rate_plan
end

#purchase_orderObject

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



68
69
70
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 68

def purchase_order
  @purchase_order
end

#startObject

upon receiving request)","description":"ISO 8601 UTC DateTime (e.g. 2015-06-16T11:58:41Z) describing the date at which the subscription should enter its first service period.“,”verbs“:



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

def start
  @start
end

#stateObject

state in which the created subscription will begin.
<span class=\"label label-default\">Provisioned</span> &mdash; The subscription will wait (without raising any invoices or beginning its service) until explicit action is taken to change its state.
<span class=\"label label-default\">AwaitingPayment</span> &mdash; The subscription is activated. After ‘start` time is surpassed, it will begin service and raise its first invoice.“,”verbs“:



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

def state
  @state
end

#trial_endObject

8601 UTC DateTime (e.g. 2015-06-16T11:58:41Z) describing the date at which the subscription should leave the trial period.“,”verbs“:



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

def trial_end
  @trial_end
end

#typeObject

Returns the value of attribute type.



48
49
50
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 48

def type
  @type
end

Class Method Details

.attribute_mapObject

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



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 102

def self.attribute_map
  {
    :'account_id' => :'accountID',
    :'product' => :'product',
    :'product_rate_plan' => :'productRatePlan',
    :'organization_id' => :'organizationID',
    :'name' => :'name',
    :'description' => :'description',
    :'start' => :'start',
    :'_end' => :'end',
    :'state' => :'state',
    :'trial_end' => :'trialEnd',
    :'type' => :'type',
    :'parent_id' => :'parentID',
    :'aggregate_all_subscriptions_on_account' => :'aggregateAllSubscriptionsOnAccount',
    :'align_period_with_aggregating_subscription' => :'alignPeriodWithAggregatingSubscription',
    :'pricing_component_quantities' => :'pricingComponentQuantities',
    :'metadata' => :'metadata',
    :'payment_terms' => :'paymentTerms',
    :'purchase_order' => :'purchaseOrder',
    :'contract_start' => :'contractStart',
    :'failed_payment_behaviour' => :'failedPaymentBehaviour',
    :'prepayment_amount' => :'prepaymentAmount'
  }
end

.swagger_typesObject

Attribute type mapping.



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

def self.swagger_types
  {
    :'account_id' => :'String',
    :'product' => :'String',
    :'product_rate_plan' => :'String',
    :'organization_id' => :'String',
    :'name' => :'String',
    :'description' => :'String',
    :'start' => :'DateTime',
    :'_end' => :'DateTime',
    :'state' => :'String',
    :'trial_end' => :'DateTime',
    :'type' => :'String',
    :'parent_id' => :'String',
    :'aggregate_all_subscriptions_on_account' => :'BOOLEAN',
    :'align_period_with_aggregating_subscription' => :'BOOLEAN',
    :'pricing_component_quantities' => :'Array<PricingComponentQuantityRequest>',
    :'metadata' => :'DynamicMetadata',
    :'payment_terms' => :'Integer',
    :'purchase_order' => :'String',
    :'contract_start' => :'DateTime',
    :'failed_payment_behaviour' => :'String',
    :'prepayment_amount' => :'Float'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



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

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
       == o. &&
      product == o.product &&
      product_rate_plan == o.product_rate_plan &&
      organization_id == o.organization_id &&
      name == o.name &&
      description == o.description &&
      start == o.start &&
      _end == o._end &&
      state == o.state &&
      trial_end == o.trial_end &&
      type == o.type &&
      parent_id == o.parent_id &&
       == o. &&
      align_period_with_aggregating_subscription == o.align_period_with_aggregating_subscription &&
      pricing_component_quantities == o.pricing_component_quantities &&
       == o. &&
      payment_terms == o.payment_terms &&
      purchase_order == o.purchase_order &&
      contract_start == o.contract_start &&
      failed_payment_behaviour == o.failed_payment_behaviour &&
      prepayment_amount == o.prepayment_amount
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type



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

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



449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 449

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



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 362

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

See Also:

  • `==` method


349
350
351
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 349

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.



355
356
357
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 355

def hash
  [, product, product_rate_plan, organization_id, name, description, start, _end, state, trial_end, type, parent_id, , align_period_with_aggregating_subscription, pricing_component_quantities, , payment_terms, purchase_order, contract_start, failed_payment_behaviour, prepayment_amount].hash
end

#list_invalid_propertiesObject

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



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 257

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

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

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

  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



429
430
431
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 429

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



435
436
437
438
439
440
441
442
443
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 435

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



423
424
425
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 423

def to_s
  to_hash.to_s
end

#valid?Boolean

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



276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/bf_ruby2/models/create_subscription_request.rb', line 276

def valid?
  return false if @account_id.nil?
  return false if @product.nil?
  return false if @product_rate_plan.nil?
  state_validator = EnumAttributeValidator.new('String', ["Trial", "Provisioned", "Paid", "AwaitingPayment", "Cancelled", "Failed", "Expired"])
  return false unless state_validator.valid?(@state)
  type_validator = EnumAttributeValidator.new('String', ["Subscription", "FixedTerm", "Trial"])
  return false unless type_validator.valid?(@type)
  failed_payment_behaviour_validator = EnumAttributeValidator.new('String', ["CancelSubscription", "None"])
  return false unless failed_payment_behaviour_validator.valid?(@failed_payment_behaviour)
  return true
end