Class: ApiReference::SubscriptionChangeApi
- Defined in:
- lib/api_reference/apis/subscription_change_api.rb
Overview
SubscriptionChangeApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#apply_subscription_change(subscription_change_id, body: nil) ⇒ ApiResponse
Apply a subscription change to perform the intended action.
-
#cancel_subscription_change(subscription_change_id) ⇒ ApiResponse
Cancel a subscription change.
-
#fetch_subscription_change(subscription_change_id) ⇒ ApiResponse
This endpoint returns a subscription change given an identifier.
-
#list_subscription_changes(limit: 20, cursor: nil, customer_id: nil, external_customer_id: nil, status: nil) ⇒ ApiResponse
This endpoint returns a list of pending subscription changes for a customer.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from ApiReference::BaseApi
Instance Method Details
#apply_subscription_change(subscription_change_id, body: nil) ⇒ ApiResponse
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. description here here
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/api_reference/apis/subscription_change_api.rb', line 126 def apply_subscription_change(subscription_change_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscription_changes/{subscription_change_id}/apply', Server::DEFAULT) .template_param(new_parameter(subscription_change_id, key: 'subscription_change_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('APIKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SubscriptionChangeResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', AuthorizationErrorException) .local_error('404', 'Not Found', APIException) .local_error('409', 'Conflict', IdempotencyRequestMismatchException) .local_error('413', 'Content Too Large', APIException) .local_error('429', 'Too Many Requests', TooManyRequestsException) .local_error('500', 'Internal Server Error', ServerErrorException)) .execute end |
#cancel_subscription_change(subscription_change_id) ⇒ ApiResponse
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. description here
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/api_reference/apis/subscription_change_api.rb', line 175 def cancel_subscription_change(subscription_change_id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/subscription_changes/{subscription_change_id}/cancel', Server::DEFAULT) .template_param(new_parameter(subscription_change_id, key: 'subscription_change_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('APIKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SubscriptionChangeResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', AuthorizationErrorException) .local_error('404', 'Not Found', APIException) .local_error('409', 'Conflict', IdempotencyRequestMismatchException) .local_error('413', 'Content Too Large', APIException) .local_error('429', 'Too Many Requests', TooManyRequestsException) .local_error('500', 'Internal Server Error', ServerErrorException)) .execute end |
#fetch_subscription_change(subscription_change_id) ⇒ ApiResponse
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.
description here
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/api_reference/apis/subscription_change_api.rb', line 79 def fetch_subscription_change(subscription_change_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/subscription_changes/{subscription_change_id}', Server::DEFAULT) .template_param(new_parameter(subscription_change_id, key: 'subscription_change_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('APIKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SubscriptionChangeResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', AuthorizationErrorException) .local_error('404', 'Not Found', APIException) .local_error('409', 'Conflict', IdempotencyRequestMismatchException) .local_error('413', 'Content Too Large', APIException) .local_error('429', 'Too Many Requests', TooManyRequestsException) .local_error('500', 'Internal Server Error', ServerErrorException)) .execute end |
#list_subscription_changes(limit: 20, cursor: nil, customer_id: nil, external_customer_id: nil, status: nil) ⇒ ApiResponse
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. here description here
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/api_reference/apis/subscription_change_api.rb', line 22 def list_subscription_changes(limit: 20, cursor: nil, customer_id: nil, external_customer_id: nil, status: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/subscription_changes', Server::DEFAULT) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(customer_id, key: 'customer_id')) .query_param(new_parameter(external_customer_id, key: 'external_customer_id')) .query_param(new_parameter(status, key: 'status')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('APIKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SubscriptionChangeListResponses.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', AuthorizationErrorException) .local_error('404', 'Not Found', APIException) .local_error('409', 'Conflict', IdempotencyRequestMismatchException) .local_error('413', 'Content Too Large', APIException) .local_error('429', 'Too Many Requests', TooManyRequestsException) .local_error('500', 'Internal Server Error', ServerErrorException)) .execute end |