Class: Dodopayments::Resources::Addons

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Addons

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 Addons.

Parameters:



128
129
130
# File 'lib/dodopayments/resources/addons.rb', line 128

def initialize(client:)
  @client = client
end

Instance Method Details

#create(currency: , name: , price: , tax_category: , description: nil, request_options: {}) ⇒ Dodopayments::Models::AddonResponse

Parameters:

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/dodopayments/resources/addons.rb', line 23

def create(params)
  parsed, options = Dodopayments::AddonCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "addons",
    body: parsed,
    model: Dodopayments::AddonResponse,
    options: options
  )
end

#list(page_number: nil, page_size: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::AddonResponse>

Parameters:

  • page_number (Integer)

    Page number default is 0

  • page_size (Integer)

    Page size default is 10 max is 100

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

Returns:

See Also:



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/dodopayments/resources/addons.rb', line 95

def list(params = {})
  parsed, options = Dodopayments::AddonListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "addons",
    query: parsed,
    page: Dodopayments::Internal::DefaultPageNumberPagination,
    model: Dodopayments::AddonResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Dodopayments::Models::AddonResponse

Parameters:

Returns:

See Also:



43
44
45
46
47
48
49
50
# File 'lib/dodopayments/resources/addons.rb', line 43

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["addons/%1$s", id],
    model: Dodopayments::AddonResponse,
    options: params[:request_options]
  )
end

#update(id, currency: nil, description: nil, image_id: nil, name: nil, price: nil, tax_category: nil, request_options: {}) ⇒ Dodopayments::Models::AddonResponse

Parameters:

  • id (String)

    Addon Id

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

    The currency of the Addon

  • description (String, nil)

    Description of the Addon, optional and must be at most 1000 characters.

  • image_id (String, nil)

    Addon image id after its uploaded to S3

  • name (String, nil)

    Name of the Addon, optional and must be at most 100 characters.

  • price (Integer, nil)

    Amount of the addon

  • tax_category (Symbol, Dodopayments::Models::TaxCategory, nil)

    Tax category of the Addon.

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

Returns:

See Also:



73
74
75
76
77
78
79
80
81
82
# File 'lib/dodopayments/resources/addons.rb', line 73

def update(id, params = {})
  parsed, options = Dodopayments::AddonUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["addons/%1$s", id],
    body: parsed,
    model: Dodopayments::AddonResponse,
    options: options
  )
end

#update_images(id, request_options: {}) ⇒ Dodopayments::Models::AddonUpdateImagesResponse

Parameters:

Returns:

See Also:



116
117
118
119
120
121
122
123
# File 'lib/dodopayments/resources/addons.rb', line 116

def update_images(id, params = {})
  @client.request(
    method: :put,
    path: ["addons/%1$s/images", id],
    model: Dodopayments::Models::AddonUpdateImagesResponse,
    options: params[:request_options]
  )
end