class Paymill::Subscription
Attributes
amount[RW]
canceled_at[R]
client[R]
currency[R]
end_of_period[R]
interval[R]
is_canceled[R]
is_deleted[R]
livemode[R]
mandate_reference[R]
name[R]
next_capture_at[R]
offer[RW]
payment[R]
period_of_validity[RW]
status[R]
temp_amount[R]
trial_end[RW]
trial_start[R]
Protected Class Methods
allowed_arguments()
click to toggle source
# File lib/paymill/models/subscription.rb, line 105 def self.allowed_arguments [:offer, :payment, :client, :amount, :currency, :interval, :name, :period_of_validity, :start_at, :mandate_reference] end
create_with?( incoming_arguments )
click to toggle source
Calls superclass method
Paymill::Base::create_with?
# File lib/paymill/models/subscription.rb, line 96 def self.create_with?( incoming_arguments ) raise ArgumentError unless incoming_arguments.include?( :offer ) || (mutual_excluded_arguments.last - incoming_arguments).empty? super( incoming_arguments - mutual_excluded_arguments.flatten ) end
mandatory_arguments()
click to toggle source
# File lib/paymill/models/subscription.rb, line 101 def self.mandatory_arguments [:payment] end
mutual_excluded_arguments()
click to toggle source
# File lib/paymill/models/subscription.rb, line 119 def self.mutual_excluded_arguments [[:offer], [:amount, :currency, :interval]] end
Public Instance Methods
cancel()
click to toggle source
# File lib/paymill/models/subscription.rb, line 87 def cancel() delete( remove: false ) end
currency=( currency )
click to toggle source
# File lib/paymill/models/subscription.rb, line 10 def currency=( currency ) @offer = nil @amount = nil @currency = currency end
interval=( interval )
click to toggle source
# File lib/paymill/models/subscription.rb, line 22 def interval=( interval ) @offer = nil @amount = nil @interval = interval end
limit( limit )
click to toggle source
# File lib/paymill/models/subscription.rb, line 68 def limit( limit ) @offer = nil @amount = nil @period_of_validity = limit update() end
name=( name )
click to toggle source
# File lib/paymill/models/subscription.rb, line 16 def name=( name ) @offer = nil @amount = nil @name = name end
pause()
click to toggle source
# File lib/paymill/models/subscription.rb, line 75 def pause() @offer = nil @amount = nil update( pause: true ) end
payment=( payment )
click to toggle source
# File lib/paymill/models/subscription.rb, line 28 def payment=( payment ) @offer = nil @amount = nil @payment = payment end
play()
click to toggle source
# File lib/paymill/models/subscription.rb, line 81 def play() @offer = nil @amount = nil update( pause: false ) end
remove()
click to toggle source
# File lib/paymill/models/subscription.rb, line 91 def remove() delete( remove: true ) end
stop_trial_period()
click to toggle source
# File lib/paymill/models/subscription.rb, line 54 def stop_trial_period() @offer = nil @amount = nil @trial_end = nil update( trial_end: false ) end
unlimit()
click to toggle source
# File lib/paymill/models/subscription.rb, line 61 def unlimit() @offer = nil @amount = nil @period_of_validity = 'remove' update() end
update_amount_once( amount )
click to toggle source
# File lib/paymill/models/subscription.rb, line 34 def update_amount_once( amount ) update_amount( amount, 0 ) end
update_amount_permanently( amount )
click to toggle source
# File lib/paymill/models/subscription.rb, line 38 def update_amount_permanently( amount ) update_amount( amount, 1 ) end
update_offer_with_refund( offer )
click to toggle source
# File lib/paymill/models/subscription.rb, line 46 def update_offer_with_refund( offer ) update_offer( offer, 1 ) end
update_offer_with_refund_and_capture_date( offer )
click to toggle source
# File lib/paymill/models/subscription.rb, line 50 def update_offer_with_refund_and_capture_date( offer ) update_offer( offer, 2 ) end
update_offer_without_changes( offer )
click to toggle source
# File lib/paymill/models/subscription.rb, line 42 def update_offer_without_changes( offer ) update_offer( offer, 0 ) end
Protected Instance Methods
parse_timestamps()
click to toggle source
Calls superclass method
Paymill::Base#parse_timestamps
# File lib/paymill/models/subscription.rb, line 109 def parse_timestamps @trial_end &&= Time.at( @trial_end ) @canceled_at &&= Time.at( @canceled_at ) @trial_start &&= Time.at( @trial_start) @canceled_at &&= Time.at( @canceled_at ) @end_of_period &&= Time.at( @end_of_period ) @next_capture_at &&= Time.at( @next_capture_at ) super end
Private Instance Methods
update_amount( amount, flag)
click to toggle source
# File lib/paymill/models/subscription.rb, line 124 def update_amount( amount, flag) raise ArgumentError( 'amount_change_type should be 0 or 1' ) unless [0, 1].include?( flag ) @offer = nil @amount = amount update( amount_change_type: flag ) end
update_offer( offer, flag )
click to toggle source
# File lib/paymill/models/subscription.rb, line 131 def update_offer( offer, flag ) raise ArgumentError( 'offer_change_type should be between 0 and 2' ) unless (0..2).include?( flag ) @currency = nil @name = nil @interval = nil @amount = nil @payment = nil @offer = offer update( offer_change_type: flag ) end