Module: Pago::V2026_04::Unions::Benefit

Defined in:
lib/pago/v2026_04/unions.rb,
sig/pago/v2026_04/generated.rbs

Overview

Variants: Models::BenefitCustom, Models::BenefitDiscord, Models::BenefitGitHubRepository, Models::BenefitDownloadables, Models::BenefitLicenseKeys, Models::BenefitMeterCredit, Models::BenefitFeatureFlag, Models::BenefitSlackSharedChannel.

Constant Summary collapse

DISCRIMINATOR =

Returns:

  • (String, nil)
"type"

Class Method Summary collapse

Class Method Details

.from_json(data) ⇒ Object?

Returns the resolved variant, or the raw payload.

Parameters:

  • data (Hash, String, nil)

Returns:

  • (Object, nil)

    the resolved variant, or the raw payload.



38
39
40
41
# File 'lib/pago/v2026_04/unions.rb', line 38

def self.from_json(data)
  data = ::JSON.parse(data) if data.is_a?(String)
  ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
end

.mappingHash{String => Class}

Returns discriminator value to model class.

Returns:

  • (Hash{String => Class})

    discriminator value to model class.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pago/v2026_04/unions.rb', line 18

def self.mapping
  @mapping ||= {
    "custom" => Models::BenefitCustom,
    "discord" => Models::BenefitDiscord,
    "downloadables" => Models::BenefitDownloadables,
    "feature_flag" => Models::BenefitFeatureFlag,
    "github_repository" => Models::BenefitGitHubRepository,
    "license_keys" => Models::BenefitLicenseKeys,
    "meter_credit" => Models::BenefitMeterCredit,
    "slack_shared_channel" => Models::BenefitSlackSharedChannel
  }.freeze
end

.variantsArray<Class>

Returns every model this union can resolve to.

Returns:

  • (Array<Class>)

    every model this union can resolve to.



32
33
34
# File 'lib/pago/v2026_04/unions.rb', line 32

def self.variants
  @variants ||= [Models::BenefitCustom, Models::BenefitDiscord, Models::BenefitGitHubRepository, Models::BenefitDownloadables, Models::BenefitLicenseKeys, Models::BenefitMeterCredit, Models::BenefitFeatureFlag, Models::BenefitSlackSharedChannel].freeze
end