Class: OryClient::Subscription

Inherits:
ApiModelBase show all
Defined in:
lib/ory-client/models/subscription.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Subscription

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
# File 'lib/ory-client/models/subscription.rb', line 147

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#created_at ⇒ Object

Returns the value of attribute created_at.



18
19
20
# File 'lib/ory-client/models/subscription.rb', line 18

def created_at
  @created_at
end

#currency ⇒ Object

The currency of the subscription. To change this, a new subscription must be created. usd USD eur Euro



21
22
23
# File 'lib/ory-client/models/subscription.rb', line 21

def currency
  @currency
end

#current_interval ⇒ Object

The currently active interval of the subscription monthly Monthly yearly Yearly



24
25
26
# File 'lib/ory-client/models/subscription.rb', line 24

def current_interval
  @current_interval
end

#current_plan ⇒ Object

The currently active plan of the subscription



27
28
29
# File 'lib/ory-client/models/subscription.rb', line 27

def current_plan
  @current_plan
end

#current_plan_details ⇒ Object

Returns the value of attribute current_plan_details.



29
30
31
# File 'lib/ory-client/models/subscription.rb', line 29

def current_plan_details
  @current_plan_details
end

#customer_id ⇒ Object

The ID of the stripe customer



32
33
34
# File 'lib/ory-client/models/subscription.rb', line 32

def customer_id
  @customer_id
end

#id ⇒ Object

The ID of the subscription



35
36
37
# File 'lib/ory-client/models/subscription.rb', line 35

def id
  @id
end

#interval_changes_to ⇒ Object

Returns the value of attribute interval_changes_to.



37
38
39
# File 'lib/ory-client/models/subscription.rb', line 37

def interval_changes_to
  @interval_changes_to
end

#ongoing_stripe_checkout_id ⇒ Object

Returns the value of attribute ongoing_stripe_checkout_id.



39
40
41
# File 'lib/ory-client/models/subscription.rb', line 39

def ongoing_stripe_checkout_id
  @ongoing_stripe_checkout_id
end

#ongoing_stripe_checkout_url ⇒ Object

The Stripe-hosted URL for completing an ongoing checkout, including any configured custom domain.



42
43
44
# File 'lib/ory-client/models/subscription.rb', line 42

def ongoing_stripe_checkout_url
  @ongoing_stripe_checkout_url
end

#payed_until ⇒ Object

Until when the subscription is payed



45
46
47
# File 'lib/ory-client/models/subscription.rb', line 45

def payed_until
  @payed_until
end

#plan_changes_at ⇒ Object

Returns the value of attribute plan_changes_at.



47
48
49
# File 'lib/ory-client/models/subscription.rb', line 47

def plan_changes_at
  @plan_changes_at
end

#plan_changes_to ⇒ Object

Returns the value of attribute plan_changes_to.



49
50
51
# File 'lib/ory-client/models/subscription.rb', line 49

def plan_changes_to
  @plan_changes_to
end

#status ⇒ Object

For collection_method=charge_automatically a subscription moves into incomplete if the initial payment attempt fails. A subscription in this status can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an active status. If the first invoice is not paid within 23 hours, the subscription transitions to incomplete_expired. This is a terminal status, the open invoice will be voided and no further invoices will be generated. A subscription that is currently in a trial period is trialing and moves to active when the trial period is over. A subscription can only enter a paused status when a trial ends without a payment method. A paused subscription doesn't generate invoices and can be resumed after your customer adds their payment method. The paused status is different from pausing collection, which still generates invoices and leaves the subscription's status unchanged. If subscription collection_method=charge_automatically, it becomes past_due when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become canceled or unpaid (depending on your subscriptions settings). If subscription collection_method=send_invoice it becomes past_due when its invoice is not paid by the due date, and canceled or unpaid if it is still not paid by an additional deadline after that. Note that when a subscription has a status of unpaid, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.



52
53
54
# File 'lib/ory-client/models/subscription.rb', line 52

def status
  @status
end

#stripe_checkout_expires_at ⇒ Object

Returns the value of attribute stripe_checkout_expires_at.



54
55
56
# File 'lib/ory-client/models/subscription.rb', line 54

def stripe_checkout_expires_at
  @stripe_checkout_expires_at
end

#updated_at ⇒ Object

Returns the value of attribute updated_at.



56
57
58
# File 'lib/ory-client/models/subscription.rb', line 56

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_map ⇒ Object

Returns attribute mapping this model knows about



103
104
105
# File 'lib/ory-client/models/subscription.rb', line 103

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributes ⇒ Object

Returns all the JSON keys this model knows about



108
109
110
# File 'lib/ory-client/models/subscription.rb', line 108

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_map ⇒ Object

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



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ory-client/models/subscription.rb', line 81

def self.attribute_map
  {
    :'created_at' => :'created_at',
    :'currency' => :'currency',
    :'current_interval' => :'current_interval',
    :'current_plan' => :'current_plan',
    :'current_plan_details' => :'current_plan_details',
    :'customer_id' => :'customer_id',
    :'id' => :'id',
    :'interval_changes_to' => :'interval_changes_to',
    :'ongoing_stripe_checkout_id' => :'ongoing_stripe_checkout_id',
    :'ongoing_stripe_checkout_url' => :'ongoing_stripe_checkout_url',
    :'payed_until' => :'payed_until',
    :'plan_changes_at' => :'plan_changes_at',
    :'plan_changes_to' => :'plan_changes_to',
    :'status' => :'status',
    :'stripe_checkout_expires_at' => :'stripe_checkout_expires_at',
    :'updated_at' => :'updated_at'
  }
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



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/ory-client/models/subscription.rb', line 440

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_nullable ⇒ Object

List of attributes with nullable: true



135
136
137
138
139
140
141
142
143
# File 'lib/ory-client/models/subscription.rb', line 135

def self.openapi_nullable
  Set.new([
    :'interval_changes_to',
    :'ongoing_stripe_checkout_id',
    :'plan_changes_at',
    :'plan_changes_to',
    :'stripe_checkout_expires_at',
  ])
end

.openapi_types ⇒ Object

Attribute type mapping.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/ory-client/models/subscription.rb', line 113

def self.openapi_types
  {
    :'created_at' => :'Time',
    :'currency' => :'String',
    :'current_interval' => :'String',
    :'current_plan' => :'String',
    :'current_plan_details' => :'PlanDetails',
    :'customer_id' => :'String',
    :'id' => :'String',
    :'interval_changes_to' => :'String',
    :'ongoing_stripe_checkout_id' => :'String',
    :'ongoing_stripe_checkout_url' => :'String',
    :'payed_until' => :'Time',
    :'plan_changes_at' => :'Time',
    :'plan_changes_to' => :'String',
    :'status' => :'String',
    :'stripe_checkout_expires_at' => :'Time',
    :'updated_at' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object) —

    to be compared



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/ory-client/models/subscription.rb', line 404

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created_at == o.created_at &&
      currency == o.currency &&
      current_interval == o.current_interval &&
      current_plan == o.current_plan &&
      current_plan_details == o.current_plan_details &&
      customer_id == o.customer_id &&
      id == o.id &&
      interval_changes_to == o.interval_changes_to &&
      ongoing_stripe_checkout_id == o.ongoing_stripe_checkout_id &&
      ongoing_stripe_checkout_url == o.ongoing_stripe_checkout_url &&
      payed_until == o.payed_until &&
      plan_changes_at == o.plan_changes_at &&
      plan_changes_to == o.plan_changes_to &&
      status == o.status &&
      stripe_checkout_expires_at == o.stripe_checkout_expires_at &&
      updated_at == o.updated_at
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object) —

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


427
428
429
# File 'lib/ory-client/models/subscription.rb', line 427

def eql?(o)
  self == o
end

#hash ⇒ Integer

Calculates hash code according to all attributes.

Returns:

  • (Integer) —

    Hash code



433
434
435
# File 'lib/ory-client/models/subscription.rb', line 433

def hash
  [created_at, currency, current_interval, current_plan, current_plan_details, customer_id, id, interval_changes_to, ongoing_stripe_checkout_id, ongoing_stripe_checkout_url, payed_until, plan_changes_at, plan_changes_to, status, stripe_checkout_expires_at, updated_at].hash
end

#list_invalid_properties ⇒ Object

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

Returns:

  • Array for valid properties with the reasons



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
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/ory-client/models/subscription.rb', line 250

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

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

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

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

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

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

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

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

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

  invalid_properties
end

#to_hash ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash) —

    Returns the object in the form of hash



462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/ory-client/models/subscription.rb', line 462

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

#valid? ⇒ Boolean

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

Returns:

  • (Boolean) —

    true if the model is valid



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/ory-client/models/subscription.rb', line 294

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @created_at.nil?
  return false if @currency.nil?
  currency_validator = EnumAttributeValidator.new('String', ["usd", "eur"])
  return false unless currency_validator.valid?(@currency)
  return false if @current_interval.nil?
  current_interval_validator = EnumAttributeValidator.new('String', ["monthly", "yearly"])
  return false unless current_interval_validator.valid?(@current_interval)
  return false if @current_plan.nil?
  return false if @customer_id.nil?
  return false if @id.nil?
  return false if @payed_until.nil?
  return false if @status.nil?
  return false if @updated_at.nil?
  true
end