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

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

Defined Under Namespace

Classes: CustomCurrencies, Grants

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Credits

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

Parameters:



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

def initialize(client:)
  @client = client
  @grants = Stigg::Resources::V1::Credits::Grants.new(client: client)
  @custom_currencies = Stigg::Resources::V1::Credits::CustomCurrencies.new(client: client)
end

Instance Attribute Details

#custom_currenciesStigg::Resources::V1::Credits::CustomCurrencies (readonly)

Operations related to custom currencies



13
14
15
# File 'lib/stigg/resources/v1/credits.rb', line 13

def custom_currencies
  @custom_currencies
end

#grantsStigg::Resources::V1::Credits::Grants (readonly)

Operations related to credit grants



9
10
11
# File 'lib/stigg/resources/v1/credits.rb', line 9

def grants
  @grants
end

Instance Method Details

#get_auto_recharge(currency_id:, customer_id:, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CreditGetAutoRechargeResponse

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

Retrieves the automatic recharge configuration for a customer and currency. Returns default settings if no configuration exists.

Parameters:

  • currency_id (String)

    Query param: Filter by currency ID (required)

  • customer_id (String)

    Query param: Filter by customer ID (required)

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



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

def get_auto_recharge(params)
  query_params = [:currency_id, :customer_id]
  parsed, options = Stigg::V1::CreditGetAutoRechargeParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "api/v1/credits/auto-recharge",
    query: query.transform_keys(currency_id: "currencyId", customer_id: "customerId"),
    headers: parsed.except(*query_params).transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::Models::V1::CreditGetAutoRechargeResponse,
    options: options
  )
end

#get_usage(customer_id:, after: nil, before: nil, currency_id: nil, end_date: nil, group_by: nil, limit: nil, resource_id: nil, start_date: nil, time_range: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CreditGetUsageResponse

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

Retrieves credit usage time-series data for a customer, grouped by feature, over a specified time range.

Parameters:

  • customer_id (String)

    Query param: Filter by customer ID (required)

  • after (String)

    Query param: Return items that come after this cursor

  • before (String)

    Query param: Return items that come before this cursor

  • currency_id (String)

    Query param: Filter by currency ID

  • end_date (Time)

    Query param: End date for the credit usage time range (ISO 8601). Defaults to no

  • group_by (String)

    Query param: Comma-separated list of feature dimension keys to group usage serie

  • limit (Integer)

    Query param: Maximum number of items to return

  • resource_id (String)

    Query param: Filter by resource ID

  • start_date (Time)

    Query param: Start date for the credit usage time range (ISO 8601). Takes preced

  • time_range (Symbol, Stigg::Models::V1::CreditGetUsageParams::TimeRange)

    Query param: Time range for usage data (LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YE

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



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/stigg/resources/v1/credits.rb', line 90

def get_usage(params)
  query_params =
    [
      :customer_id,
      :after,
      :before,
      :currency_id,
      :end_date,
      :group_by,
      :limit,
      :resource_id,
      :start_date,
      :time_range
    ]
  parsed, options = Stigg::V1::CreditGetUsageParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "api/v1/credits/usage",
    query: query.transform_keys(
      customer_id: "customerId",
      currency_id: "currencyId",
      end_date: "endDate",
      group_by: "groupBy",
      resource_id: "resourceId",
      start_date: "startDate",
      time_range: "timeRange"
    ),
    headers: parsed.except(*query_params).transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::Models::V1::CreditGetUsageResponse,
    options: options
  )
end

#list_ledger(customer_id:, after: nil, before: nil, currency_id: nil, limit: nil, resource_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CreditListLedgerResponse>

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

Retrieves a paginated list of credit ledger events for a customer.

Parameters:

  • customer_id (String)

    Query param: Filter by customer ID (required)

  • after (String)

    Query param: Return items that come after this cursor

  • before (String)

    Query param: Return items that come before this cursor

  • currency_id (String)

    Query param: Filter by currency ID

  • limit (Integer)

    Query param: Maximum number of items to return

  • resource_id (String)

    Query param: Filter by resource ID

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



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/stigg/resources/v1/credits.rb', line 155

def list_ledger(params)
  query_params = [:customer_id, :after, :before, :currency_id, :limit, :resource_id]
  parsed, options = Stigg::V1::CreditListLedgerParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "api/v1/credits/ledger",
    query: query.transform_keys(
      customer_id: "customerId",
      currency_id: "currencyId",
      resource_id: "resourceId"
    ),
    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::CreditListLedgerResponse,
    options: options
  )
end