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

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

Defined Under Namespace

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



117
118
119
120
# File 'lib/stigg/resources/v1/events/credits.rb', line 117

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

Instance Attribute Details

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

Operations related to credit grants



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

def grants
  @grants
end

Instance Method Details

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

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

Parameters:

  • currency_id (String)

    Filter by currency ID (required)

  • customer_id (String)

    Filter by customer ID (required)

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

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/stigg/resources/v1/events/credits.rb', line 26

def get_auto_recharge(params)
  parsed, options = Stigg::V1::Events::CreditGetAutoRechargeParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v1/credits/auto-recharge",
    query: query.transform_keys(currency_id: "currencyId", customer_id: "customerId"),
    model: Stigg::Models::V1::Events::CreditGetAutoRechargeResponse,
    options: options
  )
end

#get_usage(customer_id:, currency_id: nil, resource_id: nil, time_range: nil, request_options: {}) ⇒ Stigg::Models::V1::Events::CreditGetUsageResponse

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

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

Parameters:

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/stigg/resources/v1/events/credits.rb', line 59

def get_usage(params)
  parsed, options = Stigg::V1::Events::CreditGetUsageParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v1/credits/usage",
    query: query.transform_keys(
      customer_id: "customerId",
      currency_id: "currencyId",
      resource_id: "resourceId",
      time_range: "timeRange"
    ),
    model: Stigg::Models::V1::Events::CreditGetUsageResponse,
    options: options
  )
end

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

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

Parameters:

  • customer_id (String)

    Filter by customer ID (required)

  • after (String)

    Return items that come after this cursor

  • before (String)

    Return items that come before this cursor

  • currency_id (String)

    Filter by currency ID

  • limit (Integer)

    Maximum number of items to return

  • resource_id (String)

    Filter by resource ID

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

Returns:

See Also:



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

def list_ledger(params)
  parsed, options = Stigg::V1::Events::CreditListLedgerParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v1/credits/ledger",
    query: query.transform_keys(
      customer_id: "customerId",
      currency_id: "currencyId",
      resource_id: "resourceId"
    ),
    page: Stigg::Internal::MyCursorIDPage,
    model: Stigg::Models::V1::Events::CreditListLedgerResponse,
    options: options
  )
end