Class: Pago::V2026_04::Models::Subscription

Inherits:
Model
  • Object
show all
Defined in:
lib/pago/v2026_04/models.rb,
sig/pago/v2026_04/generated.rbs

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  created_at: "created_at",
  modified_at: "modified_at",
  id: "id",
  amount: "amount",
  currency: "currency",
  recurring_interval: "recurring_interval",
  recurring_interval_count: "recurring_interval_count",
  status: "status",
  current_period_start: "current_period_start",
  current_period_end: "current_period_end",
  current_meter_period_start: "current_meter_period_start",
  current_meter_period_end: "current_meter_period_end",
  trial_start: "trial_start",
  trial_end: "trial_end",
  cancel_at_period_end: "cancel_at_period_end",
  canceled_at: "canceled_at",
  started_at: "started_at",
  ends_at: "ends_at",
  ended_at: "ended_at",
  past_due_at: "past_due_at",
  pause_at_period_end: "pause_at_period_end",
  paused_at: "paused_at",
  resumes_at: "resumes_at",
  customer_id: "customer_id",
  product_id: "product_id",
  discount_id: "discount_id",
  checkout_id: "checkout_id",
  seats: "seats",
  customer_cancellation_reason: "customer_cancellation_reason",
  customer_cancellation_comment: "customer_cancellation_comment",
  metadata: "metadata",
  custom_field_data: "custom_field_data",
  customer: "customer",
  product: "product",
  discount: "discount",
  prices: "prices",
  meters: "meters",
  pending_update: "pending_update"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["created_at", "modified_at", "id", "amount", "currency", "recurring_interval", "recurring_interval_count", "status", "current_period_start", "current_period_end", "current_meter_period_start", "current_meter_period_end", "trial_start", "trial_end", "cancel_at_period_end", "canceled_at", "started_at", "ends_at", "ended_at", "pause_at_period_end", "paused_at", "resumes_at", "customer_id", "product_id", "discount_id", "checkout_id", "customer_cancellation_reason", "customer_cancellation_comment", "metadata", "customer", "product", "discount", "prices", "meters", "pending_update"].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#==, #[], #field_set?, #hash, #inspect, json_keys, required_json_keys, #to_json, #to_json_hash, wrap_raw

Constructor Details

#initialize(created_at:, modified_at:, id:, amount:, currency:, recurring_interval:, recurring_interval_count:, status:, current_period_start:, current_period_end:, current_meter_period_start:, current_meter_period_end:, trial_start:, trial_end:, cancel_at_period_end:, canceled_at:, started_at:, ends_at:, ended_at:, past_due_at: ::Pago::UNSET, pause_at_period_end:, paused_at:, resumes_at:, customer_id:, product_id:, discount_id:, checkout_id:, seats: ::Pago::UNSET, customer_cancellation_reason:, customer_cancellation_comment:, metadata:, custom_field_data: ::Pago::UNSET, customer:, product:, discount:, prices:, meters:, pending_update:) ⇒ Subscription

Returns a new instance of Subscription.

Parameters:

  • created_at: (String)
  • modified_at: (String, nil)
  • id: (String)
  • amount: (Integer)
  • currency: (String)
  • recurring_interval: (String)
  • recurring_interval_count: (Integer)
  • status: (String)
  • current_period_start: (String)
  • current_period_end: (String)
  • current_meter_period_start: (String, nil)
  • current_meter_period_end: (String, nil)
  • trial_start: (String, nil)
  • trial_end: (String, nil)
  • cancel_at_period_end: (Boolean)
  • canceled_at: (String, nil)
  • started_at: (String, nil)
  • ends_at: (String, nil)
  • ended_at: (String, nil)
  • past_due_at: (String, nil) (defaults to: ::Pago::UNSET)
  • pause_at_period_end: (Boolean)
  • paused_at: (String, nil)
  • resumes_at: (String, nil)
  • customer_id: (String)
  • product_id: (String)
  • discount_id: (String, nil)
  • checkout_id: (String, nil)
  • seats: (Integer, nil) (defaults to: ::Pago::UNSET)
  • customer_cancellation_reason: (String, nil)
  • customer_cancellation_comment: (String, nil)
  • metadata: (Hash[String, untyped])
  • custom_field_data: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • customer: (Models::SubscriptionCustomer)
  • product: (Models::Product)
  • discount: (Object)
  • prices: (Array[untyped])
  • meters: (Array[Models::SubscriptionMeter])
  • pending_update: (Models::PendingSubscriptionUpdate, nil)


39429
39430
39431
39432
39433
39434
39435
39436
39437
39438
39439
39440
39441
39442
39443
39444
39445
39446
39447
39448
39449
39450
39451
39452
39453
39454
39455
39456
39457
39458
39459
39460
39461
39462
39463
39464
39465
39466
39467
39468
39469
39470
39471
39472
39473
39474
39475
39476
39477
39478
39479
39480
39481
39482
39483
39484
39485
39486
39487
39488
39489
39490
39491
39492
39493
39494
39495
39496
39497
39498
39499
39500
39501
39502
39503
39504
39505
39506
39507
39508
# File 'lib/pago/v2026_04/models.rb', line 39429

def initialize(
  created_at:,
  modified_at:,
  id:,
  amount:,
  currency:,
  recurring_interval:,
  recurring_interval_count:,
  status:,
  current_period_start:,
  current_period_end:,
  current_meter_period_start:,
  current_meter_period_end:,
  trial_start:,
  trial_end:,
  cancel_at_period_end:,
  canceled_at:,
  started_at:,
  ends_at:,
  ended_at:,
  past_due_at: ::Pago::UNSET,
  pause_at_period_end:,
  paused_at:,
  resumes_at:,
  customer_id:,
  product_id:,
  discount_id:,
  checkout_id:,
  seats: ::Pago::UNSET,
  customer_cancellation_reason:,
  customer_cancellation_comment:,
  metadata:,
  custom_field_data: ::Pago::UNSET,
  customer:,
  product:,
  discount:,
  prices:,
  meters:,
  pending_update:
)
  super()
  assign(:created_at, created_at)
  assign(:modified_at, modified_at)
  assign(:id, id)
  assign(:amount, amount)
  assign(:currency, currency)
  assign(:recurring_interval, recurring_interval)
  assign(:recurring_interval_count, recurring_interval_count)
  assign(:status, status)
  assign(:current_period_start, current_period_start)
  assign(:current_period_end, current_period_end)
  assign(:current_meter_period_start, current_meter_period_start)
  assign(:current_meter_period_end, current_meter_period_end)
  assign(:trial_start, trial_start)
  assign(:trial_end, trial_end)
  assign(:cancel_at_period_end, cancel_at_period_end)
  assign(:canceled_at, canceled_at)
  assign(:started_at, started_at)
  assign(:ends_at, ends_at)
  assign(:ended_at, ended_at)
  assign(:past_due_at, past_due_at)
  assign(:pause_at_period_end, pause_at_period_end)
  assign(:paused_at, paused_at)
  assign(:resumes_at, resumes_at)
  assign(:customer_id, customer_id)
  assign(:product_id, product_id)
  assign(:discount_id, discount_id)
  assign(:checkout_id, checkout_id)
  assign(:seats, seats)
  assign(:customer_cancellation_reason, customer_cancellation_reason)
  assign(:customer_cancellation_comment, customer_cancellation_comment)
  assign(:metadata, )
  assign(:custom_field_data, custom_field_data)
  assign(:customer, customer)
  assign(:product, product)
  assign(:discount, discount)
  assign(:prices, prices)
  assign(:meters, meters)
  assign(:pending_update, pending_update)
end

Instance Attribute Details

#amountInteger (readonly)

The amount of the subscription.

Returns:

  • (Integer)


39300
39301
39302
# File 'lib/pago/v2026_04/models.rb', line 39300

def amount
  @amount
end

#cancel_at_period_endBoolean (readonly)

Whether the subscription will be canceled at the end of the current period.

Returns:

  • (Boolean)


39342
39343
39344
# File 'lib/pago/v2026_04/models.rb', line 39342

def cancel_at_period_end
  @cancel_at_period_end
end

#canceled_atString? (readonly)

The timestamp when the subscription was canceled. The subscription might still be active if cancel_at_period_end is true.

Returns:

  • (String, nil)


39346
39347
39348
# File 'lib/pago/v2026_04/models.rb', line 39346

def canceled_at
  @canceled_at
end

#checkout_idString? (readonly)

Returns:

  • (String, nil)


39389
39390
39391
# File 'lib/pago/v2026_04/models.rb', line 39389

def checkout_id
  @checkout_id
end

#created_atString (readonly)

Creation timestamp of the object.

Returns:

  • (String)


39288
39289
39290
# File 'lib/pago/v2026_04/models.rb', line 39288

def created_at
  @created_at
end

#currencyString (readonly)

The currency of the subscription.

Returns:

  • (String)


39304
39305
39306
# File 'lib/pago/v2026_04/models.rb', line 39304

def currency
  @currency
end

#current_meter_period_endString? (readonly)

The end timestamp of the current meter period, if the product has a meter cycle set. This is when credits next renew.

Returns:

  • (String, nil)


39330
39331
39332
# File 'lib/pago/v2026_04/models.rb', line 39330

def current_meter_period_end
  @current_meter_period_end
end

#current_meter_period_startString? (readonly)

The start timestamp of the current meter period, if the product has a meter cycle set. Metered credits are granted and overage is settled on this cadence.

Returns:

  • (String, nil)


39326
39327
39328
# File 'lib/pago/v2026_04/models.rb', line 39326

def current_meter_period_start
  @current_meter_period_start
end

#current_period_endString (readonly)

The end timestamp of the current billing period.

Returns:

  • (String)


39322
39323
39324
# File 'lib/pago/v2026_04/models.rb', line 39322

def current_period_end
  @current_period_end
end

#current_period_startString (readonly)

The start timestamp of the current billing period.

Returns:

  • (String)


39318
39319
39320
# File 'lib/pago/v2026_04/models.rb', line 39318

def current_period_start
  @current_period_start
end

#custom_field_dataHash{String => String, Integer, Boolean, nil} (readonly)

Key-value object storing custom field values.

Returns:

  • (Hash{String => String, Integer, Boolean, nil})


39406
39407
39408
# File 'lib/pago/v2026_04/models.rb', line 39406

def custom_field_data
  @custom_field_data
end

#customerModels::SubscriptionCustomer (readonly)



39409
39410
39411
# File 'lib/pago/v2026_04/models.rb', line 39409

def customer
  @customer
end

#customer_cancellation_commentString? (readonly)

Returns:

  • (String, nil)


39399
39400
39401
# File 'lib/pago/v2026_04/models.rb', line 39399

def customer_cancellation_comment
  @customer_cancellation_comment
end

#customer_cancellation_reasonString? (readonly)

Returns:

  • (String, nil)


39396
39397
39398
# File 'lib/pago/v2026_04/models.rb', line 39396

def customer_cancellation_reason
  @customer_cancellation_reason
end

#customer_idString (readonly)

The ID of the subscribed customer.

Returns:

  • (String)


39378
39379
39380
# File 'lib/pago/v2026_04/models.rb', line 39378

def customer_id
  @customer_id
end

#discountModels::DiscountFixedOnceForeverDurationBase, ... (readonly)



39415
39416
39417
# File 'lib/pago/v2026_04/models.rb', line 39415

def discount
  @discount
end

#discount_idString? (readonly)

The ID of the applied discount, if any.

Returns:

  • (String, nil)


39386
39387
39388
# File 'lib/pago/v2026_04/models.rb', line 39386

def discount_id
  @discount_id
end

#ended_atString? (readonly)

The timestamp when the subscription ended.

Returns:

  • (String, nil)


39358
39359
39360
# File 'lib/pago/v2026_04/models.rb', line 39358

def ended_at
  @ended_at
end

#ends_atString? (readonly)

The timestamp when the subscription will end.

Returns:

  • (String, nil)


39354
39355
39356
# File 'lib/pago/v2026_04/models.rb', line 39354

def ends_at
  @ends_at
end

#idString (readonly)

The ID of the object.

Returns:

  • (String)


39296
39297
39298
# File 'lib/pago/v2026_04/models.rb', line 39296

def id
  @id
end

#metadataHash{String => String, Integer, Float, Boolean} (readonly)

Returns:

  • (Hash{String => String, Integer, Float, Boolean})


39402
39403
39404
# File 'lib/pago/v2026_04/models.rb', line 39402

def 
  @metadata
end

#metersArray<Models::SubscriptionMeter> (readonly)

List of meters associated with the subscription.

Returns:



39423
39424
39425
# File 'lib/pago/v2026_04/models.rb', line 39423

def meters
  @meters
end

#modified_atString? (readonly)

Last modification timestamp of the object.

Returns:

  • (String, nil)


39292
39293
39294
# File 'lib/pago/v2026_04/models.rb', line 39292

def modified_at
  @modified_at
end

#past_due_atString? (readonly)

The timestamp when the subscription entered past_due status.

Returns:

  • (String, nil)


39362
39363
39364
# File 'lib/pago/v2026_04/models.rb', line 39362

def past_due_at
  @past_due_at
end

#pause_at_period_endBoolean (readonly)

Whether the subscription will be paused at the end of the current period.

Returns:

  • (Boolean)


39366
39367
39368
# File 'lib/pago/v2026_04/models.rb', line 39366

def pause_at_period_end
  @pause_at_period_end
end

#paused_atString? (readonly)

The timestamp when the subscription was paused.

Returns:

  • (String, nil)


39370
39371
39372
# File 'lib/pago/v2026_04/models.rb', line 39370

def paused_at
  @paused_at
end

#pending_updateModels::PendingSubscriptionUpdate? (readonly)

Pending subscription update that will be applied at the beginning of the next period. If null, there is no pending update.



39427
39428
39429
# File 'lib/pago/v2026_04/models.rb', line 39427

def pending_update
  @pending_update
end

#pricesArray<Object> (readonly)

List of enabled prices for the subscription.

Returns:

  • (Array<Object>)


39419
39420
39421
# File 'lib/pago/v2026_04/models.rb', line 39419

def prices
  @prices
end

#productModels::Product (readonly)

Returns:



39412
39413
39414
# File 'lib/pago/v2026_04/models.rb', line 39412

def product
  @product
end

#product_idString (readonly)

The ID of the subscribed product.

Returns:

  • (String)


39382
39383
39384
# File 'lib/pago/v2026_04/models.rb', line 39382

def product_id
  @product_id
end

#recurring_intervalString (readonly)

Returns:

  • (String)


39307
39308
39309
# File 'lib/pago/v2026_04/models.rb', line 39307

def recurring_interval
  @recurring_interval
end

#recurring_interval_countInteger (readonly)

Number of interval units of the subscription. If this is set to 1 the charge will happen every interval (e.g. every month), if set to 2 it will be every other month, and so on.

Returns:

  • (Integer)


39311
39312
39313
# File 'lib/pago/v2026_04/models.rb', line 39311

def recurring_interval_count
  @recurring_interval_count
end

#resumes_atString? (readonly)

The timestamp when a paused subscription is scheduled to automatically resume, if set.

Returns:

  • (String, nil)


39374
39375
39376
# File 'lib/pago/v2026_04/models.rb', line 39374

def resumes_at
  @resumes_at
end

#seatsInteger? (readonly)

The number of seats for seat-based subscriptions. None for non-seat subscriptions.

Returns:

  • (Integer, nil)


39393
39394
39395
# File 'lib/pago/v2026_04/models.rb', line 39393

def seats
  @seats
end

#started_atString? (readonly)

The timestamp when the subscription started.

Returns:

  • (String, nil)


39350
39351
39352
# File 'lib/pago/v2026_04/models.rb', line 39350

def started_at
  @started_at
end

#statusString (readonly)

Returns:

  • (String)


39314
39315
39316
# File 'lib/pago/v2026_04/models.rb', line 39314

def status
  @status
end

#trial_endString? (readonly)

The end timestamp of the trial period, if any.

Returns:

  • (String, nil)


39338
39339
39340
# File 'lib/pago/v2026_04/models.rb', line 39338

def trial_end
  @trial_end
end

#trial_startString? (readonly)

The start timestamp of the trial period, if any.

Returns:

  • (String, nil)


39334
39335
39336
# File 'lib/pago/v2026_04/models.rb', line 39334

def trial_start
  @trial_start
end

Class Method Details

.from_json(data) ⇒ Subscription?

Parameters:

  • data (Hash, String, nil)

Returns:



39512
39513
39514
39515
39516
39517
39518
39519
39520
39521
39522
39523
39524
39525
39526
39527
39528
39529
39530
39531
39532
39533
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
39545
39546
39547
39548
39549
39550
39551
39552
39553
39554
39555
39556
39557
39558
39559
39560
# File 'lib/pago/v2026_04/models.rb', line 39512

def self.from_json(data)
  data = ::JSON.parse(data) if data.is_a?(String)
  data = ::Pago::Serde.object(data)
  return nil if data.nil?

  wrap_raw(
    new(
      created_at: (data.key?("created_at") ? data["created_at"] : ::Pago::UNSET),
      modified_at: (data.key?("modified_at") ? data["modified_at"] : ::Pago::UNSET),
      id: (data.key?("id") ? data["id"] : ::Pago::UNSET),
      amount: (data.key?("amount") ? data["amount"] : ::Pago::UNSET),
      currency: (data.key?("currency") ? data["currency"] : ::Pago::UNSET),
      recurring_interval: (data.key?("recurring_interval") ? data["recurring_interval"] : ::Pago::UNSET),
      recurring_interval_count: (data.key?("recurring_interval_count") ? data["recurring_interval_count"] : ::Pago::UNSET),
      status: (data.key?("status") ? data["status"] : ::Pago::UNSET),
      current_period_start: (data.key?("current_period_start") ? data["current_period_start"] : ::Pago::UNSET),
      current_period_end: (data.key?("current_period_end") ? data["current_period_end"] : ::Pago::UNSET),
      current_meter_period_start: (data.key?("current_meter_period_start") ? data["current_meter_period_start"] : ::Pago::UNSET),
      current_meter_period_end: (data.key?("current_meter_period_end") ? data["current_meter_period_end"] : ::Pago::UNSET),
      trial_start: (data.key?("trial_start") ? data["trial_start"] : ::Pago::UNSET),
      trial_end: (data.key?("trial_end") ? data["trial_end"] : ::Pago::UNSET),
      cancel_at_period_end: (data.key?("cancel_at_period_end") ? data["cancel_at_period_end"] : ::Pago::UNSET),
      canceled_at: (data.key?("canceled_at") ? data["canceled_at"] : ::Pago::UNSET),
      started_at: (data.key?("started_at") ? data["started_at"] : ::Pago::UNSET),
      ends_at: (data.key?("ends_at") ? data["ends_at"] : ::Pago::UNSET),
      ended_at: (data.key?("ended_at") ? data["ended_at"] : ::Pago::UNSET),
      past_due_at: (data.key?("past_due_at") ? data["past_due_at"] : ::Pago::UNSET),
      pause_at_period_end: (data.key?("pause_at_period_end") ? data["pause_at_period_end"] : ::Pago::UNSET),
      paused_at: (data.key?("paused_at") ? data["paused_at"] : ::Pago::UNSET),
      resumes_at: (data.key?("resumes_at") ? data["resumes_at"] : ::Pago::UNSET),
      customer_id: (data.key?("customer_id") ? data["customer_id"] : ::Pago::UNSET),
      product_id: (data.key?("product_id") ? data["product_id"] : ::Pago::UNSET),
      discount_id: (data.key?("discount_id") ? data["discount_id"] : ::Pago::UNSET),
      checkout_id: (data.key?("checkout_id") ? data["checkout_id"] : ::Pago::UNSET),
      seats: (data.key?("seats") ? data["seats"] : ::Pago::UNSET),
      customer_cancellation_reason: (data.key?("customer_cancellation_reason") ? data["customer_cancellation_reason"] : ::Pago::UNSET),
      customer_cancellation_comment: (data.key?("customer_cancellation_comment") ? data["customer_cancellation_comment"] : ::Pago::UNSET),
      metadata: (data.key?("metadata") ? data["metadata"] : ::Pago::UNSET),
      custom_field_data: (data.key?("custom_field_data") ? data["custom_field_data"] : ::Pago::UNSET),
      customer: (data.key?("customer") ? Models::SubscriptionCustomer.from_json(data["customer"]) : ::Pago::UNSET),
      product: (data.key?("product") ? Models::Product.from_json(data["product"]) : ::Pago::UNSET),
      discount: (data.key?("discount") ? ::Pago::Serde.union(data["discount"], variants: [Models::DiscountFixedOnceForeverDurationBase, Models::DiscountFixedRepeatDurationBase, Models::DiscountPercentageOnceForeverDurationBase, Models::DiscountPercentageRepeatDurationBase]) : ::Pago::UNSET),
      prices: (data.key?("prices") ? ::Pago::Serde.array(data["prices"]) { |item0| ::Pago::Serde.union(item0, variants: [Unions::LegacyRecurringProductPrice, Unions::ProductPrice]) } : ::Pago::UNSET),
      meters: (data.key?("meters") ? ::Pago::Serde.array(data["meters"]) { |item0| Models::SubscriptionMeter.from_json(item0) } : ::Pago::UNSET),
      pending_update: (data.key?("pending_update") ? Models::PendingSubscriptionUpdate.from_json(data["pending_update"]) : ::Pago::UNSET)
    ),
    data
  )
end