Class: Upay::Plan
- Inherits:
-
Object
- Object
- Upay::Plan
- Defined in:
- lib/upay/plan.rb
Instance Method Summary collapse
- #accountId ⇒ Object
- #accountId=(accountId) ⇒ Object
- #additionalValues ⇒ Object
- #additionalValues=(additionalValues) ⇒ Object
-
#create ⇒ Object
Verb: POST Description: Returns: JSON.
- #currency ⇒ Object
- #currency=(currency) ⇒ Object
-
#delete ⇒ Object
Verb: DELETE Description: Returns: JSON.
- #description ⇒ Object
- #description=(description) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(args = {}) ⇒ Plan
constructor
A new instance of Plan.
- #interval ⇒ Object
- #interval=(interval) ⇒ Object
- #intervalCount ⇒ Object
- #intervalCount=(intervalCount) ⇒ Object
- #maxPaymentsAllowed ⇒ Object
- #maxPaymentsAllowed=(maxPaymentsAllowed) ⇒ Object
- #paymentAttempsDelay ⇒ Object
- #paymentAttempsDelay=(paymentAttempsDelay) ⇒ Object
- #planCode ⇒ Object
- #planCode=(planCode) ⇒ Object
-
#show ⇒ Object
Verb: POST Description: Returns: JSON.
- #to_hash ⇒ Object
- #trialDays ⇒ Object
- #trialDays=(trialDays) ⇒ Object
-
#update ⇒ Object
Verb: UPDATE Description: Returns: JSON.
- #valid? ⇒ Boolean
- #value ⇒ Object
- #value=(value) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Plan
Returns a new instance of Plan.
3 4 5 6 7 |
# File 'lib/upay/plan.rb', line 3 def initialize(args = {}) args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Method Details
#accountId ⇒ Object
9 |
# File 'lib/upay/plan.rb', line 9 def accountId; @accountId end |
#accountId=(accountId) ⇒ Object
10 11 12 |
# File 'lib/upay/plan.rb', line 10 def accountId=(accountId) @accountId = accountId end |
#additionalValues ⇒ Object
54 |
# File 'lib/upay/plan.rb', line 54 def additionalValues; @additionalValues end |
#additionalValues=(additionalValues) ⇒ Object
55 56 57 |
# File 'lib/upay/plan.rb', line 55 def additionalValues=(additionalValues) @additionalValues = additionalValues end |
#create ⇒ Object
Verb: POST Description: Returns: JSON
72 73 74 75 76 |
# File 'lib/upay/plan.rb', line 72 def create url = "rest/v4.3/plans" Requestor.new.post(url, self.to_hash) end |
#currency ⇒ Object
34 |
# File 'lib/upay/plan.rb', line 34 def currency; @currency end |
#currency=(currency) ⇒ Object
35 36 37 |
# File 'lib/upay/plan.rb', line 35 def currency=(currency) @currency = currency end |
#delete ⇒ Object
Verb: DELETE Description: Returns: JSON
107 108 109 110 |
# File 'lib/upay/plan.rb', line 107 def delete url = "rest/v4.3/plans/#{self.planCode}" Requestor.new.delete(url, self.to_hash) end |
#description ⇒ Object
19 |
# File 'lib/upay/plan.rb', line 19 def description; @description end |
#description=(description) ⇒ Object
20 21 22 |
# File 'lib/upay/plan.rb', line 20 def description=(description) @description = description end |
#find_by_name(name) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/upay/plan.rb', line 94 def find_by_name(name) url = "rest/v4.3/plans/" request = Requestor.new.get(url, {}) obtained_plan = {} request["subscriptionPlanList"].each do |plan| obtained_plan = plan if plan["planCode"] == name end obtained_plan end |
#interval ⇒ Object
24 |
# File 'lib/upay/plan.rb', line 24 def interval; @interval end |
#interval=(interval) ⇒ Object
25 26 27 |
# File 'lib/upay/plan.rb', line 25 def interval=(interval) @interval = interval end |
#intervalCount ⇒ Object
39 |
# File 'lib/upay/plan.rb', line 39 def intervalCount; @intervalCount end |
#intervalCount=(intervalCount) ⇒ Object
40 41 42 |
# File 'lib/upay/plan.rb', line 40 def intervalCount=(intervalCount) @intervalCount = intervalCount end |
#maxPaymentsAllowed ⇒ Object
44 |
# File 'lib/upay/plan.rb', line 44 def maxPaymentsAllowed; @maxPaymentsAllowed end |
#maxPaymentsAllowed=(maxPaymentsAllowed) ⇒ Object
45 46 47 |
# File 'lib/upay/plan.rb', line 45 def maxPaymentsAllowed=(maxPaymentsAllowed) @maxPaymentsAllowed = maxPaymentsAllowed end |
#paymentAttempsDelay ⇒ Object
49 |
# File 'lib/upay/plan.rb', line 49 def paymentAttempsDelay; @paymentAttempsDelay end |
#paymentAttempsDelay=(paymentAttempsDelay) ⇒ Object
50 51 52 |
# File 'lib/upay/plan.rb', line 50 def paymentAttempsDelay=(paymentAttempsDelay) @paymentAttempsDelay = paymentAttempsDelay end |
#planCode ⇒ Object
14 |
# File 'lib/upay/plan.rb', line 14 def planCode; @planCode end |
#planCode=(planCode) ⇒ Object
15 16 17 |
# File 'lib/upay/plan.rb', line 15 def planCode=(planCode) @planCode = planCode end |
#show ⇒ Object
Verb: POST Description: Returns: JSON
89 90 91 92 |
# File 'lib/upay/plan.rb', line 89 def show url = "rest/v4.3/plans/#{self.planCode}" Requestor.new.get(url, self.to_hash) end |
#to_hash ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/upay/plan.rb', line 112 def to_hash { :accountId => self.accountId || nil, :planCode => self.planCode, :description => self.description, :interval => self.interval, :intervalCount => self.intervalCount, :maxPaymentsAllowed => self.maxPaymentsAllowed || nil, :paymentAttemptsDelay => "1", :additionalValues => [ { :name => "PLAN_VALUE", :value => self.value, :currency => "COP" } ] } end |
#trialDays ⇒ Object
59 |
# File 'lib/upay/plan.rb', line 59 def trialDays; @trialDays end |
#trialDays=(trialDays) ⇒ Object
60 61 62 |
# File 'lib/upay/plan.rb', line 60 def trialDays=(trialDays) @trialDays = trialDays end |
#update ⇒ Object
Verb: UPDATE Description: Returns: JSON
81 82 83 84 |
# File 'lib/upay/plan.rb', line 81 def update url = "rest/v4.3/plans/#{self.planCode}" Requestor.new.put(url, self.to_hash) end |
#valid? ⇒ Boolean
64 65 66 67 |
# File 'lib/upay/plan.rb', line 64 def valid? validator = PlanValidator.new validator.valid?(self) end |
#value ⇒ Object
29 |
# File 'lib/upay/plan.rb', line 29 def value; @value end |
#value=(value) ⇒ Object
30 31 32 |
# File 'lib/upay/plan.rb', line 30 def value=(value) @value = value end |