Class: Stigg::Resources::V1::Contracts
- Inherits:
-
Object
- Object
- Stigg::Resources::V1::Contracts
- Defined in:
- lib/stigg/resources/v1/contracts.rb,
sig/stigg/resources/v1/contracts.rbs
Instance Method Summary collapse
-
#create(customer_id:, subscriptions:, activation_end_date: nil, activation_start_date: nil, name: nil, po_number: nil, setup_billing: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractCreateResponse
Some parameter documentations has been truncated, see Models::V1::ContractCreateParams for more details.
-
#delete(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractDeleteResponse
Some parameter documentations has been truncated, see Models::V1::ContractDeleteParams for more details.
-
#initialize(client:) ⇒ Contracts
constructor
private
A new instance of Contracts.
-
#list(after: nil, before: nil, customer_external_id: nil, limit: nil, name: nil, state: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::ContractListResponse>
Some parameter documentations has been truncated, see Models::V1::ContractListParams for more details.
-
#retrieve(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractRetrieveResponse
Some parameter documentations has been truncated, see Models::V1::ContractRetrieveParams for more details.
-
#update(id, activation_end_date: nil, activation_start_date: nil, name: nil, po_number: nil, setup_billing: nil, subscription_ids: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractUpdateResponse
Some parameter documentations has been truncated, see Models::V1::ContractUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Contracts
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 Contracts.
219 220 221 |
# File 'lib/stigg/resources/v1/contracts.rb', line 219 def initialize(client:) @client = client end |
Instance Method Details
#create(customer_id:, subscriptions:, activation_end_date: nil, activation_start_date: nil, name: nil, po_number: nil, setup_billing: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractCreateResponse
Some parameter documentations has been truncated, see Models::V1::ContractCreateParams for more details.
Creates a contract for a customer together with all of its (custom) subscriptions in a single atomic operation. Every new subscription is created inside one transaction — any validation or creation failure rolls the whole contract back. Each subscription entry is either a new subscription to create or a reference to an existing custom subscription. Returns the created contract.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/stigg/resources/v1/contracts.rb', line 41 def create(params) parsed, = Stigg::V1::ContractCreateParams.dump_request(params) header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"} @client.request( method: :post, path: "api/v1/contracts", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Stigg::Models::V1::ContractCreateResponse, options: ) end |
#delete(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractDeleteResponse
Some parameter documentations has been truncated, see Models::V1::ContractDeleteParams for more details.
Deletes a contract: cancels the contract in the connected billing provider and cancels every subscription linked to it.
202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/stigg/resources/v1/contracts.rb', line 202 def delete(id, params = {}) parsed, = Stigg::V1::ContractDeleteParams.dump_request(params) @client.request( method: :post, path: ["api/v1/contracts/%1$s/archive", id], headers: parsed.transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::Models::V1::ContractDeleteResponse, options: ) end |
#list(after: nil, before: nil, customer_external_id: nil, limit: nil, name: nil, state: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::ContractListResponse>
Some parameter documentations has been truncated, see Models::V1::ContractListParams for more details.
Retrieves a cursor-paginated list of contracts in the environment, fetched live from the connected billing provider. Each contract is enriched with a preview of its upcoming (next) invoice when one is available. Returns an empty list when no billing provider is connected. Supports filtering by customer external ID, state, and name.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/stigg/resources/v1/contracts.rb', line 165 def list(params = {}) query_params = [:after, :before, :customer_external_id, :limit, :name, :state] parsed, = Stigg::V1::ContractListParams.dump_request(params) query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :get, path: "api/v1/contracts", query: query.transform_keys(customer_external_id: "customerExternalId"), 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::ContractListResponse, options: ) end |
#retrieve(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractRetrieveResponse
Some parameter documentations has been truncated, see Models::V1::ContractRetrieveParams for more details.
Retrieves a single contract by its ID, enriched with a preview of its upcoming (next) invoice when one is available. Returns 404 when no contract with that ID exists in the environment.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/stigg/resources/v1/contracts.rb', line 74 def retrieve(id, params = {}) parsed, = Stigg::V1::ContractRetrieveParams.dump_request(params) @client.request( method: :get, path: ["api/v1/contracts/%1$s", id], headers: parsed.transform_keys( x_account_id: "x-account-id", x_environment_id: "x-environment-id" ), model: Stigg::Models::V1::ContractRetrieveResponse, options: ) end |
#update(id, activation_end_date: nil, activation_start_date: nil, name: nil, po_number: nil, setup_billing: nil, subscription_ids: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::ContractUpdateResponse
Some parameter documentations has been truncated, see Models::V1::ContractUpdateParams for more details.
Updates a contract's metadata (name, PO number, activation dates) and optionally re-links its subscriptions. Best-effort re-syncs the change to the connected billing provider.
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/stigg/resources/v1/contracts.rb', line 120 def update(id, params = {}) parsed, = Stigg::V1::ContractUpdateParams.dump_request(params) header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"} @client.request( method: :patch, path: ["api/v1/contracts/%1$s", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Stigg::Models::V1::ContractUpdateResponse, options: ) end |