Class: Dodopayments::Resources::Products::LocalizedPrices

Inherits:
Object
  • Object
show all
Defined in:
lib/dodopayments/resources/products/localized_prices.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ LocalizedPrices

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LocalizedPrices.

Parameters:



138
139
140
# File 'lib/dodopayments/resources/products/localized_prices.rb', line 138

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(id, product_id:, request_options: {}) ⇒ nil

Parameters:

  • id (String)

    Localized Price Id

  • product_id (String)

    Product Id

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/dodopayments/resources/products/localized_prices.rb', line 121

def archive(id, params)
  parsed, options = Dodopayments::Products::LocalizedPriceArchiveParams.dump_request(params)
  product_id =
    parsed.delete(:product_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["products/%1$s/localized-prices/%2$s", product_id, id],
    model: NilClass,
    options: options
  )
end

#create(product_id, amount:, currency:, country_code: nil, request_options: {}) ⇒ Dodopayments::Models::Products::LocalizedPrice

Some parameter documentations has been truncated, see Models::Products::LocalizedPriceCreateParams for more details.

Parameters:

  • product_id (String)

    Product Id

  • amount (Integer)

    Amount in the smallest currency unit (e.g., cents). Must be greater than zero.

  • currency (Symbol, Dodopayments::Models::Currency)

    Currency to charge in. Must be a supported currency.

  • country_code (Symbol, Dodopayments::Models::CountryCode, nil)

    Required when the product’s pricing_mode is by_country; forbidden when by_curren

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



25
26
27
28
29
30
31
32
33
34
# File 'lib/dodopayments/resources/products/localized_prices.rb', line 25

def create(product_id, params)
  parsed, options = Dodopayments::Products::LocalizedPriceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["products/%1$s/localized-prices", product_id],
    body: parsed,
    model: Dodopayments::Products::LocalizedPrice,
    options: options
  )
end

#list(product_id, request_options: {}) ⇒ Dodopayments::Models::Products::ListLocalizedPricesResponse

Parameters:

Returns:

See Also:



101
102
103
104
105
106
107
108
# File 'lib/dodopayments/resources/products/localized_prices.rb', line 101

def list(product_id, params = {})
  @client.request(
    method: :get,
    path: ["products/%1$s/localized-prices", product_id],
    model: Dodopayments::Products::ListLocalizedPricesResponse,
    options: params[:request_options]
  )
end

#retrieve(id, product_id:, request_options: {}) ⇒ Dodopayments::Models::Products::LocalizedPrice

Parameters:

  • id (String)

    Localized Price Id

  • product_id (String)

    Product Id

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/dodopayments/resources/products/localized_prices.rb', line 47

def retrieve(id, params)
  parsed, options = Dodopayments::Products::LocalizedPriceRetrieveParams.dump_request(params)
  product_id =
    parsed.delete(:product_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["products/%1$s/localized-prices/%2$s", product_id, id],
    model: Dodopayments::Products::LocalizedPrice,
    options: options
  )
end

#update(id, product_id:, amount: nil, request_options: {}) ⇒ Dodopayments::Models::Products::LocalizedPrice

Some parameter documentations has been truncated, see Models::Products::LocalizedPriceUpdateParams for more details.

Parameters:

  • id (String)

    Path param: Localized Price Id

  • product_id (String)

    Path param: Product Id

  • amount (Integer, nil)

    Body param: New amount in the smallest currency unit (e.g., cents). Must be grea

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/dodopayments/resources/products/localized_prices.rb', line 77

def update(id, params)
  parsed, options = Dodopayments::Products::LocalizedPriceUpdateParams.dump_request(params)
  product_id =
    parsed.delete(:product_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["products/%1$s/localized-prices/%2$s", product_id, id],
    body: parsed,
    model: Dodopayments::Products::LocalizedPrice,
    options: options
  )
end