Class: Caren::Store::Account
- Inherits:
-
Base
- Object
- Base
- Caren::Store::Account
show all
- Defined in:
- lib/caren/store/account.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #original_xml
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#as_xml, from_xml, hash_from_image, init_dependent_objects, #initialize, #node_root, resource_url, #resource_url, search_url, #to_xml, to_xml
Constructor Details
This class inherits a constructor from Caren::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Caren::Base
Class Method Details
.all(session) ⇒ Object
15
16
17
|
# File 'lib/caren/store/account.rb', line 15
def self.all session
from_xml session.get(self.resource_url)
end
|
.array_root ⇒ Object
27
28
29
|
# File 'lib/caren/store/account.rb', line 27
def self.array_root
:accounts
end
|
.find(id, session) ⇒ Object
11
12
13
|
# File 'lib/caren/store/account.rb', line 11
def self.find id, session
from_xml session.get(self.resource_url(id))
end
|
.keys ⇒ Object
3
4
5
6
7
8
9
|
# File 'lib/caren/store/account.rb', line 3
def self.keys
[:id, :balance, :person_id, :billable_timeline_id, ] + super
end
|
.node_root ⇒ Object
31
32
33
|
# File 'lib/caren/store/account.rb', line 31
def self.node_root
:account
end
|
.resource_location ⇒ Object
56
57
58
|
# File 'lib/caren/store/account.rb', line 56
def self.resource_location
"/api/pro/store/accounts"
end
|
Instance Method Details
#amount_xml(amount) ⇒ Object
35
36
37
38
|
# File 'lib/caren/store/account.rb', line 35
def amount_xml amount
builder = Builder::XmlMarkup.new
builder.tag! "amount", amount
end
|
#deposit_credits(amount, session) ⇒ Object
19
20
21
|
# File 'lib/caren/store/account.rb', line 19
def deposit_credits amount, session
self.class.from_xml session.post self.deposit_credits_url, amount_xml(amount)
end
|
#deposit_credits_url ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/caren/store/account.rb', line 40
def deposit_credits_url
if id
"/api/pro/store/accounts/#{id}/deposit_credits"
else
"/api/pro/people/#{person_id}/accounts/deposit_credits/#{billable_timeline_id}"
end
end
|
#withdraw_credits(amount, session) ⇒ Object
23
24
25
|
# File 'lib/caren/store/account.rb', line 23
def withdraw_credits amount, session
self.class.from_xml session.post self.withdraw_credits_url, amount_xml(amount)
end
|
#withdraw_credits_url ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/caren/store/account.rb', line 48
def withdraw_credits_url
if id
"/api/pro/store/accounts/#{id}/withdraw_credits"
else
"/api/pro/people/#{person_id}/accounts/withdraw_credits/#{billable_timeline_id}"
end
end
|