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:



173
174
175
176
# File 'lib/dodopayments/resources/product_collections.rb', line 173

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, request_options: {}) ⇒ Dodopayments::Models::ProductCollection

Parameters:

Returns:

See Also:



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

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:



120
121
122
123
124
125
126
127
# File 'lib/dodopayments/resources/product_collections.rb', line 120

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:



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

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:



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

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:



138
139
140
141
142
143
144
145
# File 'lib/dodopayments/resources/product_collections.rb', line 138

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, group_order: nil, image_id: nil, name: nil, request_options: {}) ⇒ nil

Parameters:

  • id (String)

    Product Collection Id

  • brand_id (String, nil)

    Optional brand_id update

  • description (String, nil)

    Optional description update - pass null to remove, omit to keep unchanged

  • group_order (Array<String>, nil)

    Optional new order for groups (array of group UUIDs in desired order)

  • image_id (String, nil)

    Optional image update - pass null to remove, omit to keep unchanged

  • name (String, nil)

    Optional new name for the collection

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

Returns:

  • (nil)

See Also:



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

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:



158
159
160
161
162
163
164
165
166
167
168
# File 'lib/dodopayments/resources/product_collections.rb', line 158

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