Class: Dodopayments::Resources::Products

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

Defined Under Namespace

Classes: Images

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Products

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

Parameters:



212
213
214
215
# File 'lib/dodopayments/resources/products.rb', line 212

def initialize(client:)
  @client = client
  @images = Dodopayments::Resources::Products::Images.new(client: client)
end

Instance Attribute Details

#imagesDodopayments::Resources::Products::Images (readonly)



7
8
9
# File 'lib/dodopayments/resources/products.rb', line 7

def images
  @images
end

Instance Method Details

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

Parameters:

Returns:

  • (nil)

See Also:



161
162
163
164
165
166
167
168
# File 'lib/dodopayments/resources/products.rb', line 161

def archive(id, params = {})
  @client.request(
    method: :delete,
    path: ["products/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#create(name: , price: , tax_category: , addons: nil, brand_id: nil, description: nil, digital_product_delivery: nil, license_key_activation_message: nil, license_key_activations_limit: nil, license_key_duration: nil, license_key_enabled: nil, metadata: nil, request_options: {}) ⇒ Dodopayments::Models::Product

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

Parameters:

Returns:

See Also:



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

def create(params)
  parsed, options = Dodopayments::ProductCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "products",
    body: parsed,
    model: Dodopayments::Product,
    options: options
  )
end

#list(archived: nil, brand_id: nil, page_number: nil, page_size: nil, recurring: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::ProductListResponse>

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

Parameters:

  • archived (Boolean)

    List archived products

  • brand_id (String)

    filter by Brand id

  • page_number (Integer)

    Page number default is 0

  • page_size (Integer)

    Page size default is 10 max is 100

  • recurring (Boolean)

    Filter products by pricing type:

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

Returns:

See Also:



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/dodopayments/resources/products.rb', line 141

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

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

Parameters:

Returns:

See Also:



63
64
65
66
67
68
69
70
# File 'lib/dodopayments/resources/products.rb', line 63

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

#unarchive(id, request_options: {}) ⇒ nil

Parameters:

Returns:

  • (nil)

See Also:



178
179
180
181
182
183
184
185
# File 'lib/dodopayments/resources/products.rb', line 178

def unarchive(id, params = {})
  @client.request(
    method: :post,
    path: ["products/%1$s/unarchive", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#update(id, addons: nil, brand_id: nil, description: nil, digital_product_delivery: nil, image_id: nil, license_key_activation_message: nil, license_key_activations_limit: nil, license_key_duration: nil, license_key_enabled: nil, metadata: nil, name: nil, price: nil, tax_category: nil, request_options: {}) ⇒ nil

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

Parameters:

Returns:

  • (nil)

See Also:



110
111
112
113
114
115
116
117
118
119
# File 'lib/dodopayments/resources/products.rb', line 110

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

#update_files(id, file_name: , request_options: {}) ⇒ Dodopayments::Models::ProductUpdateFilesResponse

Parameters:

Returns:

See Also:



198
199
200
201
202
203
204
205
206
207
# File 'lib/dodopayments/resources/products.rb', line 198

def update_files(id, params)
  parsed, options = Dodopayments::ProductUpdateFilesParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["products/%1$s/files", id],
    body: parsed,
    model: Dodopayments::Models::ProductUpdateFilesResponse,
    options: options
  )
end