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

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

Overview

Operations related to credit grants

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Grants

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

Parameters:



129
130
131
# File 'lib/stigg/resources/v1/events/credits/grants.rb', line 129

def initialize(client:)
  @client = client
end

Instance Method Details

#create(amount:, currency_id:, customer_id:, display_name:, grant_type:, await_payment_confirmation: nil, billing_information: nil, comment: nil, cost: nil, effective_at: nil, expire_at: nil, metadata: nil, payment_collection_method: nil, priority: nil, resource_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Events::Credits::CreditGrantResponse

Creates a new credit grant for a customer with specified amount, type, and optional billing configuration.

Parameters:

Returns:

See Also:



50
51
52
53
54
55
56
57
58
59
# File 'lib/stigg/resources/v1/events/credits/grants.rb', line 50

def create(params)
  parsed, options = Stigg::V1::Events::Credits::GrantCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v1/credits/grants",
    body: parsed,
    model: Stigg::V1::Events::Credits::CreditGrantResponse,
    options: options
  )
end

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

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

Retrieves a paginated list of credit grants 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

  • created_at (Stigg::Models::V1::Events::Credits::GrantListParams::CreatedAt)

    Filter by creation date using range operators: gt, gte, lt, lte

  • currency_id (String)

    Filter by currency ID

  • limit (Integer)

    Maximum number of items to return

  • resource_id (String)

    Filter by resource ID. When omitted, only grants without a resource are returned

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

Returns:

See Also:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/stigg/resources/v1/events/credits/grants.rb', line 87

def list(params)
  parsed, options = Stigg::V1::Events::Credits::GrantListParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v1/credits/grants",
    query: query.transform_keys(
      customer_id: "customerId",
      created_at: "createdAt",
      currency_id: "currencyId",
      resource_id: "resourceId"
    ),
    page: Stigg::Internal::MyCursorIDPage,
    model: Stigg::Models::V1::Events::Credits::GrantListResponse,
    options: options
  )
end

#void(id, request_options: {}) ⇒ Stigg::Models::V1::Events::Credits::CreditGrantResponse

Voids an existing credit grant, preventing further consumption of the remaining credits.

Parameters:

  • id (String)

    The unique identifier of the entity

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

Returns:

See Also:



117
118
119
120
121
122
123
124
# File 'lib/stigg/resources/v1/events/credits/grants.rb', line 117

def void(id, params = {})
  @client.request(
    method: :post,
    path: ["api/v1/credits/grants/%1$s/void", id],
    model: Stigg::V1::Events::Credits::CreditGrantResponse,
    options: params[:request_options]
  )
end