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:



181
182
183
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 181

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

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

Returns:

See Also:



127
128
129
130
131
132
133
134
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 127

def archive(currency_id, params = {})
  @client.request(
    method: :post,
    path: ["api/v1/credits/custom-currencies/%1$s/archive", currency_id],
    model: Stigg::V1::Credits::CustomCurrencyResponse,
    options: params[:request_options]
  )
end

#create(id:, display_name:, description: nil, metadata: nil, symbol: nil, units: 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)

    The unique identifier for the new custom currency

  • display_name (String)

    The display name of the custom currency

  • description (String)

    Description of the currency

  • metadata (Hash{Symbol=>String})

    Additional metadata to attach to the custom currency

  • symbol (String)

    The symbol used to represent the custom currency

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

    Singular and plural unit labels for a custom currency. Both fields are required

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

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 33

def create(params)
  parsed, options = Stigg::V1::Credits::CustomCurrencyCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v1/credits/custom-currencies",
    body: parsed,
    model: Stigg::V1::Credits::CustomCurrencyResponse,
    options: options
  )
end

#list(after: nil, before: nil, limit: nil, status: 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)

    Return items that come after this cursor

  • before (String)

    Return items that come before this cursor

  • limit (Integer)

    Maximum number of items to return

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

    Filter by custom currency status. Supports comma-separated values (e.g., ‘ACTIVE

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

Returns:

See Also:



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 101

def list(params = {})
  parsed, options = Stigg::V1::Credits::CustomCurrencyListParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v1/credits/custom-currencies",
    query: query,
    page: Stigg::Internal::MyCursorIDPage,
    model: Stigg::Models::V1::Credits::CustomCurrencyListResponse,
    options: options
  )
end

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

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

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

Returns:

See Also:



148
149
150
151
152
153
154
155
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 148

def list_associated_entities(currency_id, params = {})
  @client.request(
    method: :get,
    path: ["api/v1/credits/custom-currencies/%1$s/associated-entities", currency_id],
    model: Stigg::Models::V1::Credits::CustomCurrencyListAssociatedEntitiesResponse,
    options: params[:request_options]
  )
end

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

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

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

Returns:

See Also:



169
170
171
172
173
174
175
176
# File 'lib/stigg/resources/v1/credits/custom_currencies.rb', line 169

def unarchive(currency_id, params = {})
  @client.request(
    method: :post,
    path: ["api/v1/credits/custom-currencies/%1$s/unarchive", currency_id],
    model: Stigg::V1::Credits::CustomCurrencyResponse,
    options: params[:request_options]
  )
end

#update(currency_id, description: nil, display_name: nil, metadata: nil, symbol: nil, units: 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)

    The reference ID of the custom currency

  • description (String, nil)

    A human-readable description of the custom currency. Send an empty string to cle

  • display_name (String)

    The display name of the custom currency

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

    Additional metadata to attach to the custom currency

  • symbol (String, nil)

    The symbol used to represent the custom currency. Send an empty string to clear.

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

    Singular and plural unit labels for a custom currency. Both fields are required

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

Returns:

See Also:



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

def update(currency_id, params = {})
  parsed, options = Stigg::V1::Credits::CustomCurrencyUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/v1/credits/custom-currencies/%1$s", currency_id],
    body: parsed,
    model: Stigg::V1::Credits::CustomCurrencyResponse,
    options: options
  )
end