roqua-core-api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGY0OGZhYjhjOTE2ZDE2N2I0NTE5YmExNTBmMGYyOTBkNjVmM2E2Yg==
4
+ MTVmMjg5NjQ3MTUwZDgzZTA3ODBkNmRkMGQ5NGY4ZmI0Y2E5Y2Y3OQ==
5
5
  data.tar.gz: !binary |-
6
- MDA3NTBhMGQ5NzIzYTU5ODlkZDNlYjVmMTdiZjI5NzM3MjZmZGI2NQ==
6
+ M2I5NDA5OGI4MTBlYTQ1MTEyNzc5ZmZkMmU5NzY4MmRhYzhjMmRjYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjBiYTRhZjA0YWFlMzAzOTdhZmJhZmI2YTk1N2FmNzNhZDc1ZTA3MzM4ZGMw
10
- ZTZiNzg5NzllOTk1NjJiOTgzNDRjMTc0M2FlNTgxMDhlMDc2NGYxZmE5NDk3
11
- NDY2MzY2ZjkyODQ2ZDdhMDQ1YmQ3ZmRjZGEzYjIwYjE2M2ExOGE=
9
+ NWFiNjIwYzMzZWRjN2YxMjNmNTNlYjU1YmY3M2RhMTNmOGMyM2E2ZjA4Nzg4
10
+ OTA4YjM2MGRiMzRjZjllOTA1MGVmMTFiNTQ3MjE2Mjg5ZmZiNGFhNTZkZGMy
11
+ YjA0MTdmODEyZTZlZTljY2ZlNGFlZjc2N2M1MTc0ZmQ1NWNjYzY=
12
12
  data.tar.gz: !binary |-
13
- OWNiODRlZDFhOGQxNjdmNDU1MGMxZmUzNjM4ZDNlODNlNzBmYzk3YTliNzc1
14
- YmNiNDRiOTRkZjRiMTAyODZkMzA2NzE3MjQyMDA3NzRkMDBhMTJjNGIzMzJh
15
- MGU0ZjczM2RlNWE1NjQwMzFjNTRlZjc3NzU5YTg0YjRhNmQwMmQ=
13
+ ZDgyNGRjMmZlNzc2MTVhM2IzYTJkNjVjMmEyMjIyYjEyYjE1NzI2YjZiMmJk
14
+ YTQ4NDc0MWVmMWYxMDQwOWJlYTI3Mzc4YjljMTFhZWJlYmZiOTFjM2UxZjFi
15
+ ZTRjNjdjNzcwYjk2NzA3N2RmNTQ0YzAwYTI3NzRmOTAyODI3MWY=
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.0.4 / 2014-02-03
2
+
3
+ * Use object ids instead of objects in sessions
4
+
1
5
  ### 0.0.3 / 2014-02-03
2
6
 
3
7
  * Replace keys by UUIDs
@@ -6,12 +6,12 @@ module Roqua
6
6
  # but only on a anonymous base. It is not allowed to know who these dossiers
7
7
  # represent.
8
8
  class AppSession
9
- attr_reader :server
10
- attr_reader :key
9
+ attr_reader :server_url
10
+ attr_reader :app_id
11
11
 
12
- def initialize(key, server = ENV["CORE_URL"])
13
- @server = server
14
- @key = key
12
+ def initialize(app_id, server_url = ENV["CORE_URL"])
13
+ @server_url = server_url
14
+ @app_id = app_id
15
15
  end
16
16
 
17
17
  def create_organization(attributes)
@@ -20,29 +20,24 @@ module Roqua
20
20
  Models::Organization.new(response)
21
21
  end
22
22
 
23
- def organization_session(attributes)
24
- if attributes.is_a? Models::Organization
25
- organization = attributes
26
- else
27
- organization = create_organization(attributes)
28
- end
29
- OrganizationSession.new organization, key, server
23
+ def organization_session(organization_id)
24
+ OrganizationSession.new organization_id, app_id, server_url
30
25
  end
31
26
 
32
27
  private
33
28
 
34
29
  def post(url, params = {})
35
30
  # TODO: Handle authentication here
36
- HTTParty.post(server + base_url + url + ".json", body: params)
31
+ HTTParty.post(server_url + base_url + url + ".json", body: params)
37
32
  end
38
33
 
39
34
  def put(url, params = {})
40
35
  # TODO: Handle authentication here
41
- HTTParty.put(server + base_url + url + ".json", body: params)
36
+ HTTParty.put(server_url + base_url + url + ".json", body: params)
42
37
  end
43
38
 
44
39
  def base_url
45
- "/apps/#{key}"
40
+ "/apps/#{app_id}"
46
41
  end
47
42
  end
48
43
  end
@@ -2,11 +2,11 @@ module Roqua
2
2
  module CoreApi
3
3
  module Sessions
4
4
  class DossierSession < OrganizationSession
5
- attr_reader :dossier
5
+ attr_reader :dossier_id
6
6
 
7
- def initialize(dossier, organization, key, server = ENV["CORE_URL"])
8
- @dossier = dossier
9
- super(organization, key, server)
7
+ def initialize(dossier_id, organization_id, app_id, server_url = ENV["CORE_URL"])
8
+ @dossier_id = dossier_id
9
+ super(organization_id, app_id, server_url)
10
10
  end
11
11
 
12
12
  def start(attributes)
@@ -18,7 +18,7 @@ module Roqua
18
18
  private
19
19
 
20
20
  def base_url
21
- super + "/dossiers/#{dossier.id}"
21
+ super + "/dossiers/#{dossier_id}"
22
22
  end
23
23
  end
24
24
  end
@@ -2,11 +2,11 @@ module Roqua
2
2
  module CoreApi
3
3
  module Sessions
4
4
  class OrganizationSession < AppSession
5
- attr_reader :organization
5
+ attr_reader :organization_id
6
6
 
7
- def initialize(organization, key, server = ENV["CORE_URL"])
8
- @organization = organization
9
- super(key, server)
7
+ def initialize(organization_id, app_id, server_url = ENV["CORE_URL"])
8
+ @organization_id = organization_id
9
+ super(app_id, server_url)
10
10
  end
11
11
 
12
12
  def create_dossier(attributes)
@@ -15,19 +15,14 @@ module Roqua
15
15
  Models::Dossier.new(response)
16
16
  end
17
17
 
18
- def dossier_session(attributes)
19
- if attributes.is_a? Models::Dossier
20
- dossier = attributes
21
- else
22
- dossier = create_dossier(attributes)
23
- end
24
- DossierSession.new dossier, organization, key, server
18
+ def dossier_session(dossier_id)
19
+ DossierSession.new dossier_id, organization_id, app_id, server_url
25
20
  end
26
21
 
27
22
  private
28
23
 
29
24
  def base_url
30
- super + "/organizations/#{organization.id}"
25
+ super + "/organizations/#{organization_id}"
31
26
  end
32
27
  end
33
28
  end
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module CoreApi
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -7,24 +7,10 @@ module Roqua
7
7
  let(:session) { Fabricate :app_session }
8
8
 
9
9
  describe '#organization_session' do
10
- it 'creates a new organization when attributes are provided' do
11
- organization_attributes = double
12
- expect(session).to receive(:create_organization).with organization_attributes
13
- session.organization_session organization_attributes
14
- end
15
-
16
- it 'initializes an organization session with a newly created organization' do
17
- organization_attributes = double
18
- organization = double
19
- allow(session).to receive(:create_organization).with(organization_attributes).and_return organization
20
- expect(OrganizationSession).to receive(:new).with(organization, session.key, session.server)
21
- session.organization_session organization_attributes
22
- end
23
-
24
- it 'initializes an organization session with a given organization' do
25
- organization = Fabricate :organization
26
- expect(OrganizationSession).to receive(:new).with(organization, session.key, session.server)
27
- session.organization_session organization
10
+ it 'initializes an organization session with a given organization_id' do
11
+ organization_id = 'some_organization_id'
12
+ expect(OrganizationSession).to receive(:new).with(organization_id, session.app_id, session.server_url)
13
+ session.organization_session organization_id
28
14
  end
29
15
  end
30
16
  end
@@ -7,24 +7,11 @@ module Roqua
7
7
  let(:session) { Fabricate :organization_session }
8
8
 
9
9
  describe '#dossier_session' do
10
- it 'creates a new dossier when attributes are provided' do
11
- dossier_attributes = double
12
- expect(session).to receive(:create_dossier).with dossier_attributes
13
- session.dossier_session dossier_attributes
14
- end
15
-
16
- it 'initializes a dossier session with a newly created dossier' do
17
- dossier_attributes = double
18
- dossier = double
19
- allow(session).to receive(:create_dossier).with(dossier_attributes).and_return dossier
20
- expect(DossierSession).to receive(:new).with(dossier, session.organization, session.key, session.server)
21
- session.dossier_session dossier_attributes
22
- end
23
-
24
- it 'initializes an organization session with a given organization' do
25
- dossier = Fabricate :dossier
26
- expect(DossierSession).to receive(:new).with(dossier, session.organization, session.key, session.server)
27
- session.dossier_session dossier
10
+ it 'initializes a dossier session with a given organization' do
11
+ dossier_id = 'some_dossier_id'
12
+ expect(DossierSession).to receive(:new)
13
+ .with(dossier_id, session.organization_id, session.app_id, session.server_url)
14
+ session.dossier_session dossier_id
28
15
  end
29
16
  end
30
17
  end
metadata CHANGED
@@ -1,22 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- version_requirements: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - ~>
17
- - !ruby/object:Gem::Version
18
- version: 0.12.0
19
- prerelease: false
20
14
  name: httparty
21
15
  requirement: !ruby/object:Gem::Requirement
22
16
  requirements:
@@ -24,13 +18,13 @@ dependencies:
24
18
  - !ruby/object:Gem::Version
25
19
  version: 0.12.0
26
20
  type: :runtime
27
- - !ruby/object:Gem::Dependency
21
+ prerelease: false
28
22
  version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
24
  - - ~>
31
25
  - !ruby/object:Gem::Version
32
- version: '1.0'
33
- prerelease: false
26
+ version: 0.12.0
27
+ - !ruby/object:Gem::Dependency
34
28
  name: bundler
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
@@ -38,13 +32,13 @@ dependencies:
38
32
  - !ruby/object:Gem::Version
39
33
  version: '1.0'
40
34
  type: :development
41
- - !ruby/object:Gem::Dependency
35
+ prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - ~>
45
39
  - !ruby/object:Gem::Version
46
- version: '10.0'
47
- prerelease: false
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
48
42
  name: rake
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
@@ -52,13 +46,13 @@ dependencies:
52
46
  - !ruby/object:Gem::Version
53
47
  version: '10.0'
54
48
  type: :development
55
- - !ruby/object:Gem::Dependency
49
+ prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - ~>
59
53
  - !ruby/object:Gem::Version
60
- version: '0.8'
61
- prerelease: false
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
62
56
  name: yard
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
@@ -66,13 +60,13 @@ dependencies:
66
60
  - !ruby/object:Gem::Version
67
61
  version: '0.8'
68
62
  type: :development
69
- - !ruby/object:Gem::Dependency
63
+ prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - ~>
73
67
  - !ruby/object:Gem::Version
74
- version: 3.0.0.beta1
75
- prerelease: false
68
+ version: '0.8'
69
+ - !ruby/object:Gem::Dependency
76
70
  name: rspec
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
@@ -80,13 +74,13 @@ dependencies:
80
74
  - !ruby/object:Gem::Version
81
75
  version: 3.0.0.beta1
82
76
  type: :development
83
- - !ruby/object:Gem::Dependency
77
+ prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - ~>
87
81
  - !ruby/object:Gem::Version
88
- version: 2.8.0
89
- prerelease: false
82
+ version: 3.0.0.beta1
83
+ - !ruby/object:Gem::Dependency
90
84
  name: vcr
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
@@ -94,13 +88,13 @@ dependencies:
94
88
  - !ruby/object:Gem::Version
95
89
  version: 2.8.0
96
90
  type: :development
97
- - !ruby/object:Gem::Dependency
91
+ prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - ~>
101
95
  - !ruby/object:Gem::Version
102
- version: 1.17.1
103
- prerelease: false
96
+ version: 2.8.0
97
+ - !ruby/object:Gem::Dependency
104
98
  name: webmock
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
@@ -108,13 +102,13 @@ dependencies:
108
102
  - !ruby/object:Gem::Version
109
103
  version: 1.17.1
110
104
  type: :development
111
- - !ruby/object:Gem::Dependency
105
+ prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
108
  - - ~>
115
109
  - !ruby/object:Gem::Version
116
- version: 2.9.6
117
- prerelease: false
110
+ version: 1.17.1
111
+ - !ruby/object:Gem::Dependency
118
112
  name: fabrication
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
@@ -122,6 +116,12 @@ dependencies:
122
116
  - !ruby/object:Gem::Version
123
117
  version: 2.9.6
124
118
  type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 2.9.6
125
125
  description: Provides authenticated access to Core
126
126
  email: marten@veldthuis.com
127
127
  executables: []
@@ -154,11 +154,6 @@ files:
154
154
  - spec/fabricators/dossier_fabricator.rb
155
155
  - spec/fabricators/organization_fabricator.rb
156
156
  - spec/fabricators/organization_session_fabricator.rb
157
- - spec/fixtures/dossiers/can_be_created.yml
158
- - spec/fixtures/dossiers/can_be_started.yml
159
- - spec/fixtures/organizations/can_be_created.yml
160
- - spec/integration/dossiers_spec.rb
161
- - spec/integration/organizations_spec.rb
162
157
  - spec/lib/roqua/core_api/sessions/app_session_spec.rb
163
158
  - spec/lib/roqua/core_api/sessions/organization_session_spec.rb
164
159
  - spec/spec_helper.rb
@@ -192,11 +187,6 @@ test_files:
192
187
  - spec/fabricators/dossier_fabricator.rb
193
188
  - spec/fabricators/organization_fabricator.rb
194
189
  - spec/fabricators/organization_session_fabricator.rb
195
- - spec/fixtures/dossiers/can_be_created.yml
196
- - spec/fixtures/dossiers/can_be_started.yml
197
- - spec/fixtures/organizations/can_be_created.yml
198
- - spec/integration/dossiers_spec.rb
199
- - spec/integration/organizations_spec.rb
200
190
  - spec/lib/roqua/core_api/sessions/app_session_spec.rb
201
191
  - spec/lib/roqua/core_api/sessions/organization_session_spec.rb
202
192
  - spec/spec_helper.rb
@@ -1,81 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: http://core.dev/apps/development/organizations.json
6
- body:
7
- encoding: US-ASCII
8
- string: organization[name]=some_name
9
- headers: {}
10
- response:
11
- status:
12
- code: 201
13
- message: Created
14
- headers:
15
- X-Frame-Options:
16
- - SAMEORIGIN
17
- X-Xss-Protection:
18
- - 1; mode=block
19
- X-Content-Type-Options:
20
- - nosniff
21
- X-Ua-Compatible:
22
- - chrome=1
23
- Location:
24
- - http://core.dev/apps/1/organizations/2
25
- Content-Type:
26
- - application/json; charset=utf-8
27
- Etag:
28
- - ! '"ee236155ad2af3b9c115a6dbd3210082"'
29
- Cache-Control:
30
- - max-age=0, private, must-revalidate
31
- X-Request-Id:
32
- - 9ac2b602-479f-4c61-96c4-f5ba48aa8e5f
33
- X-Runtime:
34
- - '1.107816'
35
- Connection:
36
- - close
37
- body:
38
- encoding: US-ASCII
39
- string: ! '{"id":2,"name":"some_name","created_at":"2014-01-29T21:22:11.081Z","updated_at":"2014-01-29T21:22:11.081Z","app_id":1}'
40
- http_version:
41
- recorded_at: Wed, 29 Jan 2014 21:22:11 GMT
42
- - request:
43
- method: post
44
- uri: http://core.dev/apps/development/organizations/some_id/dossiers.json
45
- body:
46
- encoding: US-ASCII
47
- string: dossier[id]=some_id
48
- headers: {}
49
- response:
50
- status:
51
- code: 201
52
- message: Created
53
- headers:
54
- X-Frame-Options:
55
- - SAMEORIGIN
56
- X-Xss-Protection:
57
- - 1; mode=block
58
- X-Content-Type-Options:
59
- - nosniff
60
- X-Ua-Compatible:
61
- - chrome=1
62
- Location:
63
- - http://core.dev/apps/1/organizations/2/dossiers/1
64
- Content-Type:
65
- - application/json; charset=utf-8
66
- Etag:
67
- - ! '"958c0debedcabd980620e4c7a1299600"'
68
- Cache-Control:
69
- - max-age=0, private, must-revalidate
70
- X-Request-Id:
71
- - 4bd305b7-cd21-43c9-9724-6943e6f1956d
72
- X-Runtime:
73
- - '0.055516'
74
- Connection:
75
- - close
76
- body:
77
- encoding: US-ASCII
78
- string: ! '{"id":1,"identifier":"fca8af4de679dc32ffc9412862397291","organization_id":2}'
79
- http_version:
80
- recorded_at: Wed, 29 Jan 2014 21:22:11 GMT
81
- recorded_with: VCR 2.8.0
@@ -1,36 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: put
5
- uri: http://core.dev/apps/development/organizations/some_id/dossiers/1/start.json
6
- body:
7
- encoding: US-ASCII
8
- string: attributes[protocols][]=some_protocol
9
- headers: {}
10
- response:
11
- status:
12
- code: 204
13
- message: No Content
14
- headers:
15
- X-Frame-Options:
16
- - SAMEORIGIN
17
- X-Xss-Protection:
18
- - 1; mode=block
19
- X-Content-Type-Options:
20
- - nosniff
21
- X-Ua-Compatible:
22
- - chrome=1
23
- Cache-Control:
24
- - no-cache
25
- X-Request-Id:
26
- - b4cdc7f0-ec00-4db0-bf28-a3eb0900df98
27
- X-Runtime:
28
- - '0.007831'
29
- Connection:
30
- - close
31
- body:
32
- encoding: US-ASCII
33
- string: ''
34
- http_version:
35
- recorded_at: Thu, 30 Jan 2014 19:40:59 GMT
36
- recorded_with: VCR 2.8.0
@@ -1,50 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: http://core.dev/apps/development/organizations.json
6
- body:
7
- encoding: UTF-8
8
- string: organization[name]=Foo%20Bar
9
- headers: {}
10
- response:
11
- status:
12
- code: 201
13
- message: Created
14
- headers:
15
- Date:
16
- - Tue, 28 Jan 2014 14:04:59 GMT
17
- Server:
18
- - Apache/2.2.24 (Unix) DAV/2 Phusion_Passenger/4.0.35 mod_ssl/2.2.24 OpenSSL/0.9.8y
19
- X-Frame-Options:
20
- - SAMEORIGIN
21
- X-Xss-Protection:
22
- - 1; mode=block
23
- X-Content-Type-Options:
24
- - nosniff
25
- X-Ua-Compatible:
26
- - chrome=1
27
- Etag:
28
- - "\"304439f64ca0ad5b9042da7c93ee58d2\""
29
- Cache-Control:
30
- - max-age=0, private, must-revalidate
31
- X-Request-Id:
32
- - a3f0d5c5-6118-4277-8bc3-f88344a5e8da
33
- X-Runtime:
34
- - '0.009867'
35
- X-Powered-By:
36
- - Phusion Passenger 4.0.35
37
- Location:
38
- - http://core.dev/apps/1/organizations/5
39
- Status:
40
- - 201 Created
41
- Transfer-Encoding:
42
- - chunked
43
- Content-Type:
44
- - application/json; charset=utf-8
45
- body:
46
- encoding: UTF-8
47
- string: "{\"id\":5,\"name\":\"Foo Bar\",\"created_at\":\"2014-01-28T14:04:59.261Z\",\"updated_at\":\"2014-01-28T14:04:59.261Z\",\"app_id\":1}"
48
- http_version:
49
- recorded_at: Tue, 28 Jan 2014 14:04:59 GMT
50
- recorded_with: VCR 2.8.0
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'dossiers' do
4
-
5
- let(:organization) { Fabricate :organization }
6
- let(:session) { Sessions::OrganizationSession.new(organization, 'development', 'http://core.dev') }
7
-
8
- it 'can be created', :vcr do
9
- dossier = session.create_dossier({})
10
- expect(dossier.id).to eq(1)
11
- end
12
-
13
- it 'can be started', :vcr do
14
- dossier = Fabricate :dossier
15
- dossier_session = Sessions::DossierSession.new(dossier, organization, 'development', 'http://core.dev')
16
- expect { dossier_session.start(protocols: ['some_protocol']) }.to_not raise_error
17
- end
18
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'organizations' do
4
- let(:session) { Sessions::AppSession.new('development', 'http://core.dev') }
5
-
6
- it 'can be created', :vcr do
7
- organization = session.create_organization(name: 'Foo Bar')
8
- expect(organization.name).to eq("Foo Bar")
9
- end
10
- end