Class: Orb::Resources::SubscriptionChanges

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

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:



133
134
135
# File 'lib/orb/resources/subscription_changes.rb', line 133

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

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.

  • mark_as_paid (Boolean, nil)

    Mark all pending invoices that are payable as paid. If amount is also provided,

  • payment_external_id (String, nil)

    An optional external ID to associate with the payment. Only applicable when mark

  • payment_notes (String, nil)

    Optional notes about the payment. Only applicable when mark_as_paid is true.

  • payment_received_date (Date, nil)

    A date string to specify the date the payment was received. Only applicable when

  • previously_collected_amount (String, nil)

    Amount already collected to apply to the customer's balance. If mark_as_paid is

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

Returns:

See Also:



98
99
100
101
102
103
104
105
106
107
# File 'lib/orb/resources/subscription_changes.rb', line 98

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:



121
122
123
124
125
126
127
128
# File 'lib/orb/resources/subscription_changes.rb', line 121

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

#list(cursor: nil, customer_id: nil, external_customer_id: nil, limit: nil, status: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::SubscriptionChangeListResponse>

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

This endpoint returns a list of pending subscription changes for a customer. Use the Fetch Subscription Change endpoint to retrieve the expected subscription state after the pending change is applied.

Parameters:

  • cursor (String, nil)

    Cursor for pagination. This can be populated by the next_cursor value returned

  • customer_id (String, nil)
  • external_customer_id (String, nil)
  • limit (Integer)

    The number of items to fetch. Defaults to 20.

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

Returns:

See Also:



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/orb/resources/subscription_changes.rb', line 57

def list(params = {})
  parsed, options = Orb::SubscriptionChangeListParams.dump_request(params)
  query = Orb::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "subscription_changes",
    query: query,
    page: Orb::Internal::Page,
    model: Orb::Models::SubscriptionChangeListResponse,
    options: 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, schedule plan change endpoint, ...). 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