caren-api 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.8
1
+ 0.9.9
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.9.8"
8
+ s.version = "0.9.9"
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 = "2013-01-07"
12
+ s.date = "2013-01-16"
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 = [
@@ -73,6 +73,7 @@ Gem::Specification.new do |s|
73
73
  "spec/fixtures/caren_billable_category.xml",
74
74
  "spec/fixtures/caren_billables.xml",
75
75
  "spec/fixtures/caren_billables_search.xml",
76
+ "spec/fixtures/caren_cancelled_link.xml",
76
77
  "spec/fixtures/caren_care_provider.xml",
77
78
  "spec/fixtures/caren_care_provider_validation.xml",
78
79
  "spec/fixtures/caren_care_providers.xml",
data/lib/caren/link.rb CHANGED
@@ -22,6 +22,10 @@ class Caren::Link < Caren::Base
22
22
  from_xml session.get(self.resource_url(id))
23
23
  end
24
24
 
25
+ def cancel session
26
+ self.class.from_xml session.put(self.class.cancel_url(self.id), nil)
27
+ end
28
+
25
29
  def pdf session
26
30
  self.class.from_xml session.get(self.class.pdf_url(self.id))
27
31
  end
@@ -54,6 +58,10 @@ class Caren::Link < Caren::Base
54
58
  "#{resource_location}/#{id}/pdf"
55
59
  end
56
60
 
61
+ def self.cancel_url id=nil
62
+ "#{resource_location}/#{id}/cancel"
63
+ end
64
+
57
65
  def self.resource_location
58
66
  "/api/pro/links"
59
67
  end
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <link>
3
+ <created-at type="datetime">2011-10-10T10:38:49+02:00</created-at>
4
+ <updated-at type="datetime">2011-10-10T10:40:35+02:00</updated-at>
5
+ <id type="integer">1</id>
6
+ <care-provider-id type="integer">1</care-provider-id>
7
+ <person-id type="integer">3</person-id>
8
+ <person-name>Andre Foeken</person-name>
9
+ <person-photo>http://example.com/1.png</person-photo>
10
+ <external-id>1</external-id>
11
+ <status>cancelled</status>
12
+ </link>
data/spec/link_spec.rb CHANGED
@@ -23,17 +23,21 @@ describe "Link", "REST methods" do
23
23
  link = File.read("spec/fixtures/caren_link.xml")
24
24
  links = File.read("spec/fixtures/caren_links.xml")
25
25
  search = File.read("spec/fixtures/caren_links_search.xml")
26
+ cancelled_link = File.read("spec/fixtures/caren_cancelled_link.xml")
26
27
 
27
28
  link_url = Caren::Api.session.url_for(Caren::Link.resource_url(1))
28
29
  links_url = Caren::Api.session.url_for(Caren::Link.resource_url)
29
30
  search_url = Caren::Api.session.url_for("#{Caren::Link.resource_url}?key=external-id&value=1")
30
31
 
32
+ cancel_url = Caren::Api.session.url_for("#{Caren::Link.cancel_url(1)}")
33
+
31
34
  timestamp = DateTime.now.to_i
32
35
 
33
36
  FakeWeb.register_uri(:get, link_url, :body => link, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,link) )
34
37
  FakeWeb.register_uri(:get, links_url, :body => links, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,links) )
35
38
  FakeWeb.register_uri(:get, search_url, :body => search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,search) )
36
39
  FakeWeb.register_uri(:post, links_url, :status => 201, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp) )
40
+ FakeWeb.register_uri(:put, cancel_url, :body => cancelled_link, :status => 204, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,nil,cancelled_link) )
37
41
  end
38
42
 
39
43
  it "should be able to create a new link using the API" do
@@ -60,4 +64,10 @@ describe "Link", "REST methods" do
60
64
  links.should have(1).thing
61
65
  end
62
66
 
67
+ it "should be able to cancel a specific link using the API" do
68
+ links = Caren::Link.search(:external_id, 1, Caren::Api.session)
69
+ link = links.first.cancel(Caren::Api.session)
70
+ link.status.should == "cancelled"
71
+ end
72
+
63
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caren-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-07 00:00:00.000000000 Z
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -220,6 +220,7 @@ files:
220
220
  - spec/fixtures/caren_billable_category.xml
221
221
  - spec/fixtures/caren_billables.xml
222
222
  - spec/fixtures/caren_billables_search.xml
223
+ - spec/fixtures/caren_cancelled_link.xml
223
224
  - spec/fixtures/caren_care_provider.xml
224
225
  - spec/fixtures/caren_care_provider_validation.xml
225
226
  - spec/fixtures/caren_care_providers.xml
@@ -269,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
270
  version: '0'
270
271
  segments:
271
272
  - 0
272
- hash: 1698079609391487229
273
+ hash: -660240599541516947
273
274
  required_rubygems_version: !ruby/object:Gem::Requirement
274
275
  none: false
275
276
  requirements: