Class: Stigg::Resources::V1::Customers
- Inherits:
-
Object
- Object
- Stigg::Resources::V1::Customers
- Defined in:
- lib/stigg/resources/v1/customers.rb,
lib/stigg/resources/v1/customers/integrations.rb,
lib/stigg/resources/v1/customers/payment_method.rb,
lib/stigg/resources/v1/customers/promotional_entitlements.rb
Defined Under Namespace
Classes: Integrations, PaymentMethod, PromotionalEntitlements
Instance Attribute Summary collapse
- #integrations ⇒ Stigg::Resources::V1::Customers::Integrations readonly
-
#payment_method ⇒ Stigg::Resources::V1::Customers::PaymentMethod
readonly
Operations related to customers.
-
#promotional_entitlements ⇒ Stigg::Resources::V1::Customers::PromotionalEntitlements
readonly
Operations related to promotional entitlements.
Instance Method Summary collapse
-
#archive(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerArchiveParams for more details.
-
#check_entitlement(id, currency_id: nil, feature_id: nil, requested_usage: nil, requested_values: nil, resource_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerCheckEntitlementResponse
Some parameter documentations has been truncated, see Models::V1::CustomerCheckEntitlementParams for more details.
-
#import(customers:, integration_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerImportResponse
Some parameter documentations has been truncated, see Models::V1::CustomerImportParams for more details.
-
#initialize(client:) ⇒ Customers
constructor
private
A new instance of Customers.
-
#list(after: nil, before: nil, created_at: nil, email: nil, limit: nil, name: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResponse>
Some parameter documentations has been truncated, see Models::V1::CustomerListParams for more details.
-
#list_resources(id, after: nil, before: nil, limit: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResourcesResponse>
Some parameter documentations has been truncated, see Models::V1::CustomerListResourcesParams for more details.
-
#provision(id:, billing_currency: nil, billing_id: nil, coupon_id: nil, default_payment_method: nil, email: nil, integrations: nil, language: nil, metadata: nil, name: nil, passthrough: nil, timezone: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerProvisionParams for more details.
-
#retrieve(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerRetrieveParams for more details.
-
#retrieve_entitlements(id, resource_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerRetrieveEntitlementsResponse
Some parameter documentations has been truncated, see Models::V1::CustomerRetrieveEntitlementsParams for more details.
-
#unarchive(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerUnarchiveParams for more details.
-
#update(id, billing_currency: nil, billing_id: nil, coupon_id: nil, email: nil, integrations: nil, language: nil, metadata: nil, name: nil, passthrough: nil, timezone: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Customers
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 Customers.
448 449 450 451 452 453 |
# File 'lib/stigg/resources/v1/customers.rb', line 448 def initialize(client:) @client = client @payment_method = Stigg::Resources::V1::Customers::PaymentMethod.new(client: client) @promotional_entitlements = Stigg::Resources::V1::Customers::PromotionalEntitlements.new(client: client) @integrations = Stigg::Resources::V1::Customers::Integrations.new(client: client) end |
Instance Attribute Details
#integrations ⇒ Stigg::Resources::V1::Customers::Integrations (readonly)
16 17 18 |
# File 'lib/stigg/resources/v1/customers.rb', line 16 def integrations @integrations end |
#payment_method ⇒ Stigg::Resources::V1::Customers::PaymentMethod (readonly)
Operations related to customers
9 10 11 |
# File 'lib/stigg/resources/v1/customers.rb', line 9 def payment_method @payment_method end |
#promotional_entitlements ⇒ Stigg::Resources::V1::Customers::PromotionalEntitlements (readonly)
Operations related to promotional entitlements
13 14 15 |
# File 'lib/stigg/resources/v1/customers.rb', line 13 def promotional_entitlements @promotional_entitlements end |
Instance Method Details
#archive(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerArchiveParams for more details.
Archives a customer, preventing new subscriptions. Optionally cancels existing subscriptions.
168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/stigg/resources/v1/customers.rb', line 168 def archive(id, params = {}) parsed, = Stigg::V1::CustomerArchiveParams.dump_request(params) @client.request( method: :post, path: ["api/v1/customers/%1$s/archive", id], headers: parsed.transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::V1::CustomerResponse, options: ) end |
#check_entitlement(id, currency_id: nil, feature_id: nil, requested_usage: nil, requested_values: nil, resource_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerCheckEntitlementResponse
Some parameter documentations has been truncated, see Models::V1::CustomerCheckEntitlementParams for more details.
Checks a single entitlement (feature or credit) for a customer or resource. Supports ‘requestedUsage` and `requestedValues` to evaluate against limits or enum values.
Warning: This REST API endpoint lacks built-in client-side caching, fallback mechanisms, and low-latency guarantees. It is not recommended for hot-path entitlement checks. For production use, consider using the Stigg Node Server SDK with caching or the Sidecar for low-latency cached responses.
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/stigg/resources/v1/customers.rb', line 217 def check_entitlement(id, params = {}) query_params = [:currency_id, :feature_id, :requested_usage, :requested_values, :resource_id] parsed, = Stigg::V1::CustomerCheckEntitlementParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: ["api/v1/customers/%1$s/entitlements/check", id], query: query.transform_keys( currency_id: "currencyId", feature_id: "featureId", requested_usage: "requestedUsage", requested_values: "requestedValues", resource_id: "resourceId" ), headers: parsed.except(*query_params).transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::Models::V1::CustomerCheckEntitlementResponse, options: ) end |
#import(customers:, integration_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerImportResponse
Some parameter documentations has been truncated, see Models::V1::CustomerImportParams for more details.
Imports multiple customers in bulk. Used for migrating customer data from external systems.
261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/stigg/resources/v1/customers.rb', line 261 def import(params) parsed, = Stigg::V1::CustomerImportParams.dump_request(params) header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"} @client.request( method: :post, path: "api/v1/customers/import", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Stigg::Models::V1::CustomerImportResponse, options: ) end |
#list(after: nil, before: nil, created_at: nil, email: nil, limit: nil, name: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResponse>
Some parameter documentations has been truncated, see Models::V1::CustomerListParams for more details.
Retrieves a paginated list of customers in the environment.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/stigg/resources/v1/customers.rb', line 131 def list(params = {}) query_params = [:after, :before, :created_at, :email, :limit, :name] parsed, = Stigg::V1::CustomerListParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: "api/v1/customers", query: query.transform_keys(created_at: "createdAt"), 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::CustomerListResponse, options: ) end |
#list_resources(id, after: nil, before: nil, limit: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResourcesResponse>
Some parameter documentations has been truncated, see Models::V1::CustomerListResourcesParams for more details.
Retrieves a paginated list of resources within the same customer.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/stigg/resources/v1/customers.rb', line 298 def list_resources(id, params = {}) query_params = [:after, :before, :limit] parsed, = Stigg::V1::CustomerListResourcesParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: ["api/v1/customers/%1$s/resources", id], query: query, 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::CustomerListResourcesResponse, options: ) end |
#provision(id:, billing_currency: nil, billing_id: nil, coupon_id: nil, default_payment_method: nil, email: nil, integrations: nil, language: nil, metadata: nil, name: nil, passthrough: nil, timezone: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerProvisionParams for more details.
Creates a new customer and optionally provisions an initial subscription in a single operation.
357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/stigg/resources/v1/customers.rb', line 357 def provision(params) parsed, = Stigg::V1::CustomerProvisionParams.dump_request(params) header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"} @client.request( method: :post, path: "api/v1/customers", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Stigg::V1::CustomerResponse, options: ) end |
#retrieve(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerRetrieveParams for more details.
Retrieves a customer by their unique identifier, including billing information and subscription status.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/stigg/resources/v1/customers.rb', line 37 def retrieve(id, params = {}) parsed, = Stigg::V1::CustomerRetrieveParams.dump_request(params) @client.request( method: :get, path: ["api/v1/customers/%1$s", id], headers: parsed.transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::V1::CustomerResponse, options: ) end |
#retrieve_entitlements(id, resource_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerRetrieveEntitlementsResponse
Some parameter documentations has been truncated, see Models::V1::CustomerRetrieveEntitlementsParams for more details.
Retrieves the effective entitlements for a customer or resource, including feature and credit entitlements.
Warning: This REST API endpoint lacks built-in client-side caching, fallback mechanisms, and low-latency guarantees. It is not recommended for hot-path entitlement checks. For production use, consider using the Stigg Node Server SDK with caching or the Sidecar for low-latency cached responses.
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/stigg/resources/v1/customers.rb', line 396 def retrieve_entitlements(id, params = {}) query_params = [:resource_id] parsed, = Stigg::V1::CustomerRetrieveEntitlementsParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: ["api/v1/customers/%1$s/entitlements", id], query: query.transform_keys(resource_id: "resourceId"), headers: parsed.except(*query_params).transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::Models::V1::CustomerRetrieveEntitlementsResponse, options: ) end |
#unarchive(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerUnarchiveParams for more details.
Restores an archived customer, allowing them to create new subscriptions again.
431 432 433 434 435 436 437 438 439 440 441 442 443 |
# File 'lib/stigg/resources/v1/customers.rb', line 431 def unarchive(id, params = {}) parsed, = Stigg::V1::CustomerUnarchiveParams.dump_request(params) @client.request( method: :post, path: ["api/v1/customers/%1$s/unarchive", id], headers: parsed.transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::V1::CustomerResponse, options: ) end |
#update(id, billing_currency: nil, billing_id: nil, coupon_id: nil, email: nil, integrations: nil, language: nil, metadata: nil, name: nil, passthrough: nil, timezone: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Some parameter documentations has been truncated, see Models::V1::CustomerUpdateParams for more details.
Updates an existing customer’s properties such as name, email, and billing information.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/stigg/resources/v1/customers.rb', line 90 def update(id, params = {}) parsed, = Stigg::V1::CustomerUpdateParams.dump_request(params) header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"} @client.request( method: :patch, path: ["api/v1/customers/%1$s", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Stigg::V1::CustomerResponse, options: ) end |