caren-api 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.9
1
+ 0.6.10
data/caren-api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "caren-api"
8
- s.version = "0.6.9"
8
+ s.version = "0.6.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andre Foeken"]
12
- s.date = "2012-06-07"
12
+ s.date = "2012-06-13"
13
13
  s.description = "You can use this gem as inspiration of the base of your connections with Caren."
14
14
  s.email = "andre.foeken@nedap.com"
15
15
  s.extra_rdoc_files = [
@@ -40,6 +40,8 @@ Gem::Specification.new do |s|
40
40
  "lib/caren/event_slot_container.rb",
41
41
  "lib/caren/external_message.rb",
42
42
  "lib/caren/link.rb",
43
+ "lib/caren/store/account.rb",
44
+ "lib/caren/store/account_entry.rb",
43
45
  "lib/caren/store/address.rb",
44
46
  "lib/caren/store/billable.rb",
45
47
  "lib/caren/store/billable_category.rb",
data/lib/caren/event.rb CHANGED
@@ -23,14 +23,6 @@ class Caren::Event < Caren::Base
23
23
  ] + super
24
24
  end
25
25
 
26
- def reserve_credits session
27
- session.post reserve_credits_url, self.to_xml
28
- end
29
-
30
- def release_credits session
31
- session.post release_credits_url, self.to_xml
32
- end
33
-
34
26
  def self.array_root
35
27
  :events
36
28
  end
@@ -39,14 +31,4 @@ class Caren::Event < Caren::Base
39
31
  :event
40
32
  end
41
33
 
42
- private
43
-
44
- def reserve_credits_url
45
- "/api/pro/store/credits/reserve"
46
- end
47
-
48
- def release_credits_url
49
- "/api/pro/store/credits/release"
50
- end
51
-
52
34
  end
@@ -0,0 +1,68 @@
1
+ class Caren::Store::Account < Caren::Base
2
+
3
+ def self.keys
4
+ [:id, # Integer (Caren id)
5
+ :balance, # Integer (Balance in credits, unit depends on billable)
6
+ :person_id, # Integer (Caren person id)
7
+ :billable_timeline_id, # Integer
8
+ ] + super
9
+ end
10
+
11
+ def self.find id, session
12
+ from_xml session.get(self.resource_url(id))
13
+ end
14
+
15
+ def self.all session
16
+ from_xml session.get(self.resource_url)
17
+ end
18
+
19
+ def deposit_credits amount, session
20
+ session.post self.class.deposit_credits_url(self.id), amount_xml(amount)
21
+ end
22
+
23
+ def withdraw_credits amount, session
24
+ session.post self.class.withdraw_credits_url(self.id), amount_xml(amount)
25
+ end
26
+
27
+ def self.reserve_credits caren_event, session
28
+ session.post reserve_credits_url, caren_event.to_xml
29
+ end
30
+
31
+ def self.release_credits caren_event, session
32
+ session.post release_credits_url, caren_event.to_xml
33
+ end
34
+
35
+ def self.array_root
36
+ :accounts
37
+ end
38
+
39
+ def self.node_root
40
+ :account
41
+ end
42
+
43
+ def amount_xml amount
44
+ builder = Builder::XmlMarkup.new
45
+ builder.tag! "amount", amount
46
+ end
47
+
48
+ def self.deposit_credits_url id
49
+ "/api/pro/store/accounts/#{id}/deposit_credits"
50
+ end
51
+
52
+ def self.withdraw_credits_url id
53
+ "/api/pro/store/accounts/#{id}/withdraw_credits"
54
+ end
55
+
56
+ def self.reserve_credits_url
57
+ "/api/pro/store/accounts/reserve_credits"
58
+ end
59
+
60
+ def self.release_credits_url
61
+ "/api/pro/store/accounts/release_credits"
62
+ end
63
+
64
+ def self.resource_location
65
+ "/api/pro/store/accounts"
66
+ end
67
+
68
+ end
@@ -0,0 +1,43 @@
1
+ class Caren::Store::AccountEntry < Caren::Base
2
+
3
+ def self.keys
4
+ [:id, # Integer (Caren id)
5
+ :account_id, # Integer (Caren account id)
6
+ :amount, # Integer (Delta amount in credits, unit depends on account billable)
7
+ :reserved, # Boolean (Is this a reservation)
8
+ :source_id, # Integer (Source of the account entry, Caren object id)
9
+ :source_type # String (Source of the account entry, Caren object class string)
10
+ ] + super
11
+ end
12
+
13
+ def self.find account_id, id, session
14
+ from_xml session.get(self.resource_url(account_id,id))
15
+ end
16
+
17
+ def self.all account_id, session
18
+ from_xml session.get(self.resource_url(account_id))
19
+ end
20
+
21
+ def self.array_root
22
+ :account_entries
23
+ end
24
+
25
+ def self.node_root
26
+ :account_entry
27
+ end
28
+
29
+ def self.resource_location
30
+ "/api/pro/store/account/%i/account_entries"
31
+ end
32
+
33
+ private
34
+
35
+ def resource_url account_id, id=nil
36
+ self.class.resource_url(account_id,id)
37
+ end
38
+
39
+ def self.resource_url account_id, id=nil
40
+ "#{self.resource_location % account_id}#{id}"
41
+ end
42
+
43
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caren-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 9
10
- version: 0.6.9
9
+ - 10
10
+ version: 0.6.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andre Foeken
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-07 00:00:00 Z
18
+ date: 2012-06-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -178,6 +178,8 @@ files:
178
178
  - lib/caren/event_slot_container.rb
179
179
  - lib/caren/external_message.rb
180
180
  - lib/caren/link.rb
181
+ - lib/caren/store/account.rb
182
+ - lib/caren/store/account_entry.rb
181
183
  - lib/caren/store/address.rb
182
184
  - lib/caren/store/billable.rb
183
185
  - lib/caren/store/billable_category.rb