Class: Pago::V2026_04::Models::SubscriptionCreateExternalCustomer

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

Overview

Create a subscription for an existing customer identified by an external ID.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  metadata: "metadata",
  product_id: "product_id",
  external_customer_id: "external_customer_id"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["product_id", "external_customer_id"].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(metadata: ::Pago::UNSET, product_id:, external_customer_id:) ⇒ SubscriptionCreateExternalCustomer

Returns a new instance of SubscriptionCreateExternalCustomer.

Parameters:

  • metadata: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • product_id: (String)
  • external_customer_id: (String)


40151
40152
40153
40154
40155
40156
40157
40158
40159
40160
# File 'lib/pago/v2026_04/models.rb', line 40151

def initialize(
  metadata: ::Pago::UNSET,
  product_id:,
  external_customer_id:
)
  super()
  assign(:metadata, )
  assign(:product_id, product_id)
  assign(:external_customer_id, external_customer_id)
end

Instance Attribute Details

#external_customer_idString (readonly)

The ID of the customer in your system to create the subscription for. It must already exist in Pago.

Returns:

  • (String)


40149
40150
40151
# File 'lib/pago/v2026_04/models.rb', line 40149

def external_customer_id
  @external_customer_id
end

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

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

Returns:

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


40141
40142
40143
# File 'lib/pago/v2026_04/models.rb', line 40141

def 
  @metadata
end

#product_idString (readonly)

The ID of the recurring product to subscribe to. Must be a free product, otherwise the customer should go through a checkout flow.

Returns:

  • (String)


40145
40146
40147
# File 'lib/pago/v2026_04/models.rb', line 40145

def product_id
  @product_id
end

Class Method Details

.from_json(data) ⇒ SubscriptionCreateExternalCustomer?

Parameters:

  • data (Hash, String, nil)

Returns:



40164
40165
40166
40167
40168
40169
40170
40171
40172
40173
40174
40175
40176
40177
# File 'lib/pago/v2026_04/models.rb', line 40164

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(
      metadata: (data.key?("metadata") ? data["metadata"] : ::Pago::UNSET),
      product_id: (data.key?("product_id") ? data["product_id"] : ::Pago::UNSET),
      external_customer_id: (data.key?("external_customer_id") ? data["external_customer_id"] : ::Pago::UNSET)
    ),
    data
  )
end