Class: Orb::Resources::SubscriptionChanges

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/resources/subscription_changes.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SubscriptionChanges

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

Parameters:



85
86
87
# File 'lib/orb/resources/subscription_changes.rb', line 85

def initialize(client:)
  @client = client
end

Instance Method Details

#apply(subscription_change_id, description: nil, previously_collected_amount: nil, request_options: {}) ⇒ Orb::Models::SubscriptionChangeApplyResponse

Apply a subscription change to perform the intended action. If a positive amount is passed with a request to this endpoint, any eligible invoices that were created will be issued immediately if they only contain in-advance fees.

Parameters:

  • subscription_change_id (String)
  • description (String, nil)

    Description to apply to the balance transaction representing this credit.

  • previously_collected_amount (String, nil)

    Amount already collected to apply to the customer’s balance.

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

Returns:

See Also:



50
51
52
53
54
55
56
57
58
59
# File 'lib/orb/resources/subscription_changes.rb', line 50

def apply(subscription_change_id, params = {})
  parsed, options = Orb::SubscriptionChangeApplyParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["subscription_changes/%1$s/apply", subscription_change_id],
    body: parsed,
    model: Orb::Models::SubscriptionChangeApplyResponse,
    options: options
  )
end

#cancel(subscription_change_id, request_options: {}) ⇒ Orb::Models::SubscriptionChangeCancelResponse

Cancel a subscription change. The change can no longer be applied. A subscription can only have one “pending” change at a time - use this endpoint to cancel an existing change before creating a new one.

Parameters:

  • subscription_change_id (String)
  • request_options (Orb::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



73
74
75
76
77
78
79
80
# File 'lib/orb/resources/subscription_changes.rb', line 73

def cancel(subscription_change_id, params = {})
  @client.request(
    method: :post,
    path: ["subscription_changes/%1$s/cancel", subscription_change_id],
    model: Orb::Models::SubscriptionChangeCancelResponse,
    options: params[:request_options]
  )
end

#retrieve(subscription_change_id, request_options: {}) ⇒ Orb::Models::SubscriptionChangeRetrieveResponse

This endpoint returns a subscription change given an identifier.

A subscription change is created by including ‘Create-Pending-Subscription-Change: True` in the header of a subscription mutation API call (e.g. [create subscription endpoint](/api-reference/subscription/create-subscription), [schedule plan change endpoint](/api-reference/subscription/schedule-plan-change), …). The subscription change will be referenced by the `pending_subscription_change` field in the response.

Parameters:

  • subscription_change_id (String)
  • request_options (Orb::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



24
25
26
27
28
29
30
31
# File 'lib/orb/resources/subscription_changes.rb', line 24

def retrieve(subscription_change_id, params = {})
  @client.request(
    method: :get,
    path: ["subscription_changes/%1$s", subscription_change_id],
    model: Orb::Models::SubscriptionChangeRetrieveResponse,
    options: params[:request_options]
  )
end