Class: CyberSourceMergedSpec::SubscriptionsController
- Inherits:
-
BaseController
- Object
- BaseController
- CyberSourceMergedSpec::SubscriptionsController
- Defined in:
- lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb
Overview
SubscriptionsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#activate_subscription(id, process_missed_payments: true) ⇒ ApiResponse
Reactivating a Suspended Subscription You can reactivate a suspended subscription for the next billing cycle.
-
#cancel_subscription(id) ⇒ ApiResponse
Cancel a Subscription.
-
#create_subscription(create_subscription_request) ⇒ ApiResponse
Create a Recurring Billing Subscription parameter: TODO: type description here.
-
#get_all_subscriptions(offset: nil, limit: nil, code: nil, status: nil, customer_id: nil, client_reference_information_code: nil) ⇒ ApiResponse
Retrieve Subscriptions by Subscription Code & Subscription Status.
-
#get_subscription(id) ⇒ ApiResponse
Get a Subscription by Subscription Id.
-
#get_subscription_code ⇒ ApiResponse
Get a Unique Subscription Code.
-
#subscriptions_id_payments_get(id, offset: nil, limit: nil, scheduled_payments_count: nil) ⇒ ApiResponse
Retrieve a list of payments for a specific subscription by its ID.
-
#subscriptions_id_payments_put(id, update_payments) ⇒ ApiResponse
Modifies the state of a subscription's payments.
-
#suspend_subscription(id) ⇒ ApiResponse
Suspend a Subscription.
-
#update_subscription(id, update_subscription) ⇒ ApiResponse
Update a Subscription by Subscription Id Subscription.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from CyberSourceMergedSpec::BaseController
Instance Method Details
#activate_subscription(id, process_missed_payments: true) ⇒ ApiResponse
Reactivating a Suspended Subscription
You can reactivate a suspended subscription for the next billing cycle.
You cannot reactivate a canceled or completed subscription.
You can specify whether you want to process missed payments for the period
during which the subscription was suspended using the
processMissedPayments query parameter by setting it to true or false.
If no value is specified, the system will default to true.
Important: The "processMissedPayments" query parameter is only
effective when the Ask each time before reactivating option is selected in
the reactivation settings. If any other option is chosen, the value
provided in the request will be ignored by the system. For more
information, see the [Recurring Billing User
Guide](https://developer.cybersource.com/docs/cybs/en-us/recurring-billing
/user/all/rest/recurring-billing-user/recurring-billing-user-about-guide.h
tml).
You can check how many payments were missed and the total amount by
retrieving the subscription details, where you will find the
reactivationInformation object. See: [Retrieving a
Subscription](https://developer.cybersource.com/docs/cybs/en-us/recurring-
billing/developer/all/rest/recurring-billing-dev/recur-bill-subscriptions/
recur-bill-getting-a-subscription.html).
parameter: Indicates if missed payments should be processed from the
period when the subscription was suspended. By default, this is set to
true. When any option other than "Ask each time before reactivating" is
selected in the reactivation settings, the value that you enter will be
ignored.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 228 def activate_subscription(id, process_missed_payments: true) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/rbs/v1/subscriptions/{id}/activate', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .query_param(new_parameter(process_missed_payments, key: 'processMissedPayments')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ActivateSubscriptionResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', ActivateSubscriptionException) .local_error('404', 'Not found.', ActivateSubscriptionException2Exception) .local_error('502', 'Unexpected system error or system timeout.', ActivateSubscriptionException3Exception)) .execute end |
#cancel_subscription(id) ⇒ ApiResponse
Cancel a Subscription
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 144 def cancel_subscription(id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/rbs/v1/subscriptions/{id}/cancel', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CancelSubscriptionResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', CancelSubscriptionException) .local_error('404', 'Not found.', CancelSubscriptionException2Exception) .local_error('502', 'Unexpected system error or system timeout.', CancelSubscriptionException3Exception)) .execute end |
#create_subscription(create_subscription_request) ⇒ ApiResponse
Create a Recurring Billing Subscription parameter: TODO: type description here
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 13 def create_subscription(create_subscription_request) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/rbs/v1/subscriptions', Server::DEFAULT) .body_param(new_parameter(create_subscription_request) .is_required(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreateSubscriptionResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', CreateSubscriptionException) .local_error('502', 'Unexpected system error or system timeout.', CreateSubscriptionException2Exception)) .execute end |
#get_all_subscriptions(offset: nil, limit: nil, code: nil, status: nil, customer_id: nil, client_reference_information_code: nil) ⇒ ApiResponse
Retrieve Subscriptions by Subscription Code & Subscription Status.
Default - 20, Max - 100
Filter by Client Reference Information Code / Merchant Reference Number
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 46 def get_all_subscriptions(offset: nil, limit: nil, code: nil, status: nil, customer_id: nil, client_reference_information_code: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/rbs/v1/subscriptions', Server::DEFAULT) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .query_param(new_parameter(offset, key: 'offset')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(code, key: 'code')) .query_param(new_parameter(status, key: 'status')) .query_param(new_parameter(customer_id, key: 'customerId')) .query_param(new_parameter(client_reference_information_code, key: 'clientReferenceInformationCode')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetAllSubscriptionsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', GetAllSubscriptionsException) .local_error('502', 'Unexpected system error or system timeout.', GetAllSubscriptionsException2Exception)) .execute end |
#get_subscription(id) ⇒ ApiResponse
Get a Subscription by Subscription Id
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 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 80 def get_subscription(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/rbs/v1/subscriptions/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetSubscriptionResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', GetSubscriptionException) .local_error('404', 'Not found.', GetSubscriptionException2Exception) .local_error('502', 'Unexpected system error or system timeout.', GetSubscriptionException3Exception)) .execute end |
#get_subscription_code ⇒ ApiResponse
Get a Unique Subscription Code
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 258 def get_subscription_code @api_call .request(new_request_builder(HttpMethodEnum::GET, '/rbs/v1/subscriptions/code', Server::DEFAULT) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetSubscriptionCodeResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', GetSubscriptionCodeException) .local_error('502', 'Unexpected system error or system timeout.', GetSubscriptionCodeException2Exception)) .execute end |
#subscriptions_id_payments_get(id, offset: nil, limit: nil, scheduled_payments_count: nil) ⇒ ApiResponse
Retrieve a list of payments for a specific subscription by its ID.
Default - 20, Max - 100
existing scheduled payments to be returned. Default - 5, Max - 9999
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 286 def subscriptions_id_payments_get(id, offset: nil, limit: nil, scheduled_payments_count: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/rbs/v1/subscriptions/{id}/payments', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .query_param(new_parameter(offset, key: 'offset')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(scheduled_payments_count, key: 'scheduledPaymentsCount')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetSubscriptionsPaymentsResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', SubscriptionsIdPaymentsGetException) .local_error('404', 'Not found.', SubscriptionsIdPaymentsGetException2Exception) .local_error('502', 'Unexpected system error or system timeout.', SubscriptionsIdPaymentsGetException3Exception)) .execute end |
#subscriptions_id_payments_put(id, update_payments) ⇒ ApiResponse
Modifies the state of a subscription's payments. Currently, the only possible modifications are "skipping" and "restoring" payments. Marking a payment as "skipped" means it will not be processed when its scheduled time arrives. "Restoring" a payment removes it from the list of payments to be skipped. payments of a subscription
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 328 def subscriptions_id_payments_put(id, update_payments) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/rbs/v1/subscriptions/{id}/payments', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .body_param(new_parameter(update_payments) .is_required(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetSubscriptionsPaymentsResponse1.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', SubscriptionsIdPaymentsPutException) .local_error('404', 'Not found.', SubscriptionsIdPaymentsPutException2Exception) .local_error('502', 'Unexpected system error or system timeout.', SubscriptionsIdPaymentsPutException3Exception)) .execute end |
#suspend_subscription(id) ⇒ ApiResponse
Suspend a Subscription
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 173 def suspend_subscription(id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/rbs/v1/subscriptions/{id}/suspend', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SuspendSubscriptionResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', SuspendSubscriptionException) .local_error('404', 'Not found.', SuspendSubscriptionException2Exception) .local_error('502', 'Unexpected system error or system timeout.', SuspendSubscriptionException3Exception)) .execute end |
#update_subscription(id, update_subscription) ⇒ ApiResponse
Update a Subscription by Subscription Id Subscription
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/cyber_source_merged_spec/controllers/subscriptions_controller.rb', line 111 def update_subscription(id, update_subscription) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/rbs/v1/subscriptions/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .should_encode(true)) .body_param(new_parameter(update_subscription) .is_required(true)) .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UpdateSubscriptionResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request.', UpdateSubscriptionException) .local_error('404', 'Not found.', UpdateSubscriptionException2Exception) .local_error('502', 'Unexpected system error or system timeout.', UpdateSubscriptionException3Exception)) .execute end |