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

Inherits:
Object
  • Object
show all
Defined in:
lib/stigg/resources/v1/events/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:



184
185
186
# File 'lib/stigg/resources/v1/events/credits/custom_currencies.rb', line 184

def initialize(client:)
  @client = client
end

Instance Method Details

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

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:



130
131
132
133
134
135
136
137
# File 'lib/stigg/resources/v1/events/credits/custom_currencies.rb', line 130

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

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

Some parameter documentations has been truncated, see Models::V1::Events::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::Events::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:



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

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

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

Some parameter documentations has been truncated, see Models::V1::Events::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:

Returns:

See Also:



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

def list(params = {})
  parsed, options = Stigg::V1::Events::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::Events::Credits::CustomCurrencyListResponse,
    options: options
  )
end

#list_associated_entities(currency_id, request_options: {}) ⇒ Stigg::Models::V1::Events::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:



151
152
153
154
155
156
157
158
# File 'lib/stigg/resources/v1/events/credits/custom_currencies.rb', line 151

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::Events::Credits::CustomCurrencyListAssociatedEntitiesResponse,
    options: params[:request_options]
  )
end

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

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:



172
173
174
175
176
177
178
179
# File 'lib/stigg/resources/v1/events/credits/custom_currencies.rb', line 172

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

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

Some parameter documentations has been truncated, see Models::V1::Events::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::Events::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:



71
72
73
74
75
76
77
78
79
80
# File 'lib/stigg/resources/v1/events/credits/custom_currencies.rb', line 71

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