Class: MundiApi::SubscriptionsController
- Inherits:
-
BaseController
- Object
- BaseController
- MundiApi::SubscriptionsController
- Defined in:
- lib/mundi_api/controllers/subscriptions_controller.rb
Overview
SubscriptionsController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#cancel_subscription(subscription_id, request = nil) ⇒ Object
Cancels a subscription Request for cancelling a subscription.
-
#create_discount(subscription_id, request) ⇒ Object
Creates a discount creating a discount.
-
#create_subscription(body) ⇒ Object
Creates a new subscription creating a subscription.
-
#create_subscription_item(subscription_id, request) ⇒ Object
Creates a new Subscription item for creating a subscription item.
-
#create_usage(subscription_id, item_id, body) ⇒ Object
Creates a usage a usage.
-
#delete_discount(subscription_id, discount_id) ⇒ Object
Deletes a discount.
-
#delete_subscription_item(subscription_id, subscription_item_id) ⇒ Object
Deletes a subscription item id.
-
#delete_usage(subscription_id, item_id, usage_id) ⇒ Object
Deletes a usage.
-
#get_subscription(subscription_id) ⇒ Object
Gets a subscription.
-
#get_subscriptions(page = nil, size = nil, code = nil, billing_type = nil, customer_id = nil, plan_id = nil, card_id = nil, status = nil, next_billing_since = nil, next_billing_until = nil, created_since = nil, created_until = nil) ⇒ Object
Gets all subscriptions billing type customer id id id status subscription’s next billing date start range subscription’s next billing date end range subscription’s creation date start range subscriptions creation date end range.
-
#get_usages(subscription_id, item_id, page = nil, size = nil) ⇒ Object
Lists all usages from a subscription item.
- #instance ⇒ Object
-
#update_subscription_billing_date(subscription_id, request) ⇒ Object
Updates the billing date from a subscription Request for updating the subscription billing date.
-
#update_subscription_card(subscription_id, request) ⇒ Object
Updates the credit card from a subscription for updating a card.
-
#update_subscription_item(subscription_id, item_id, body) ⇒ Object
Updates a subscription item for updating a subscription item.
-
#update_subscription_metadata(subscription_id, request) ⇒ Object
Updates the metadata from a subscription updating the subscrption metadata.
-
#update_subscription_payment_method(subscription_id, request) ⇒ Object
Updates the payment method from a subscription parameter: Request for updating the paymentmethod from a subscription.
Methods inherited from BaseController
#execute_request, #initialize, #validate_parameters, #validate_response
Constructor Details
This class inherits a constructor from MundiApi::BaseController
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
10 11 12 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 10 def instance @instance end |
Instance Method Details
#cancel_subscription(subscription_id, request = nil) ⇒ Object
Cancels a subscription Request for cancelling a subscription
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 385 def cancel_subscription(subscription_id, request = nil) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.delete( _query_url, headers: _headers, parameters: request.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionResponse.from_hash(decoded) end |
#create_discount(subscription_id, request) ⇒ Object
Creates a discount creating a discount
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 244 def create_discount(subscription_id, request) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/discounts' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.post( _query_url, headers: _headers, parameters: request.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetDiscountResponse.from_hash(decoded) end |
#create_subscription(body) ⇒ Object
Creates a new subscription creating a subscription
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 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 175 def create_subscription(body) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.post( _query_url, headers: _headers, parameters: body.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionResponse.from_hash(decoded) end |
#create_subscription_item(subscription_id, request) ⇒ Object
Creates a new Subscription item for creating a subscription item
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 207 def create_subscription_item(subscription_id, request) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/items' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.post( _query_url, headers: _headers, parameters: request.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionItemResponse.from_hash(decoded) end |
#create_usage(subscription_id, item_id, body) ⇒ Object
Creates a usage a usage
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 89 90 91 92 93 94 95 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 63 def create_usage(subscription_id, item_id, body) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/items/{item_id}/usages' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id, 'item_id' => item_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.post( _query_url, headers: _headers, parameters: body.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetUsageResponse.from_hash(decoded) end |
#delete_discount(subscription_id, discount_id) ⇒ Object
Deletes a discount
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 349 def delete_discount(subscription_id, discount_id) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/discounts/{discount_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id, 'discount_id' => discount_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = @http_client.delete( _query_url, headers: _headers ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetDiscountResponse.from_hash(decoded) end |
#delete_subscription_item(subscription_id, subscription_item_id) ⇒ Object
Deletes a subscription item id
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 422 def delete_subscription_item(subscription_id, subscription_item_id) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/items/{subscription_item_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id, 'subscription_item_id' => subscription_item_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = @http_client.delete( _query_url, headers: _headers ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionItemResponse.from_hash(decoded) end |
#delete_usage(subscription_id, item_id, usage_id) ⇒ Object
Deletes a usage
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 458 def delete_usage(subscription_id, item_id, usage_id) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id, 'item_id' => item_id, 'usage_id' => usage_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = @http_client.delete( _query_url, headers: _headers ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetUsageResponse.from_hash(decoded) end |
#get_subscription(subscription_id) ⇒ Object
Gets a subscription
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 279 def get_subscription(subscription_id) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = @http_client.get( _query_url, headers: _headers ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionResponse.from_hash(decoded) end |
#get_subscriptions(page = nil, size = nil, code = nil, billing_type = nil, customer_id = nil, plan_id = nil, card_id = nil, status = nil, next_billing_since = nil, next_billing_until = nil, created_since = nil, created_until = nil) ⇒ Object
Gets all subscriptions billing type customer id id id status subscription’s next billing date start range subscription’s next billing date end range subscription’s creation date start range subscriptions creation date end range
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 596 def get_subscriptions(page = nil, size = nil, code = nil, billing_type = nil, customer_id = nil, plan_id = nil, card_id = nil, status = nil, next_billing_since = nil, next_billing_until = nil, created_since = nil, created_until = nil) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions' _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'page' => page, 'size' => size, 'code' => code, 'billing_type' => billing_type, 'customer_id' => customer_id, 'plan_id' => plan_id, 'card_id' => card_id, 'status' => status, 'next_billing_since' => next_billing_since, 'next_billing_until' => next_billing_until, 'created_since' => created_since, 'created_until' => created_until, array_serialization: Configuration.array_serialization ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = @http_client.get( _query_url, headers: _headers ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) ListSubscriptionsResponse.from_hash(decoded) end |
#get_usages(subscription_id, item_id, page = nil, size = nil) ⇒ Object
Lists all usages from a subscription item
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 497 def get_usages(subscription_id, item_id, page = nil, size = nil) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/items/{item_id}/usages' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id, 'item_id' => item_id ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'page' => page, 'size' => size, array_serialization: Configuration.array_serialization ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = @http_client.get( _query_url, headers: _headers ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) ListUsagesResponse.from_hash(decoded) end |
#instance ⇒ Object
13 14 15 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 13 def instance self.class.instance end |
#update_subscription_billing_date(subscription_id, request) ⇒ Object
Updates the billing date from a subscription Request for updating the subscription billing date
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 102 def update_subscription_billing_date(subscription_id, request) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/billing-date' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.patch( _query_url, headers: _headers, parameters: request.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionResponse.from_hash(decoded) end |
#update_subscription_card(subscription_id, request) ⇒ Object
Updates the credit card from a subscription for updating a card
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 167 168 169 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 139 def update_subscription_card(subscription_id, request) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/card' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.patch( _query_url, headers: _headers, parameters: request.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionResponse.from_hash(decoded) end |
#update_subscription_item(subscription_id, item_id, body) ⇒ Object
Updates a subscription item for updating a subscription item
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 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 23 def update_subscription_item(subscription_id, item_id, body) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/items/{item_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id, 'item_id' => item_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.put( _query_url, headers: _headers, parameters: body.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionItemResponse.from_hash(decoded) end |
#update_subscription_metadata(subscription_id, request) ⇒ Object
Updates the metadata from a subscription updating the subscrption metadata
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 541 def (subscription_id, request) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/Subscriptions/{subscription_id}/metadata' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.patch( _query_url, headers: _headers, parameters: request.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionResponse.from_hash(decoded) end |
#update_subscription_payment_method(subscription_id, request) ⇒ Object
Updates the payment method from a subscription parameter: Request for updating the paymentmethod from a subscription
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/mundi_api/controllers/subscriptions_controller.rb', line 313 def update_subscription_payment_method(subscription_id, request) # Prepare query url. _query_builder = Configuration.base_uri.dup _query_builder << '/subscriptions/{subscription_id}/payment-method' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'subscription_id' => subscription_id ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = @http_client.patch( _query_url, headers: _headers, parameters: request.to_json ) BasicAuth.apply(_request) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. decoded = APIHelper.json_deserialize(_context.response.raw_body) GetSubscriptionResponse.from_hash(decoded) end |