Class: Dodopayments::Resources::ProductCollections

Inherits:
Object
  • Object
show all
Defined in:
lib/dodopayments/resources/product_collections.rb,
lib/dodopayments/resources/product_collections/groups.rb,
lib/dodopayments/resources/product_collections/groups/items.rb

Defined Under Namespace

Classes: Groups

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ProductCollections

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

Parameters:



199
200
201
202
# File 'lib/dodopayments/resources/product_collections.rb', line 199

def initialize(client:)
  @client = client
  @groups = Dodopayments::Resources::ProductCollections::Groups.new(client: client)
end

Instance Attribute Details

#groupsDodopayments::Resources::ProductCollections::Groups (readonly)



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

def groups
  @groups
end

Instance Method Details

#create(groups:, name:, brand_id: nil, description: nil, effective_at_on_downgrade: nil, effective_at_on_upgrade: nil, on_payment_failure: nil, proration_billing_mode_on_downgrade: nil, proration_billing_mode_on_upgrade: nil, request_options: {}) ⇒ Dodopayments::Models::ProductCollection

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

Parameters:

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/dodopayments/resources/product_collections.rb', line 37

def create(params)
  parsed, options = Dodopayments::ProductCollectionCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "product-collections",
    body: parsed,
    model: Dodopayments::ProductCollection,
    options: options
  )
end

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

Parameters:

Returns:

  • (nil)

See Also:



146
147
148
149
150
151
152
153
# File 'lib/dodopayments/resources/product_collections.rb', line 146

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

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

Parameters:

  • archived (Boolean)

    List archived collections

  • 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

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

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/dodopayments/resources/product_collections.rb', line 124

def list(params = {})
  parsed, options = Dodopayments::ProductCollectionListParams.dump_request(params)
  query = Dodopayments::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "product-collections",
    query: query,
    page: Dodopayments::Internal::DefaultPageNumberPagination,
    model: Dodopayments::Models::ProductCollectionListResponse,
    options: options
  )
end

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

Parameters:

Returns:

See Also:



57
58
59
60
61
62
63
64
# File 'lib/dodopayments/resources/product_collections.rb', line 57

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

#unarchive(id, request_options: {}) ⇒ Dodopayments::Models::ProductCollectionUnarchiveResponse

Parameters:

Returns:

See Also:



164
165
166
167
168
169
170
171
# File 'lib/dodopayments/resources/product_collections.rb', line 164

def unarchive(id, params = {})
  @client.request(
    method: :post,
    path: ["product-collections/%1$s/unarchive", id],
    model: Dodopayments::Models::ProductCollectionUnarchiveResponse,
    options: params[:request_options]
  )
end

#update(id, brand_id: nil, description: nil, effective_at_on_downgrade: nil, effective_at_on_upgrade: nil, group_order: nil, image_id: nil, name: nil, on_payment_failure: nil, proration_billing_mode_on_downgrade: nil, proration_billing_mode_on_upgrade: nil, request_options: {}) ⇒ nil

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

Parameters:

Returns:

  • (nil)

See Also:



98
99
100
101
102
103
104
105
106
107
# File 'lib/dodopayments/resources/product_collections.rb', line 98

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

#update_images(id, force_update: nil, request_options: {}) ⇒ Dodopayments::Models::ProductCollectionUpdateImagesResponse

Parameters:

  • id (String)

    Product Collection Id

  • force_update (Boolean, nil)

    If true, generates a new image ID to force cache invalidation

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

Returns:

See Also:



184
185
186
187
188
189
190
191
192
193
194
# File 'lib/dodopayments/resources/product_collections.rb', line 184

def update_images(id, params = {})
  parsed, options = Dodopayments::ProductCollectionUpdateImagesParams.dump_request(params)
  query = Dodopayments::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :put,
    path: ["product-collections/%1$s/images", id],
    query: query,
    model: Dodopayments::Models::ProductCollectionUpdateImagesResponse,
    options: options
  )
end