Class: Stigg::Resources::V1::Credits::Grants
- Inherits:
-
Object
- Object
- Stigg::Resources::V1::Credits::Grants
- Defined in:
- lib/stigg/resources/v1/credits/grants.rb
Overview
Operations related to credit grants
Instance Method Summary collapse
-
#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, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CreditGrantResponse
Some parameter documentations has been truncated, see Models::V1::Credits::GrantCreateParams for more details.
-
#initialize(client:) ⇒ Grants
constructor
private
A new instance of Grants.
-
#list(customer_id:, after: nil, before: nil, created_at: 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::Credits::GrantListResponse>
Some parameter documentations has been truncated, see Models::V1::Credits::GrantListParams for more details.
-
#void(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CreditGrantResponse
Some parameter documentations has been truncated, see Models::V1::Credits::GrantVoidParams for more details.
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.
158 159 160 |
# File 'lib/stigg/resources/v1/credits/grants.rb', line 158 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, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CreditGrantResponse
Some parameter documentations has been truncated, see Models::V1::Credits::GrantCreateParams for more details.
Creates a new credit grant for a customer with specified amount, type, and optional billing configuration.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/stigg/resources/v1/credits/grants.rb', line 56 def create(params) parsed, = Stigg::V1::Credits::GrantCreateParams.dump_request(params) header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"} @client.request( method: :post, path: "api/v1/credits/grants", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Stigg::V1::Credits::CreditGrantResponse, options: ) end |
#list(customer_id:, after: nil, before: nil, created_at: 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::Credits::GrantListResponse>
Some parameter documentations has been truncated, see Models::V1::Credits::GrantListParams for more details.
Retrieves a paginated list of credit grants for a customer.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/stigg/resources/v1/credits/grants.rb', line 99 def list(params) query_params = [:customer_id, :after, :before, :created_at, :currency_id, :limit, :resource_id] parsed, = Stigg::V1::Credits::GrantListParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params)) @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" ), 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::Credits::GrantListResponse, options: ) end |
#void(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Credits::CreditGrantResponse
Some parameter documentations has been truncated, see Models::V1::Credits::GrantVoidParams for more details.
Voids an existing credit grant, preventing further consumption of the remaining credits.
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/stigg/resources/v1/credits/grants.rb', line 141 def void(id, params = {}) parsed, = Stigg::V1::Credits::GrantVoidParams.dump_request(params) @client.request( method: :post, path: ["api/v1/credits/grants/%1$s/void", id], headers: parsed.transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::V1::Credits::CreditGrantResponse, options: ) end |