Class: Stigg::Resources::V1::Credits::CustomCurrencies

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

Overview

Operations related to custom currencies

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CustomCurrencies

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

Parameters:



239
240
241
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 239

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(currency_id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CustomCurrencyResponse

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

Archives a custom currency. Fails if the currency is still associated with any active plan or addon — use the associated-entities endpoint first to inspect dependencies.

Parameters:

  • currency_id (String)

    The reference ID of the custom currency

  • 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:



155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 155

def archive(currency_id, params = {})
  parsed, options = Stigg::V1::Credits::CustomCurrencyArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1/credits/custom-currencies/%1$s/archive", currency_id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Credits::CustomCurrencyResponse,
    options: options
  )
end

#create(id:, display_name:, description: nil, metadata: nil, symbol: nil, units: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CustomCurrencyResponse

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

Creates a new custom currency in the environment.

Parameters:

  • id (String)

    Body param: The unique identifier for the new custom currency

  • display_name (String)

    Body param: The display name of the custom currency

  • description (String)

    Body param: Description of the currency

  • metadata (Hash{Symbol=>String})

    Body param: Additional metadata to attach to the custom currency

  • symbol (String)

    Body param: The symbol used to represent the custom currency

  • units (Stigg::Models::V1::Credits::CustomCurrencyCreateParams::Units)

    Body param: Singular and plural unit labels for a custom currency. Both fields a

  • 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:



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 37

def create(params)
  parsed, options = Stigg::V1::Credits::CustomCurrencyCreateParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :post,
    path: "api/v1/credits/custom-currencies",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::V1::Credits::CustomCurrencyResponse,
    options: options
  )
end

#list(after: nil, before: nil, limit: nil, status: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::Credits::CustomCurrencyListResponse>

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

Retrieves a paginated list of custom currencies in the environment. Archived currencies are excluded by default; pass ‘status=ARCHIVED` (or `status=ACTIVE,ARCHIVED`) to include them.

Parameters:

  • after (String)

    Query param: Return items that come after this cursor

  • before (String)

    Query param: Return items that come before this cursor

  • limit (Integer)

    Query param: Maximum number of items to return

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

    Query param: Filter by custom currency status. Supports comma-separated values (

  • 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:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 117

def list(params = {})
  query_params = [:after, :before, :limit, :status]
  parsed, options = Stigg::V1::Credits::CustomCurrencyListParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "api/v1/credits/custom-currencies",
    query: query,
    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::Credits::CustomCurrencyListResponse,
    options: options
  )
end

#list_associated_entities(currency_id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CustomCurrencyListAssociatedEntitiesResponse

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

Lists the active plans and addons that reference a custom currency. Useful before archiving to inspect dependencies.

Parameters:

  • currency_id (String)

    The reference ID of the custom currency

  • 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:



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 189

def list_associated_entities(currency_id, params = {})
  parsed, options = Stigg::V1::Credits::CustomCurrencyListAssociatedEntitiesParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["api/v1/credits/custom-currencies/%1$s/associated-entities", currency_id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::Models::V1::Credits::CustomCurrencyListAssociatedEntitiesResponse,
    options: options
  )
end

#unarchive(currency_id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CustomCurrencyResponse

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

Restores a previously archived custom currency. Fails if another active currency with the same ID already exists.

Parameters:

  • currency_id (String)

    The reference ID of the custom currency

  • 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:



222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 222

def unarchive(currency_id, params = {})
  parsed, options = Stigg::V1::Credits::CustomCurrencyUnarchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1/credits/custom-currencies/%1$s/unarchive", currency_id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Credits::CustomCurrencyResponse,
    options: options
  )
end

#update(currency_id, description: nil, display_name: nil, metadata: nil, symbol: nil, units: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CustomCurrencyResponse

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

Updates an existing custom currency. Only the supplied fields are modified.

Parameters:

  • currency_id (String)

    Path param: The reference ID of the custom currency

  • description (String, nil)

    Body param: A human-readable description of the custom currency. Send an empty s

  • display_name (String)

    Body param: The display name of the custom currency

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

    Body param: Additional metadata to attach to the custom currency

  • symbol (String, nil)

    Body param: The symbol used to represent the custom currency. Send an empty stri

  • units (Stigg::Models::V1::Credits::CustomCurrencyUpdateParams::Units)

    Body param: Singular and plural unit labels for a custom currency. Both fields a

  • 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:



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 78

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