Class: Upay::Subscription
- Inherits:
-
Object
- Object
- Upay::Subscription
- Defined in:
- lib/upay/subscription.rb
Instance Method Summary collapse
-
#create ⇒ Object
Verb: POST Description: Returns: JSON.
- #creditCardToken ⇒ Object
- #creditCardToken=(creditCardToken) ⇒ Object
- #currentPeriodEnd ⇒ Object
- #currentPeriodEnd=(currentPeriodEnd) ⇒ Object
- #currentPeriodStart ⇒ Object
- #currentPeriodStart=(currentPeriodStart) ⇒ Object
- #customer ⇒ Object
- #customer=(customer) ⇒ Object
-
#delete ⇒ Object
Verb: DELETE Description: Returns: JSON.
- #id ⇒ Object
- #id=(id) ⇒ Object
-
#initialize(args = {}) ⇒ Subscription
constructor
A new instance of Subscription.
- #installments ⇒ Object
- #installments=(installments) ⇒ Object
- #plan ⇒ Object
- #plan=(plan) ⇒ Object
- #quantity ⇒ Object
- #quantity=(quantity) ⇒ Object
-
#show ⇒ Object
Verb: POST Description: Returns: JSON.
- #to_hash ⇒ Object
- #trialDays ⇒ Object
- #trialDays=(trialDays) ⇒ Object
-
#update ⇒ Object
Verb: UPDATE Description: Returns: JSON.
Constructor Details
#initialize(args = {}) ⇒ Subscription
Returns a new instance of Subscription.
3 4 5 6 7 |
# File 'lib/upay/subscription.rb', line 3 def initialize(args = {}) args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Method Details
#create ⇒ Object
Verb: POST Description: Returns: JSON
57 58 59 60 61 62 63 64 |
# File 'lib/upay/subscription.rb', line 57 def create url = "rest/v4.3/subscriptions/" hash_for_create = self.to_hash response = Requestor.new.post(url, hash_for_create) puts response self.id = response["id"] self end |
#creditCardToken ⇒ Object
49 |
# File 'lib/upay/subscription.rb', line 49 def creditCardToken; @creditCardToken end |
#creditCardToken=(creditCardToken) ⇒ Object
50 51 52 |
# File 'lib/upay/subscription.rb', line 50 def creditCardToken=(creditCardToken); @creditCardToken = creditCardToken end |
#currentPeriodEnd ⇒ Object
44 |
# File 'lib/upay/subscription.rb', line 44 def currentPeriodEnd; @currentPeriodEnd end |
#currentPeriodEnd=(currentPeriodEnd) ⇒ Object
45 46 47 |
# File 'lib/upay/subscription.rb', line 45 def currentPeriodEnd=(currentPeriodEnd); @currentPeriodEnd = currentPeriodEnd end |
#currentPeriodStart ⇒ Object
39 |
# File 'lib/upay/subscription.rb', line 39 def currentPeriodStart; @currentPeriodStart end |
#currentPeriodStart=(currentPeriodStart) ⇒ Object
40 41 42 |
# File 'lib/upay/subscription.rb', line 40 def currentPeriodStart=(currentPeriodStart); @currentPeriodStart = currentPeriodStart end |
#customer ⇒ Object
19 |
# File 'lib/upay/subscription.rb', line 19 def customer; @customer end |
#customer=(customer) ⇒ Object
20 21 22 |
# File 'lib/upay/subscription.rb', line 20 def customer=(customer); @customer = customer end |
#delete ⇒ Object
Verb: DELETE Description: Returns: JSON
85 86 87 88 |
# File 'lib/upay/subscription.rb', line 85 def delete url = "rest/v4.3/subscriptions/#{self.id}" Requestor.new.delete(url, {}) end |
#id ⇒ Object
9 |
# File 'lib/upay/subscription.rb', line 9 def id; @id end |
#id=(id) ⇒ Object
10 11 12 |
# File 'lib/upay/subscription.rb', line 10 def id=(id); @id = id end |
#installments ⇒ Object
34 |
# File 'lib/upay/subscription.rb', line 34 def installments; @installments end |
#installments=(installments) ⇒ Object
35 36 37 |
# File 'lib/upay/subscription.rb', line 35 def installments=(installments); @installments = installments end |
#plan ⇒ Object
14 |
# File 'lib/upay/subscription.rb', line 14 def plan; @plan end |
#plan=(plan) ⇒ Object
15 16 17 |
# File 'lib/upay/subscription.rb', line 15 def plan=(plan); @plan = plan end |
#quantity ⇒ Object
29 |
# File 'lib/upay/subscription.rb', line 29 def quantity; @quantity end |
#quantity=(quantity) ⇒ Object
30 31 32 |
# File 'lib/upay/subscription.rb', line 30 def quantity=(quantity); @quantity = quantity end |
#show ⇒ Object
Verb: POST Description: Returns: JSON
77 78 79 80 |
# File 'lib/upay/subscription.rb', line 77 def show url = "rest/v4.3/subscriptions/#{self.id}" Requestor.new.get(url, {}) end |
#to_hash ⇒ Object
90 91 92 |
# File 'lib/upay/subscription.rb', line 90 def to_hash self.instance_variables.each_with_object({}) { |var,hash| hash[var.to_s.delete("@")] = self.instance_variable_get(var)} end |
#trialDays ⇒ Object
24 |
# File 'lib/upay/subscription.rb', line 24 def trialDays; @trialDays end |
#trialDays=(trialDays) ⇒ Object
25 26 27 |
# File 'lib/upay/subscription.rb', line 25 def trialDays=(trialDays); @trialDays = trialDays end |
#update ⇒ Object
Verb: UPDATE Description: Returns: JSON
69 70 71 72 |
# File 'lib/upay/subscription.rb', line 69 def update url = "/rest/v4.3/subscriptions/{self.id}" Requestor.new.put(url, hash_for_create) end |