Class: Frulo::Subscriber
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#initialize, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Frulo::Resource
Class Method Details
.all ⇒ Object
51
52
53
54
|
# File 'lib/frulo.rb', line 51
def self.all
request = Frulo.get("/subscribers.xml")
request['subscribers'].collect{|data| Subscriber.new(data)}
end
|
.find(id) ⇒ Object
56
57
58
59
|
# File 'lib/frulo.rb', line 56
def self.find(id)
request = Frulo.get("/subscriber/#{id}.xml")
request.nil? ? nil : Subscriber.new(request['subscriber'])
end
|
Instance Method Details
#extend_subscription! ⇒ Object
65
66
67
68
|
# File 'lib/frulo.rb', line 65
def extend_subscription!
request = Frulo.put("/subscriber/#{self.id}/extend_subscription.xml")
request.code == 200 ? true : false
end
|
#id ⇒ Object
61
62
63
|
# File 'lib/frulo.rb', line 61
def id
subscriber['customer_id']
end
|
#trial? ⇒ Boolean
75
76
77
|
# File 'lib/frulo.rb', line 75
def trial?
subscription['state'].to_s == 'trial'
end
|
#update_plan(plan_id) ⇒ Object
70
71
72
73
|
# File 'lib/frulo.rb', line 70
def update_plan(plan_id)
request = Frulo.post("/subscriber/#{self.id}/update_plan.xml", :body => {:plan => {:id => plan_id }})
request.code == 200 ? true : false
end
|