Class: Pago::V2026_04::Models::DiscountPercentageRepeatDuration

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

Overview

Schema for a percentage discount that is applied on every invoice for a certain number of months.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  duration: "duration",
  duration_in_months: "duration_in_months",
  type: "type",
  basis_points: "basis_points",
  created_at: "created_at",
  modified_at: "modified_at",
  id: "id",
  metadata: "metadata",
  name: "name",
  code: "code",
  starts_at: "starts_at",
  ends_at: "ends_at",
  max_redemptions: "max_redemptions",
  redemptions_count: "redemptions_count",
  organization_id: "organization_id",
  products: "products"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["duration", "duration_in_months", "type", "basis_points", "created_at", "modified_at", "id", "metadata", "name", "code", "starts_at", "ends_at", "max_redemptions", "redemptions_count", "organization_id", "products"].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(duration:, duration_in_months:, type:, basis_points:, created_at:, modified_at:, id:, metadata:, name:, code:, starts_at:, ends_at:, max_redemptions:, redemptions_count:, organization_id:, products:) ⇒ DiscountPercentageRepeatDuration

Returns a new instance of DiscountPercentageRepeatDuration.

Parameters:

  • duration: (String)
  • duration_in_months: (Integer)
  • type: (String)
  • basis_points: (Integer)
  • created_at: (String)
  • modified_at: (String, nil)
  • id: (String)
  • metadata: (Hash[String, untyped])
  • name: (String)
  • code: (String, nil)
  • starts_at: (String, nil)
  • ends_at: (String, nil)
  • max_redemptions: (Integer, nil)
  • redemptions_count: (Integer)
  • organization_id: (String)
  • products: (Array[Models::DiscountProduct])


23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
# File 'lib/pago/v2026_04/models.rb', line 23627

def initialize(
  duration:,
  duration_in_months:,
  type:,
  basis_points:,
  created_at:,
  modified_at:,
  id:,
  metadata:,
  name:,
  code:,
  starts_at:,
  ends_at:,
  max_redemptions:,
  redemptions_count:,
  organization_id:,
  products:
)
  super()
  assign(:duration, duration)
  assign(:duration_in_months, duration_in_months)
  assign(:type, type)
  assign(:basis_points, basis_points)
  assign(:created_at, created_at)
  assign(:modified_at, modified_at)
  assign(:id, id)
  assign(:metadata, )
  assign(:name, name)
  assign(:code, code)
  assign(:starts_at, starts_at)
  assign(:ends_at, ends_at)
  assign(:max_redemptions, max_redemptions)
  assign(:redemptions_count, redemptions_count)
  assign(:organization_id, organization_id)
  assign(:products, products)
end

Instance Attribute Details

#basis_pointsInteger (readonly)

Discount percentage in basis points. A basis point is 1/100th of a percent. For example, 1000 basis points equals a 10% discount.

Returns:

  • (Integer)


23579
23580
23581
# File 'lib/pago/v2026_04/models.rb', line 23579

def basis_points
  @basis_points
end

#codeString? (readonly)

Code customers can use to apply the discount during checkout.

Returns:

  • (String, nil)


23602
23603
23604
# File 'lib/pago/v2026_04/models.rb', line 23602

def code
  @code
end

#created_atString (readonly)

Creation timestamp of the object.

Returns:

  • (String)


23583
23584
23585
# File 'lib/pago/v2026_04/models.rb', line 23583

def created_at
  @created_at
end

#durationString (readonly)

Returns:

  • (String)


23569
23570
23571
# File 'lib/pago/v2026_04/models.rb', line 23569

def duration
  @duration
end

#duration_in_monthsInteger (readonly)

Returns:

  • (Integer)


23572
23573
23574
# File 'lib/pago/v2026_04/models.rb', line 23572

def duration_in_months
  @duration_in_months
end

#ends_atString? (readonly)

Timestamp after which the discount is no longer redeemable.

Returns:

  • (String, nil)


23610
23611
23612
# File 'lib/pago/v2026_04/models.rb', line 23610

def ends_at
  @ends_at
end

#idString (readonly)

The ID of the object.

Returns:

  • (String)


23591
23592
23593
# File 'lib/pago/v2026_04/models.rb', line 23591

def id
  @id
end

#max_redemptionsInteger? (readonly)

Maximum number of times the discount can be redeemed.

Returns:

  • (Integer, nil)


23614
23615
23616
# File 'lib/pago/v2026_04/models.rb', line 23614

def max_redemptions
  @max_redemptions
end

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

Returns:

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


23594
23595
23596
# File 'lib/pago/v2026_04/models.rb', line 23594

def 
  @metadata
end

#modified_atString? (readonly)

Last modification timestamp of the object.

Returns:

  • (String, nil)


23587
23588
23589
# File 'lib/pago/v2026_04/models.rb', line 23587

def modified_at
  @modified_at
end

#nameString (readonly)

Name of the discount. Will be displayed to the customer when the discount is applied.

Returns:

  • (String)


23598
23599
23600
# File 'lib/pago/v2026_04/models.rb', line 23598

def name
  @name
end

#organization_idString (readonly)

The organization ID.

Returns:

  • (String)


23622
23623
23624
# File 'lib/pago/v2026_04/models.rb', line 23622

def organization_id
  @organization_id
end

#productsArray<Models::DiscountProduct> (readonly)

Returns:



23625
23626
23627
# File 'lib/pago/v2026_04/models.rb', line 23625

def products
  @products
end

#redemptions_countInteger (readonly)

Number of times the discount has been redeemed.

Returns:

  • (Integer)


23618
23619
23620
# File 'lib/pago/v2026_04/models.rb', line 23618

def redemptions_count
  @redemptions_count
end

#starts_atString? (readonly)

Timestamp after which the discount is redeemable.

Returns:

  • (String, nil)


23606
23607
23608
# File 'lib/pago/v2026_04/models.rb', line 23606

def starts_at
  @starts_at
end

#typeString (readonly)

Returns:

  • (String)


23575
23576
23577
# File 'lib/pago/v2026_04/models.rb', line 23575

def type
  @type
end

Class Method Details

.from_json(data) ⇒ DiscountPercentageRepeatDuration?

Parameters:

  • data (Hash, String, nil)

Returns:



23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
# File 'lib/pago/v2026_04/models.rb', line 23666

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(
      duration: (data.key?("duration") ? data["duration"] : ::Pago::UNSET),
      duration_in_months: (data.key?("duration_in_months") ? data["duration_in_months"] : ::Pago::UNSET),
      type: (data.key?("type") ? data["type"] : ::Pago::UNSET),
      basis_points: (data.key?("basis_points") ? data["basis_points"] : ::Pago::UNSET),
      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),
      metadata: (data.key?("metadata") ? data["metadata"] : ::Pago::UNSET),
      name: (data.key?("name") ? data["name"] : ::Pago::UNSET),
      code: (data.key?("code") ? data["code"] : ::Pago::UNSET),
      starts_at: (data.key?("starts_at") ? data["starts_at"] : ::Pago::UNSET),
      ends_at: (data.key?("ends_at") ? data["ends_at"] : ::Pago::UNSET),
      max_redemptions: (data.key?("max_redemptions") ? data["max_redemptions"] : ::Pago::UNSET),
      redemptions_count: (data.key?("redemptions_count") ? data["redemptions_count"] : ::Pago::UNSET),
      organization_id: (data.key?("organization_id") ? data["organization_id"] : ::Pago::UNSET),
      products: (data.key?("products") ? ::Pago::Serde.array(data["products"]) { |item0| Models::DiscountProduct.from_json(item0) } : ::Pago::UNSET)
    ),
    data
  )
end