Class: Braintree::Subscription
- Inherits:
-
Object
- Object
- Braintree::Subscription
- Includes:
- BaseModule, Util::IdEquality
- Defined in:
- lib/braintree/subscription.rb,
lib/braintree/subscription/status_details.rb
Defined Under Namespace
Modules: Source, Status, TrialDurationUnit Classes: StatusDetails
Instance Attribute Summary collapse
-
#add_ons ⇒ Object
readonly
Returns the value of attribute add_ons.
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#billing_day_of_month ⇒ Object
readonly
Returns the value of attribute billing_day_of_month.
-
#billing_period_end_date ⇒ Object
readonly
Returns the value of attribute billing_period_end_date.
-
#billing_period_start_date ⇒ Object
readonly
Returns the value of attribute billing_period_start_date.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#current_billing_cycle ⇒ Object
readonly
Returns the value of attribute current_billing_cycle.
-
#days_past_due ⇒ Object
readonly
Returns the value of attribute days_past_due.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#descriptor ⇒ Object
readonly
Returns the value of attribute descriptor.
-
#discounts ⇒ Object
readonly
Returns the value of attribute discounts.
-
#failure_count ⇒ Object
readonly
Returns the value of attribute failure_count.
-
#first_billing_date ⇒ Object
readonly
Returns the value of attribute first_billing_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#merchant_account_id ⇒ Object
readonly
Returns the value of attribute merchant_account_id.
-
#next_billing_date ⇒ Object
readonly
Returns the value of attribute next_billing_date.
-
#next_billing_period_amount ⇒ Object
readonly
Returns the value of attribute next_billing_period_amount.
-
#number_of_billing_cycles ⇒ Object
readonly
Returns the value of attribute number_of_billing_cycles.
-
#paid_through_date ⇒ Object
readonly
Returns the value of attribute paid_through_date.
-
#payment_method_token ⇒ Object
readonly
Returns the value of attribute payment_method_token.
-
#plan_id ⇒ Object
readonly
Returns the value of attribute plan_id.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_history ⇒ Object
readonly
Returns the value of attribute status_history.
-
#transactions ⇒ Object
readonly
Returns the value of attribute transactions.
-
#trial_duration ⇒ Object
readonly
Returns the value of attribute trial_duration.
-
#trial_duration_unit ⇒ Object
readonly
Returns the value of attribute trial_duration_unit.
-
#trial_period ⇒ Object
readonly
Returns the value of attribute trial_period.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
- ._new(*args) ⇒ Object
- .cancel(*args) ⇒ Object
- .cancel!(*args) ⇒ Object
- .create(*args) ⇒ Object
- .create!(*args) ⇒ Object
- .find(*args) ⇒ Object
- .retry_charge(*args) ⇒ Object
- .search(&block) ⇒ Object
- .update(*args) ⇒ Object
- .update!(*args) ⇒ Object
Instance Method Summary collapse
-
#initialize(gateway, attributes) ⇒ Subscription
constructor
A new instance of Subscription.
- #never_expires? ⇒ Boolean
Methods included from Util::IdEquality
Methods included from BaseModule
Methods included from BaseModule::Methods
#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class
Constructor Details
#initialize(gateway, attributes) ⇒ Subscription
Returns a new instance of Subscription.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/braintree/subscription.rb', line 94 def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @balance = Util.to_big_decimal(balance) @price = Util.to_big_decimal(price) @descriptor = Descriptor.new(@descriptor) transactions.map! { |attrs| Transaction._new(gateway, attrs) } add_ons.map! { |attrs| AddOn._new(attrs) } discounts.map! { |attrs| Discount._new(attrs) } @status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : [] @first_billing_date = Date.parse(first_billing_date) unless first_billing_date.nil? @next_billing_date = Date.parse(next_billing_date) unless next_billing_date.nil? @billing_period_start_date = Date.parse(billing_period_start_date) unless billing_period_start_date.nil? @billing_period_end_date = Date.parse(billing_period_end_date) unless billing_period_end_date.nil? @paid_through_date = Date.parse(paid_through_date) unless paid_through_date.nil? end |
Instance Attribute Details
#add_ons ⇒ Object (readonly)
Returns the value of attribute add_ons.
28 29 30 |
# File 'lib/braintree/subscription.rb', line 28 def add_ons @add_ons end |
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
29 30 31 |
# File 'lib/braintree/subscription.rb', line 29 def balance @balance end |
#billing_day_of_month ⇒ Object (readonly)
Returns the value of attribute billing_day_of_month.
30 31 32 |
# File 'lib/braintree/subscription.rb', line 30 def billing_day_of_month @billing_day_of_month end |
#billing_period_end_date ⇒ Object (readonly)
Returns the value of attribute billing_period_end_date.
31 32 33 |
# File 'lib/braintree/subscription.rb', line 31 def billing_period_end_date @billing_period_end_date end |
#billing_period_start_date ⇒ Object (readonly)
Returns the value of attribute billing_period_start_date.
32 33 34 |
# File 'lib/braintree/subscription.rb', line 32 def billing_period_start_date @billing_period_start_date end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
33 34 35 |
# File 'lib/braintree/subscription.rb', line 33 def created_at @created_at end |
#current_billing_cycle ⇒ Object (readonly)
Returns the value of attribute current_billing_cycle.
34 35 36 |
# File 'lib/braintree/subscription.rb', line 34 def current_billing_cycle @current_billing_cycle end |
#days_past_due ⇒ Object (readonly)
Returns the value of attribute days_past_due.
35 36 37 |
# File 'lib/braintree/subscription.rb', line 35 def days_past_due @days_past_due end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
36 37 38 |
# File 'lib/braintree/subscription.rb', line 36 def description @description end |
#descriptor ⇒ Object (readonly)
Returns the value of attribute descriptor.
37 38 39 |
# File 'lib/braintree/subscription.rb', line 37 def descriptor @descriptor end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts.
38 39 40 |
# File 'lib/braintree/subscription.rb', line 38 def discounts @discounts end |
#failure_count ⇒ Object (readonly)
Returns the value of attribute failure_count.
39 40 41 |
# File 'lib/braintree/subscription.rb', line 39 def failure_count @failure_count end |
#first_billing_date ⇒ Object (readonly)
Returns the value of attribute first_billing_date.
40 41 42 |
# File 'lib/braintree/subscription.rb', line 40 def first_billing_date @first_billing_date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
41 42 43 |
# File 'lib/braintree/subscription.rb', line 41 def id @id end |
#merchant_account_id ⇒ Object (readonly)
Returns the value of attribute merchant_account_id.
42 43 44 |
# File 'lib/braintree/subscription.rb', line 42 def merchant_account_id @merchant_account_id end |
#next_billing_date ⇒ Object (readonly)
Returns the value of attribute next_billing_date.
43 44 45 |
# File 'lib/braintree/subscription.rb', line 43 def next_billing_date @next_billing_date end |
#next_billing_period_amount ⇒ Object (readonly)
Returns the value of attribute next_billing_period_amount.
44 45 46 |
# File 'lib/braintree/subscription.rb', line 44 def next_billing_period_amount @next_billing_period_amount end |
#number_of_billing_cycles ⇒ Object (readonly)
Returns the value of attribute number_of_billing_cycles.
45 46 47 |
# File 'lib/braintree/subscription.rb', line 45 def number_of_billing_cycles @number_of_billing_cycles end |
#paid_through_date ⇒ Object (readonly)
Returns the value of attribute paid_through_date.
46 47 48 |
# File 'lib/braintree/subscription.rb', line 46 def paid_through_date @paid_through_date end |
#payment_method_token ⇒ Object (readonly)
Returns the value of attribute payment_method_token.
47 48 49 |
# File 'lib/braintree/subscription.rb', line 47 def payment_method_token @payment_method_token end |
#plan_id ⇒ Object (readonly)
Returns the value of attribute plan_id.
48 49 50 |
# File 'lib/braintree/subscription.rb', line 48 def plan_id @plan_id end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
49 50 51 |
# File 'lib/braintree/subscription.rb', line 49 def price @price end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
50 51 52 |
# File 'lib/braintree/subscription.rb', line 50 def status @status end |
#status_history ⇒ Object (readonly)
Returns the value of attribute status_history.
51 52 53 |
# File 'lib/braintree/subscription.rb', line 51 def status_history @status_history end |
#transactions ⇒ Object (readonly)
Returns the value of attribute transactions.
52 53 54 |
# File 'lib/braintree/subscription.rb', line 52 def transactions @transactions end |
#trial_duration ⇒ Object (readonly)
Returns the value of attribute trial_duration.
53 54 55 |
# File 'lib/braintree/subscription.rb', line 53 def trial_duration @trial_duration end |
#trial_duration_unit ⇒ Object (readonly)
Returns the value of attribute trial_duration_unit.
54 55 56 |
# File 'lib/braintree/subscription.rb', line 54 def trial_duration_unit @trial_duration_unit end |
#trial_period ⇒ Object (readonly)
Returns the value of attribute trial_period.
55 56 57 |
# File 'lib/braintree/subscription.rb', line 55 def trial_period @trial_period end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
56 57 58 |
# File 'lib/braintree/subscription.rb', line 56 def updated_at @updated_at end |
Class Method Details
._new(*args) ⇒ Object
117 118 119 |
# File 'lib/braintree/subscription.rb', line 117 def _new(*args) self.new(*args) end |
.cancel(*args) ⇒ Object
58 59 60 |
# File 'lib/braintree/subscription.rb', line 58 def self.cancel(*args) Configuration.gateway.subscription.cancel(*args) end |
.cancel!(*args) ⇒ Object
62 63 64 |
# File 'lib/braintree/subscription.rb', line 62 def self.cancel!(*args) Configuration.gateway.subscription.cancel!(*args) end |
.create(*args) ⇒ Object
66 67 68 |
# File 'lib/braintree/subscription.rb', line 66 def self.create(*args) Configuration.gateway.subscription.create(*args) end |
.create!(*args) ⇒ Object
70 71 72 |
# File 'lib/braintree/subscription.rb', line 70 def self.create!(*args) Configuration.gateway.subscription.create!(*args) end |
.find(*args) ⇒ Object
74 75 76 |
# File 'lib/braintree/subscription.rb', line 74 def self.find(*args) Configuration.gateway.subscription.find(*args) end |
.retry_charge(*args) ⇒ Object
78 79 80 |
# File 'lib/braintree/subscription.rb', line 78 def self.retry_charge(*args) Configuration.gateway.subscription.retry_charge(*args) end |
.search(&block) ⇒ Object
82 83 84 |
# File 'lib/braintree/subscription.rb', line 82 def self.search(&block) Configuration.gateway.subscription.search(&block) end |
.update(*args) ⇒ Object
86 87 88 |
# File 'lib/braintree/subscription.rb', line 86 def self.update(*args) Configuration.gateway.subscription.update(*args) end |
.update!(*args) ⇒ Object
90 91 92 |
# File 'lib/braintree/subscription.rb', line 90 def self.update!(*args) Configuration.gateway.subscription.update!(*args) end |
Instance Method Details
#never_expires? ⇒ Boolean
111 112 113 |
# File 'lib/braintree/subscription.rb', line 111 def never_expires? @never_expires end |