Class: Stigg::Resources::V1::Plans

Inherits:
Object
  • Object
show all
Defined in:
lib/stigg/resources/v1/plans.rb,
lib/stigg/resources/v1/plans/entitlements.rb

Overview

Operations related to plans

Defined Under Namespace

Classes: Entitlements

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Plans

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

Parameters:



403
404
405
406
# File 'lib/stigg/resources/v1/plans.rb', line 403

def initialize(client:)
  @client = client
  @entitlements = Stigg::Resources::V1::Plans::Entitlements.new(client: client)
end

Instance Attribute Details

#entitlementsStigg::Resources::V1::Plans::Entitlements (readonly)



9
10
11
# File 'lib/stigg/resources/v1/plans.rb', line 9

def entitlements
  @entitlements
end

Instance Method Details

#archive(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Plan

Some parameter documentations has been truncated, see Models::V1::PlanArchiveParams for more details.

Archives a plan, preventing it from being used in new subscriptions.

Parameters:

  • id (String)

    The unique identifier of the entity

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

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

Returns:

See Also:



205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/stigg/resources/v1/plans.rb', line 205

def archive(id, params = {})
  parsed, options = Stigg::V1::PlanArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1/plans/%1$s/archive", id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Plan,
    options: options
  )
end

#create(id:, display_name:, product_id:, billing_id: nil, default_trial_config: nil, description: nil, metadata: nil, parent_plan_id: nil, pricing_type: nil, status: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Plan

Some parameter documentations has been truncated, see Models::V1::PlanCreateParams for more details.

Creates a new plan in draft status.

Parameters:

  • id (String)

    Body param: The unique identifier for the entity

  • display_name (String)

    Body param: The display name of the package

  • product_id (String)

    Body param: The product ID to associate the plan with

  • billing_id (String, nil)

    Body param: The unique identifier for the entity in the billing provider

  • default_trial_config (Stigg::Models::V1::PlanCreateParams::DefaultTrialConfig, nil)

    Body param: Default trial configuration for the plan

  • description (String, nil)

    Body param: The description of the package

  • metadata (Hash{Symbol=>String})

    Body param: Metadata associated with the entity

  • parent_plan_id (String, nil)

    Body param: The ID of the parent plan, if applicable

  • pricing_type (Symbol, Stigg::Models::V1::PlanCreateParams::PricingType, nil)

    Body param: The pricing type of the package

  • status (Symbol, Stigg::Models::V1::PlanCreateParams::Status)

    Body param: The status of the package

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/stigg/resources/v1/plans.rb', line 47

def create(params)
  parsed, options = Stigg::V1::PlanCreateParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :post,
    path: "api/v1/plans",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::V1::Plan,
    options: options
  )
end

#create_draft(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Plan

Some parameter documentations has been truncated, see Models::V1::PlanCreateDraftParams for more details.

Creates a draft version of an existing plan for modification before publishing.

Parameters:

  • id (String)

    The unique identifier of the entity

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

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

Returns:

See Also:



237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/stigg/resources/v1/plans.rb', line 237

def create_draft(id, params = {})
  parsed, options = Stigg::V1::PlanCreateDraftParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1/plans/%1$s/draft", id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Plan,
    options: options
  )
end

#list(after: nil, before: nil, created_at: nil, limit: nil, product_id: nil, status: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::PlanListResponse>

Some parameter documentations has been truncated, see Models::V1::PlanListParams for more details.

Retrieves a paginated list of plans in the environment.

Parameters:

  • after (String)

    Query param: Return items that come after this cursor

  • before (String)

    Query param: Return items that come before this cursor

  • created_at (Stigg::Models::V1::PlanListParams::CreatedAt)

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

  • limit (Integer)

    Query param: Maximum number of items to return

  • product_id (String)

    Query param: Filter by product ID

  • status (Array<Symbol, Stigg::Models::V1::PlanListParams::Status>)

    Query param: Filter by status. Supports comma-separated values for multiple stat

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/stigg/resources/v1/plans.rb', line 169

def list(params = {})
  query_params = [:after, :before, :created_at, :limit, :product_id, :status]
  parsed, options = Stigg::V1::PlanListParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "api/v1/plans",
    query: query.transform_keys(created_at: "createdAt", product_id: "productId"),
    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::PlanListResponse,
    options: options
  )
end

#list_charges(id, after: nil, before: nil, limit: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::PlanListChargesResponse>

Some parameter documentations has been truncated, see Models::V1::PlanListChargesParams for more details.

Retrieves the list of charges configured on a plan.

Parameters:

  • id (String)

    Path param: The unique identifier of the entity

  • after (String)

    Query param: Return items that come after this cursor

  • before (String)

    Query param: Return items that come before this cursor

  • limit (Integer)

    Query param: Maximum number of items to return

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/stigg/resources/v1/plans.rb', line 275

def list_charges(id, params = {})
  query_params = [:after, :before, :limit]
  parsed, options = Stigg::V1::PlanListChargesParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["api/v1/plans/%1$s/charges", 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::PlanListChargesResponse,
    options: options
  )
end

#list_overage_charges(id, after: nil, before: nil, limit: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::PlanListOverageChargesResponse>

Some parameter documentations has been truncated, see Models::V1::PlanListOverageChargesParams for more details.

Retrieves the list of overage charges configured on a plan.

Parameters:

  • id (String)

    Path param: The unique identifier of the entity

  • after (String)

    Query param: Return items that come after this cursor

  • before (String)

    Query param: Return items that come before this cursor

  • limit (Integer)

    Query param: Maximum number of items to return

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/stigg/resources/v1/plans.rb', line 317

def list_overage_charges(id, params = {})
  query_params = [:after, :before, :limit]
  parsed, options = Stigg::V1::PlanListOverageChargesParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["api/v1/plans/%1$s/overage-charges", 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::PlanListOverageChargesResponse,
    options: options
  )
end

#publish(id, migration_type:, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::PlanPublishResponse

Some parameter documentations has been truncated, see Models::V1::PlanPublishParams for more details.

Publishes a draft plan, making it available for use in subscriptions.

Parameters:

  • id (String)

    Path param: The unique identifier of the entity

  • migration_type (Symbol, Stigg::Models::V1::PlanPublishParams::MigrationType)

    Body param: The migration type of the package

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/stigg/resources/v1/plans.rb', line 355

def publish(id, params)
  parsed, options = Stigg::V1::PlanPublishParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :post,
    path: ["api/v1/plans/%1$s/publish", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::Models::V1::PlanPublishResponse,
    options: options
  )
end

#remove_draft(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::PlanRemoveDraftResponse

Some parameter documentations has been truncated, see Models::V1::PlanRemoveDraftParams for more details.

Removes a draft version of a plan.

Parameters:

  • id (String)

    The unique identifier of the entity

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

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

Returns:

See Also:



386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/stigg/resources/v1/plans.rb', line 386

def remove_draft(id, params = {})
  parsed, options = Stigg::V1::PlanRemoveDraftParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["api/v1/plans/%1$s/draft", id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::Models::V1::PlanRemoveDraftResponse,
    options: options
  )
end

#retrieve(id, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Plan

Some parameter documentations has been truncated, see Models::V1::PlanRetrieveParams for more details.

Retrieves a plan by its unique identifier, including entitlements and pricing details.

Parameters:

  • id (String)

    The unique identifier of the entity

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

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

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/stigg/resources/v1/plans.rb', line 79

def retrieve(id, params = {})
  parsed, options = Stigg::V1::PlanRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["api/v1/plans/%1$s", id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::Plan,
    options: options
  )
end

#update(id, billing_id: nil, charges: nil, compatible_addon_ids: nil, default_trial_config: nil, description: nil, display_name: nil, metadata: nil, parent_plan_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {}) ⇒ Stigg::Models::V1::Plan

Some parameter documentations has been truncated, see Models::V1::PlanUpdateParams for more details.

Updates an existing plan’s properties such as display name, description, and metadata.

Parameters:

  • id (String)

    Path param: The unique identifier of the entity

  • billing_id (String, nil)

    Body param: The unique identifier for the entity in the billing provider

  • charges (Stigg::Models::V1::PlanUpdateParams::Charges)

    Body param: Pricing configuration to set on the plan draft

  • compatible_addon_ids (Array<String>, nil)

    Body param

  • default_trial_config (Stigg::Models::V1::PlanUpdateParams::DefaultTrialConfig, nil)

    Body param: Default trial configuration for the plan

  • description (String, nil)

    Body param: The description of the package

  • display_name (String)

    Body param: The display name of the package

  • metadata (Hash{Symbol=>String})

    Body param: Metadata associated with the entity

  • parent_plan_id (String, nil)

    Body param: The ID of the parent plan, if applicable

  • x_account_id (String)

    Header param: Account ID — optional when authenticating with a user JWT (Bearer

  • x_environment_id (String)

    Header param: Environment ID — required when authenticating with a user JWT (Bea

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

Returns:

See Also:



128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/stigg/resources/v1/plans.rb', line 128

def update(id, params = {})
  parsed, options = Stigg::V1::PlanUpdateParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :patch,
    path: ["api/v1/plans/%1$s", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::V1::Plan,
    options: options
  )
end