Class: StickyIoRestfulApiV2025731::CreditsController
- Inherits:
-
BaseController
- Object
- BaseController
- StickyIoRestfulApiV2025731::CreditsController
- Defined in:
- lib/sticky_io_restful_api_v2025731/controllers/credits_controller.rb
Overview
CreditsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_update_subscription_credit(body, domain, v2_ext, subscription_id) ⇒ ApiResponse
This will be used to either create or update a subscription credit.
-
#delete_subscription_credit(domain, v2_ext, subscription_id) ⇒ ApiResponse
Remove a subscription credit here.
-
#destroy_subscription_credit(domain, v2_ext, order_id) ⇒ ApiResponse
Remove credit of an order.
-
#get_subscription_credit(domain, v2_ext, subscription_id) ⇒ ApiResponse
View the details of a subscription credit here.
-
#issue_subscription_credit(body, domain, v2_ext, order_id) ⇒ ApiResponse
Adds or replace credit to an order.
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 StickyIoRestfulApiV2025731::BaseController
Instance Method Details
#create_update_subscription_credit(body, domain, v2_ext, subscription_id) ⇒ ApiResponse
This will be used to either create or update a subscription credit. ‘action` is an additional parameter that can be passed in the request. when the `action` is `replace` the amount that is passed in the request will be the amount that is now a credit on the subscription. If it is not passed, and there is already a credit on the subscription, the amount passed will be ADDED to the subscription TODO: type description here 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 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/credits_controller.rb', line 22 def create_update_subscription_credit(body, domain, v2_ext, subscription_id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}subscriptions/{subscription_id}/credits', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ReplaceSubscriptionCredit.method(:from_hash)) .is_api_response(true) .local_error('404', 'Not Found', InvalidSubscriptionIdException)) .execute end |
#delete_subscription_credit(domain, v2_ext, subscription_id) ⇒ ApiResponse
Remove a subscription credit here
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/credits_controller.rb', line 61 def delete_subscription_credit(domain, v2_ext, subscription_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}subscriptions/{subscription_id}/credits', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DeleteSubscriptionCredit.method(:from_hash)) .is_api_response(true) .local_error('404', 'Not Found', InvalidSubscripitionIdException)) .execute end |
#destroy_subscription_credit(domain, v2_ext, order_id) ⇒ ApiResponse
Remove credit of an order.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/credits_controller.rb', line 167 def destroy_subscription_credit(domain, v2_ext, order_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}orders/{order_id}/credit', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .template_param(new_parameter(order_id, key: 'order_id') .is_required(true) .should_encode(true)) .auth(Single.new('basic'))) .response(new_response_handler .is_response_void(true) .is_api_response(true)) .execute end |
#get_subscription_credit(domain, v2_ext, subscription_id) ⇒ ApiResponse
View the details of a subscription credit here
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/credits_controller.rb', line 96 def get_subscription_credit(domain, v2_ext, subscription_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}subscriptions/{subscription_id}/credits', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .template_param(new_parameter(subscription_id, key: 'subscription_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetSubscriptionCredit.method(:from_hash)) .is_api_response(true) .local_error('404', 'Not Found', InvalidSubscriptionIdException)) .execute end |
#issue_subscription_credit(body, domain, v2_ext, order_id) ⇒ ApiResponse
Adds or replace credit to an order. credit_action parameter is optional. If passed and equals ‘replace’ the credit gets replaced, else the credit gets added to the existing credit. type description here
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 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/credits_controller.rb', line 134 def issue_subscription_credit(body, domain, v2_ext, order_id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}orders/{order_id}/credit', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .template_param(new_parameter(order_id, key: 'order_id') .is_required(true) .should_encode(true)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('basic'))) .response(new_response_handler .is_response_void(true) .is_api_response(true)) .execute end |