Class: ProcessOut::Subscription
- Inherits:
-
Object
- Object
- ProcessOut::Subscription
- Defined in:
- lib/processout/subscription.rb
Instance Attribute Summary collapse
-
#activated ⇒ Object
Returns the value of attribute activated.
-
#activated_at ⇒ Object
Returns the value of attribute activated_at.
-
#active ⇒ Object
Returns the value of attribute active.
-
#addons ⇒ Object
Returns the value of attribute addons.
-
#addons_amount ⇒ Object
Returns the value of attribute addons_amount.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#billable_amount ⇒ Object
Returns the value of attribute billable_amount.
-
#cancel_at ⇒ Object
Returns the value of attribute cancel_at.
-
#cancel_url ⇒ Object
Returns the value of attribute cancel_url.
-
#canceled ⇒ Object
Returns the value of attribute canceled.
-
#cancellation_reason ⇒ Object
Returns the value of attribute cancellation_reason.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#discounted_amount ⇒ Object
Returns the value of attribute discounted_amount.
-
#discounts ⇒ Object
Returns the value of attribute discounts.
-
#id ⇒ Object
Returns the value of attribute id.
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#iterate_at ⇒ Object
Returns the value of attribute iterate_at.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pending_cancellation ⇒ Object
Returns the value of attribute pending_cancellation.
-
#plan ⇒ Object
Returns the value of attribute plan.
-
#plan_id ⇒ Object
Returns the value of attribute plan_id.
-
#project ⇒ Object
Returns the value of attribute project.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#return_url ⇒ Object
Returns the value of attribute return_url.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#token ⇒ Object
Returns the value of attribute token.
-
#token_id ⇒ Object
Returns the value of attribute token_id.
-
#transactions ⇒ Object
Returns the value of attribute transactions.
-
#trial_end_at ⇒ Object
Returns the value of attribute trial_end_at.
-
#unpaid_state ⇒ Object
Returns the value of attribute unpaid_state.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all the subscriptions.
-
#cancel(options = {}) ⇒ Object
Cancel a subscription.
-
#create(options = {}) ⇒ Object
Create a new subscription for the given customer.
-
#delete_addon(addon_id, options = {}) ⇒ Object
Delete an addon applied to a subscription.
-
#delete_discount(discount_id, options = {}) ⇒ Object
Delete a discount applied to a subscription.
-
#fetch_addons(options = {}) ⇒ Object
Get the addons applied to the subscription.
-
#fetch_customer(options = {}) ⇒ Object
Get the customer owning the subscription.
-
#fetch_discounts(options = {}) ⇒ Object
Get the discounts applied to the subscription.
-
#fetch_transactions(options = {}) ⇒ Object
Get the subscriptions past transactions.
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#find(subscription_id, options = {}) ⇒ Object
Find a subscription by its ID.
-
#find_addon(addon_id, options = {}) ⇒ Object
Find a subscription’s addon by its ID.
-
#find_discount(discount_id, options = {}) ⇒ Object
Find a subscription’s discount by its ID.
-
#initialize(client, data = {}) ⇒ Subscription
constructor
- Initializes the Subscription object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the Subscription object Params:
-
#new(data = {}) ⇒ Object
Create a new Subscription using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of data.
- Prefills the object with the data passed as parameters Params:
-
#save(options = {}) ⇒ Object
Save the updated subscription attributes.
Constructor Details
#initialize(client, data = {}) ⇒ Subscription
Initializes the Subscription object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
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 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/processout/subscription.rb', line 288 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.project = data.fetch(:project, nil) self.project_id = data.fetch(:project_id, nil) self.plan = data.fetch(:plan, nil) self.plan_id = data.fetch(:plan_id, nil) self.discounts = data.fetch(:discounts, nil) self.addons = data.fetch(:addons, nil) self.transactions = data.fetch(:transactions, nil) self.customer = data.fetch(:customer, nil) self.customer_id = data.fetch(:customer_id, nil) self.token = data.fetch(:token, nil) self.token_id = data.fetch(:token_id, nil) self.url = data.fetch(:url, nil) self.name = data.fetch(:name, nil) self.amount = data.fetch(:amount, nil) self.billable_amount = data.fetch(:billable_amount, nil) self.discounted_amount = data.fetch(:discounted_amount, nil) self.addons_amount = data.fetch(:addons_amount, nil) self.currency = data.fetch(:currency, nil) self. = data.fetch(:metadata, nil) self.interval = data.fetch(:interval, nil) self.trial_end_at = data.fetch(:trial_end_at, nil) self.activated = data.fetch(:activated, nil) self.active = data.fetch(:active, nil) self.cancel_at = data.fetch(:cancel_at, nil) self.canceled = data.fetch(:canceled, nil) self.cancellation_reason = data.fetch(:cancellation_reason, nil) self.pending_cancellation = data.fetch(:pending_cancellation, nil) self.return_url = data.fetch(:return_url, nil) self.cancel_url = data.fetch(:cancel_url, nil) self.unpaid_state = data.fetch(:unpaid_state, nil) self.sandbox = data.fetch(:sandbox, nil) self.created_at = data.fetch(:created_at, nil) self.activated_at = data.fetch(:activated_at, nil) self.iterate_at = data.fetch(:iterate_at, nil) end |
Instance Attribute Details
#activated ⇒ Object
Returns the value of attribute activated.
32 33 34 |
# File 'lib/processout/subscription.rb', line 32 def activated @activated end |
#activated_at ⇒ Object
Returns the value of attribute activated_at.
43 44 45 |
# File 'lib/processout/subscription.rb', line 43 def activated_at @activated_at end |
#active ⇒ Object
Returns the value of attribute active.
33 34 35 |
# File 'lib/processout/subscription.rb', line 33 def active @active end |
#addons ⇒ Object
Returns the value of attribute addons.
16 17 18 |
# File 'lib/processout/subscription.rb', line 16 def addons @addons end |
#addons_amount ⇒ Object
Returns the value of attribute addons_amount.
27 28 29 |
# File 'lib/processout/subscription.rb', line 27 def addons_amount @addons_amount end |
#amount ⇒ Object
Returns the value of attribute amount.
24 25 26 |
# File 'lib/processout/subscription.rb', line 24 def amount @amount end |
#billable_amount ⇒ Object
Returns the value of attribute billable_amount.
25 26 27 |
# File 'lib/processout/subscription.rb', line 25 def billable_amount @billable_amount end |
#cancel_at ⇒ Object
Returns the value of attribute cancel_at.
34 35 36 |
# File 'lib/processout/subscription.rb', line 34 def cancel_at @cancel_at end |
#cancel_url ⇒ Object
Returns the value of attribute cancel_url.
39 40 41 |
# File 'lib/processout/subscription.rb', line 39 def cancel_url @cancel_url end |
#canceled ⇒ Object
Returns the value of attribute canceled.
35 36 37 |
# File 'lib/processout/subscription.rb', line 35 def canceled @canceled end |
#cancellation_reason ⇒ Object
Returns the value of attribute cancellation_reason.
36 37 38 |
# File 'lib/processout/subscription.rb', line 36 def cancellation_reason @cancellation_reason end |
#created_at ⇒ Object
Returns the value of attribute created_at.
42 43 44 |
# File 'lib/processout/subscription.rb', line 42 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
28 29 30 |
# File 'lib/processout/subscription.rb', line 28 def currency @currency end |
#customer ⇒ Object
Returns the value of attribute customer.
18 19 20 |
# File 'lib/processout/subscription.rb', line 18 def customer @customer end |
#customer_id ⇒ Object
Returns the value of attribute customer_id.
19 20 21 |
# File 'lib/processout/subscription.rb', line 19 def customer_id @customer_id end |
#discounted_amount ⇒ Object
Returns the value of attribute discounted_amount.
26 27 28 |
# File 'lib/processout/subscription.rb', line 26 def discounted_amount @discounted_amount end |
#discounts ⇒ Object
Returns the value of attribute discounts.
15 16 17 |
# File 'lib/processout/subscription.rb', line 15 def discounts @discounts end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/processout/subscription.rb', line 10 def id @id end |
#interval ⇒ Object
Returns the value of attribute interval.
30 31 32 |
# File 'lib/processout/subscription.rb', line 30 def interval @interval end |
#iterate_at ⇒ Object
Returns the value of attribute iterate_at.
44 45 46 |
# File 'lib/processout/subscription.rb', line 44 def iterate_at @iterate_at end |
#metadata ⇒ Object
Returns the value of attribute metadata.
29 30 31 |
# File 'lib/processout/subscription.rb', line 29 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/processout/subscription.rb', line 23 def name @name end |
#pending_cancellation ⇒ Object
Returns the value of attribute pending_cancellation.
37 38 39 |
# File 'lib/processout/subscription.rb', line 37 def pending_cancellation @pending_cancellation end |
#plan ⇒ Object
Returns the value of attribute plan.
13 14 15 |
# File 'lib/processout/subscription.rb', line 13 def plan @plan end |
#plan_id ⇒ Object
Returns the value of attribute plan_id.
14 15 16 |
# File 'lib/processout/subscription.rb', line 14 def plan_id @plan_id end |
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/processout/subscription.rb', line 11 def project @project end |
#project_id ⇒ Object
Returns the value of attribute project_id.
12 13 14 |
# File 'lib/processout/subscription.rb', line 12 def project_id @project_id end |
#return_url ⇒ Object
Returns the value of attribute return_url.
38 39 40 |
# File 'lib/processout/subscription.rb', line 38 def return_url @return_url end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
41 42 43 |
# File 'lib/processout/subscription.rb', line 41 def sandbox @sandbox end |
#token ⇒ Object
Returns the value of attribute token.
20 21 22 |
# File 'lib/processout/subscription.rb', line 20 def token @token end |
#token_id ⇒ Object
Returns the value of attribute token_id.
21 22 23 |
# File 'lib/processout/subscription.rb', line 21 def token_id @token_id end |
#transactions ⇒ Object
Returns the value of attribute transactions.
17 18 19 |
# File 'lib/processout/subscription.rb', line 17 def transactions @transactions end |
#trial_end_at ⇒ Object
Returns the value of attribute trial_end_at.
31 32 33 |
# File 'lib/processout/subscription.rb', line 31 def trial_end_at @trial_end_at end |
#unpaid_state ⇒ Object
Returns the value of attribute unpaid_state.
40 41 42 |
# File 'lib/processout/subscription.rb', line 40 def unpaid_state @unpaid_state end |
#url ⇒ Object
Returns the value of attribute url.
22 23 24 |
# File 'lib/processout/subscription.rb', line 22 def url @url end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the subscriptions. Params:
options
-
Hash
of options
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/processout/subscription.rb', line 709 def all( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['subscriptions'] tmp = Subscription.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |
#cancel(options = {}) ⇒ Object
Cancel a subscription. The reason may be provided as well. Params:
options
-
Hash
of options
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
# File 'lib/processout/subscription.rb', line 841 def cancel( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "" data = { "cancel_at" => @cancel_at, "cancellation_reason" => @cancellation_reason, "cancel_at_end" => .fetch(:cancel_at_end, nil) } response = Response.new(request.delete(path, data, )) return_values = Array.new body = response.body body = body["subscription"] return_values.push(self.fill_with_data(body)) return_values[0] end |
#create(options = {}) ⇒ Object
Create a new subscription for the given customer. Params:
options
-
Hash
of options
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
# File 'lib/processout/subscription.rb', line 739 def create( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions" data = { "plan_id" => @plan_id, "cancel_at" => @cancel_at, "name" => @name, "amount" => @amount, "currency" => @currency, "metadata" => @metadata, "interval" => @interval, "trial_end_at" => @trial_end_at, "customer_id" => @customer_id, "return_url" => @return_url, "cancel_url" => @cancel_url, "source" => .fetch(:source, nil), "coupon_id" => .fetch(:coupon_id, nil) } response = Response.new(request.post(path, data, )) return_values = Array.new body = response.body body = body["subscription"] return_values.push(self.fill_with_data(body)) return_values[0] end |
#delete_addon(addon_id, options = {}) ⇒ Object
Delete an addon applied to a subscription. Params:
addon_id
-
ID of the addon or plan to be removed from the subscription
options
-
Hash
of options
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File 'lib/processout/subscription.rb', line 555 def delete_addon(addon_id, = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/addons/" + CGI.escape(addon_id) + "" data = { "prorate" => .fetch(:prorate, nil), "proration_date" => .fetch(:proration_date, nil), "preview" => .fetch(:preview, nil) } response = Response.new(request.delete(path, data, )) return_values = Array.new return_values.push(response.success) return_values[0] end |
#delete_discount(discount_id, options = {}) ⇒ Object
Delete a discount applied to a subscription. Params:
discount_id
-
ID of the discount or coupon to be removed from the subscription
options
-
Hash
of options
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
# File 'lib/processout/subscription.rb', line 658 def delete_discount(discount_id, = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/discounts/" + CGI.escape(discount_id) + "" data = { } response = Response.new(request.delete(path, data, )) return_values = Array.new return_values.push(response.success) return_values[0] end |
#fetch_addons(options = {}) ⇒ Object
Get the addons applied to the subscription. Params:
options
-
Hash
of options
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 |
# File 'lib/processout/subscription.rb', line 499 def fetch_addons( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/addons" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['addons'] tmp = Addon.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |
#fetch_customer(options = {}) ⇒ Object
Get the customer owning the subscription. Params:
options
-
Hash
of options
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
# File 'lib/processout/subscription.rb', line 578 def fetch_customer( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/customers" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["customer"] customer = Customer.new(@client) return_values.push(customer.fill_with_data(body)) return_values[0] end |
#fetch_discounts(options = {}) ⇒ Object
Get the discounts applied to the subscription. Params:
options
-
Hash
of options
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 |
# File 'lib/processout/subscription.rb', line 602 def fetch_discounts( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/discounts" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['discounts'] tmp = Discount.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |
#fetch_transactions(options = {}) ⇒ Object
Get the subscriptions past transactions. Params:
options
-
Hash
of options
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
# File 'lib/processout/subscription.rb', line 679 def fetch_transactions( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/transactions" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['transactions'] tmp = Transaction.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API
337 338 339 340 341 342 343 344 345 346 347 348 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 379 380 381 382 383 384 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 416 417 418 419 420 421 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 |
# File 'lib/processout/subscription.rb', line 337 def fill_with_data(data) if data.nil? return self end if data.include? "id" self.id = data["id"] end if data.include? "project" self.project = data["project"] end if data.include? "project_id" self.project_id = data["project_id"] end if data.include? "plan" self.plan = data["plan"] end if data.include? "plan_id" self.plan_id = data["plan_id"] end if data.include? "discounts" self.discounts = data["discounts"] end if data.include? "addons" self.addons = data["addons"] end if data.include? "transactions" self.transactions = data["transactions"] end if data.include? "customer" self.customer = data["customer"] end if data.include? "customer_id" self.customer_id = data["customer_id"] end if data.include? "token" self.token = data["token"] end if data.include? "token_id" self.token_id = data["token_id"] end if data.include? "url" self.url = data["url"] end if data.include? "name" self.name = data["name"] end if data.include? "amount" self.amount = data["amount"] end if data.include? "billable_amount" self.billable_amount = data["billable_amount"] end if data.include? "discounted_amount" self.discounted_amount = data["discounted_amount"] end if data.include? "addons_amount" self.addons_amount = data["addons_amount"] end if data.include? "currency" self.currency = data["currency"] end if data.include? "metadata" self. = data["metadata"] end if data.include? "interval" self.interval = data["interval"] end if data.include? "trial_end_at" self.trial_end_at = data["trial_end_at"] end if data.include? "activated" self.activated = data["activated"] end if data.include? "active" self.active = data["active"] end if data.include? "cancel_at" self.cancel_at = data["cancel_at"] end if data.include? "canceled" self.canceled = data["canceled"] end if data.include? "cancellation_reason" self.cancellation_reason = data["cancellation_reason"] end if data.include? "pending_cancellation" self.pending_cancellation = data["pending_cancellation"] end if data.include? "return_url" self.return_url = data["return_url"] end if data.include? "cancel_url" self.cancel_url = data["cancel_url"] end if data.include? "unpaid_state" self.unpaid_state = data["unpaid_state"] end if data.include? "sandbox" self.sandbox = data["sandbox"] end if data.include? "created_at" self.created_at = data["created_at"] end if data.include? "activated_at" self.activated_at = data["activated_at"] end if data.include? "iterate_at" self.iterate_at = data["iterate_at"] end self end |
#find(subscription_id, options = {}) ⇒ Object
Find a subscription by its ID. Params:
subscription_id
-
ID of the subscription
options
-
Hash
of options
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
# File 'lib/processout/subscription.rb', line 778 def find(subscription_id, = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(subscription_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["subscription"] obj = Subscription.new(@client) return_values.push(obj.fill_with_data(body)) return_values[0] end |
#find_addon(addon_id, options = {}) ⇒ Object
Find a subscription’s addon by its ID. Params:
addon_id
-
ID of the addon
options
-
Hash
of options
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/processout/subscription.rb', line 530 def find_addon(addon_id, = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/addons/" + CGI.escape(addon_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["addon"] addon = Addon.new(@client) return_values.push(addon.fill_with_data(body)) return_values[0] end |
#find_discount(discount_id, options = {}) ⇒ Object
Find a subscription’s discount by its ID. Params:
discount_id
-
ID of the discount
options
-
Hash
of options
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
# File 'lib/processout/subscription.rb', line 633 def find_discount(discount_id, = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "/discounts/" + CGI.escape(discount_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["discount"] discount = Discount.new(@client) return_values.push(discount.fill_with_data(body)) return_values[0] end |
#new(data = {}) ⇒ Object
Create a new Subscription using the current client
330 331 332 |
# File 'lib/processout/subscription.rb', line 330 def new(data = {}) Subscription.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
453 454 455 456 457 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 490 491 492 493 494 |
# File 'lib/processout/subscription.rb', line 453 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.project = data.fetch(:project, self.project) self.project_id = data.fetch(:project_id, self.project_id) self.plan = data.fetch(:plan, self.plan) self.plan_id = data.fetch(:plan_id, self.plan_id) self.discounts = data.fetch(:discounts, self.discounts) self.addons = data.fetch(:addons, self.addons) self.transactions = data.fetch(:transactions, self.transactions) self.customer = data.fetch(:customer, self.customer) self.customer_id = data.fetch(:customer_id, self.customer_id) self.token = data.fetch(:token, self.token) self.token_id = data.fetch(:token_id, self.token_id) self.url = data.fetch(:url, self.url) self.name = data.fetch(:name, self.name) self.amount = data.fetch(:amount, self.amount) self.billable_amount = data.fetch(:billable_amount, self.billable_amount) self.discounted_amount = data.fetch(:discounted_amount, self.discounted_amount) self.addons_amount = data.fetch(:addons_amount, self.addons_amount) self.currency = data.fetch(:currency, self.currency) self. = data.fetch(:metadata, self.) self.interval = data.fetch(:interval, self.interval) self.trial_end_at = data.fetch(:trial_end_at, self.trial_end_at) self.activated = data.fetch(:activated, self.activated) self.active = data.fetch(:active, self.active) self.cancel_at = data.fetch(:cancel_at, self.cancel_at) self.canceled = data.fetch(:canceled, self.canceled) self.cancellation_reason = data.fetch(:cancellation_reason, self.cancellation_reason) self.pending_cancellation = data.fetch(:pending_cancellation, self.pending_cancellation) self.return_url = data.fetch(:return_url, self.return_url) self.cancel_url = data.fetch(:cancel_url, self.cancel_url) self.unpaid_state = data.fetch(:unpaid_state, self.unpaid_state) self.sandbox = data.fetch(:sandbox, self.sandbox) self.created_at = data.fetch(:created_at, self.created_at) self.activated_at = data.fetch(:activated_at, self.activated_at) self.iterate_at = data.fetch(:iterate_at, self.iterate_at) self end |
#save(options = {}) ⇒ Object
Save the updated subscription attributes. Params:
options
-
Hash
of options
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
# File 'lib/processout/subscription.rb', line 805 def save( = {}) self.prefill() request = Request.new(@client) path = "/subscriptions/" + CGI.escape(@id) + "" data = { "plan_id" => @plan_id, "name" => @name, "amount" => @amount, "interval" => @interval, "trial_end_at" => @trial_end_at, "metadata" => @metadata, "coupon_id" => .fetch(:coupon_id, nil), "source" => .fetch(:source, nil), "prorate" => .fetch(:prorate, nil), "proration_date" => .fetch(:proration_date, nil), "preview" => .fetch(:preview, nil) } response = Response.new(request.put(path, data, )) return_values = Array.new body = response.body body = body["subscription"] return_values.push(self.fill_with_data(body)) return_values[0] end |