Class: Stigg::Resources::V1::Products

Inherits:
Object
  • Object
show all
Defined in:
lib/stigg/resources/v1/products.rb

Overview

Operations related to products

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:



242
243
244
# File 'lib/stigg/resources/v1/products.rb', line 242

def initialize(client:)
  @client = client
end

Instance Method Details

#archive_product(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Product

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

Archives a product, preventing new subscriptions. All plans and addons are archived.

Parameters:

  • id (String)

    The unique identifier of the entity

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/stigg/resources/v1/products.rb', line 27

def archive_product(id, params = {})
  parsed, options = Stigg::V1::ProductArchiveProductParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1/products/%1$s/archive", id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Product,
    options: options
  )
end

#create_product(id:, display_name:, description: nil, metadata: nil, multiple_subscriptions: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Product

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

Creates a new product.

Parameters:

  • id (String)

    Body param: The unique identifier for the entity

  • display_name (String)

    Body param: Display name of the product

  • description (String, nil)

    Body param: Description of the product

  • metadata (Hash{Symbol=>String}, nil)

    Body param: Additional metadata for the product

  • multiple_subscriptions (Boolean)

    Body param: Indicates if multiple subscriptions to this product are allowed

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/stigg/resources/v1/products.rb', line 67

def create_product(params)
  parsed, options = Stigg::V1::ProductCreateProductParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :post,
    path: "api/v1/products",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::V1::Product,
    options: options
  )
end

#duplicate_product(id, target_id:, description: nil, display_name: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Product

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

Duplicates an existing product, including its plans, addons, and configuration.

Parameters:

  • id (String)

    Path param: The unique identifier of the entity

  • target_id (String)

    Body param: The unique identifier for the entity

  • description (String, nil)

    Body param: Description of the product

  • display_name (String)

    Body param: Display name of the product

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/stigg/resources/v1/products.rb', line 104

def duplicate_product(id, params)
  parsed, options = Stigg::V1::ProductDuplicateProductParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :post,
    path: ["api/v1/products/%1$s/duplicate", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::V1::Product,
    options: options
  )
end

#list_products(id: nil, after: nil, before: nil, created_at: nil, limit: nil, status: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::ProductListProductsResponse>

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

Retrieves a paginated list of products in the environment.

Parameters:

  • id (String)

    Query param: Filter by entity ID

  • after (String)

    Query param: Return items that come after this cursor

  • before (String)

    Query param: Return items that come before this cursor

  • created_at (Stigg::Models::V1::ProductListProductsParams::CreatedAt)

    Query param: Filter by creation date using range operators: gt, gte, lt, lte

  • limit (Integer)

    Query param: Maximum number of items to return

  • status (Array<Symbol, Stigg::Models::V1::ProductListProductsParams::Status>)

    Query param: Filter by product status. Supports comma-separated values for multi

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/stigg/resources/v1/products.rb', line 145

def list_products(params = {})
  query_params = [:id, :after, :before, :created_at, :limit, :status]
  parsed, options = Stigg::V1::ProductListProductsParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "api/v1/products",
    query: query.transform_keys(created_at: "createdAt"),
    headers: parsed.except(*query_params).transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    page: Stigg::Internal::MyCursorIDPage,
    model: Stigg::Models::V1::ProductListProductsResponse,
    options: options
  )
end

#unarchive_product(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Product

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

Restores an archived product, allowing new subscriptions to be created.

Parameters:

  • id (String)

    The unique identifier of the entity

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

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

Returns:

See Also:



181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/stigg/resources/v1/products.rb', line 181

def unarchive_product(id, params = {})
  parsed, options = Stigg::V1::ProductUnarchiveProductParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1/products/%1$s/unarchive", id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Product,
    options: options
  )
end

#update_product(id, description: nil, display_name: nil, metadata: nil, multiple_subscriptions: nil, product_settings: nil, usage_reset_cutoff_rule: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Product

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

Updates an existing product’s properties such as display name, description, and metadata.

Parameters:

  • id (String)

    Path param: The unique identifier of the entity

  • description (String, nil)

    Body param: Description of the product

  • display_name (String)

    Body param: Display name of the product

  • metadata (Hash{Symbol=>String}, nil)

    Body param: Additional metadata for the product

  • multiple_subscriptions (Boolean)

    Body param: Indicates if multiple subscriptions to this product are allowed

  • product_settings (Stigg::Models::V1::ProductUpdateProductParams::ProductSettings)

    Body param

  • usage_reset_cutoff_rule (Stigg::Models::V1::ProductUpdateProductParams::UsageResetCutoffRule)

    Body param: Rule defining when usage resets upon subscription update.

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/stigg/resources/v1/products.rb', line 226

def update_product(id, params = {})
  parsed, options = Stigg::V1::ProductUpdateProductParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :patch,
    path: ["api/v1/products/%1$s", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::V1::Product,
    options: options
  )
end