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, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Archives a customer, preventing new subscriptions.
-
#check_entitlement(id, currency_id: nil, feature_id: nil, requested_usage: nil, requested_values: nil, resource_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, request_options: {}) ⇒ Stigg::Models::V1::CustomerImportResponse
Imports multiple customers in bulk.
-
#initialize(client:) ⇒ Customers
constructor
private
A new instance of Customers.
-
#list(after: nil, before: nil, created_at: nil, email: nil, limit: nil, name: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResponse>
Retrieves a paginated list of customers in the environment.
-
#list_resources(id, after: nil, before: nil, limit: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResourcesResponse>
Retrieves a paginated list of resources within the same customer.
-
#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, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Creates a new customer and optionally provisions an initial subscription in a single operation.
-
#retrieve(id, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Retrieves a customer by their unique identifier, including billing information and subscription status.
-
#retrieve_entitlements(id, resource_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerRetrieveEntitlementsResponse
Retrieves the effective entitlements for a customer or resource, including feature and credit entitlements.
-
#unarchive(id, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Restores an archived customer, allowing them to create new subscriptions again.
-
#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, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Updates an existing customer’s properties such as name, email, and billing information.
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.
340 341 342 343 344 345 |
# File 'lib/stigg/resources/v1/customers.rb', line 340 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, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Archives a customer, preventing new subscriptions. Optionally cancels existing subscriptions.
128 129 130 131 132 133 134 135 |
# File 'lib/stigg/resources/v1/customers.rb', line 128 def archive(id, params = {}) @client.request( method: :post, path: ["api/v1/customers/%1$s/archive", id], model: Stigg::V1::CustomerResponse, options: params[:request_options] ) end |
#check_entitlement(id, currency_id: nil, feature_id: nil, requested_usage: nil, requested_values: nil, resource_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.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/stigg/resources/v1/customers.rb', line 168 def check_entitlement(id, params = {}) parsed, = Stigg::V1::CustomerCheckEntitlementParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed) @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" ), model: Stigg::Models::V1::CustomerCheckEntitlementResponse, options: ) end |
#import(customers:, integration_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerImportResponse
Imports multiple customers in bulk. Used for migrating customer data from external systems.
200 201 202 203 204 205 206 207 208 209 |
# File 'lib/stigg/resources/v1/customers.rb', line 200 def import(params) parsed, = Stigg::V1::CustomerImportParams.dump_request(params) @client.request( method: :post, path: "api/v1/customers/import", body: parsed, model: Stigg::Models::V1::CustomerImportResponse, options: ) end |
#list(after: nil, before: nil, created_at: nil, email: nil, limit: nil, name: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResponse>
Retrieves a paginated list of customers in the environment.
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/stigg/resources/v1/customers.rb', line 103 def list(params = {}) parsed, = Stigg::V1::CustomerListParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "api/v1/customers", query: query.transform_keys(created_at: "createdAt"), page: Stigg::Internal::MyCursorIDPage, model: Stigg::Models::V1::CustomerListResponse, options: ) end |
#list_resources(id, after: nil, before: nil, limit: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::CustomerListResourcesResponse>
Retrieves a paginated list of resources within the same customer.
228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/stigg/resources/v1/customers.rb', line 228 def list_resources(id, params = {}) parsed, = Stigg::V1::CustomerListResourcesParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["api/v1/customers/%1$s/resources", id], query: query, 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, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Creates a new customer and optionally provisions an initial subscription in a single operation.
275 276 277 278 279 280 281 282 283 284 |
# File 'lib/stigg/resources/v1/customers.rb', line 275 def provision(params) parsed, = Stigg::V1::CustomerProvisionParams.dump_request(params) @client.request( method: :post, path: "api/v1/customers", body: parsed, model: Stigg::V1::CustomerResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Retrieves a customer by their unique identifier, including billing information and subscription status.
30 31 32 33 34 35 36 37 |
# File 'lib/stigg/resources/v1/customers.rb', line 30 def retrieve(id, params = {}) @client.request( method: :get, path: ["api/v1/customers/%1$s", id], model: Stigg::V1::CustomerResponse, options: params[:request_options] ) end |
#retrieve_entitlements(id, resource_id: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerRetrieveEntitlementsResponse
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.
305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/stigg/resources/v1/customers.rb', line 305 def retrieve_entitlements(id, params = {}) parsed, = Stigg::V1::CustomerRetrieveEntitlementsParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["api/v1/customers/%1$s/entitlements", id], query: query.transform_keys(resource_id: "resourceId"), model: Stigg::Models::V1::CustomerRetrieveEntitlementsResponse, options: ) end |
#unarchive(id, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Restores an archived customer, allowing them to create new subscriptions again.
328 329 330 331 332 333 334 335 |
# File 'lib/stigg/resources/v1/customers.rb', line 328 def unarchive(id, params = {}) @client.request( method: :post, path: ["api/v1/customers/%1$s/unarchive", id], model: Stigg::V1::CustomerResponse, options: params[:request_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, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse
Updates an existing customer’s properties such as name, email, and billing information.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/stigg/resources/v1/customers.rb', line 71 def update(id, params = {}) parsed, = Stigg::V1::CustomerUpdateParams.dump_request(params) @client.request( method: :patch, path: ["api/v1/customers/%1$s", id], body: parsed, model: Stigg::V1::CustomerResponse, options: ) end |