roqua-core-api 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/roqua/core_api/sessions/dossier_group_session.rb +2 -1
- data/lib/roqua/core_api/sessions/oauth_session.rb +47 -0
- data/lib/roqua/core_api/sessions/organization_session.rb +5 -0
- data/lib/roqua/core_api/sessions.rb +9 -0
- data/lib/roqua/core_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67ff3e48f5919f5069d74dd9b15526758a4accd2
|
4
|
+
data.tar.gz: d913be241b4f1223a437860b2766acedf20a7020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ebb58cb3b1667bab8082a700bb13a9d5b426ecbba13005d56eb126fce4a252833d83618107102af06fde6f395db11dca4c4a5f63d2f84ac6b504b93be077490
|
7
|
+
data.tar.gz: 82dbfd9211e89bb6570701db18253c5fa44362917d400d3b2132ee886b264ef8f04f97393115dcda87fc1d7ddc71a00a725febfbf5a8dda8d71931971a50c326
|
@@ -9,8 +9,9 @@ module Roqua
|
|
9
9
|
super(organization_id, server_url)
|
10
10
|
end
|
11
11
|
|
12
|
+
# create_dossier(.. , person: { email: 'user@domain.com' })
|
12
13
|
def create_dossier(attributes)
|
13
|
-
response = post "/dossiers", dossier: attributes
|
14
|
+
response = post "/dossiers", person: attributes.delete(:person), dossier: attributes
|
14
15
|
fail response.inspect unless response.code == 201
|
15
16
|
Models::Dossier.new(response)
|
16
17
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Roqua
|
2
|
+
module CoreApi
|
3
|
+
module Sessions
|
4
|
+
class OAuthSession
|
5
|
+
attr_reader :access_token
|
6
|
+
attr_reader :server_url
|
7
|
+
|
8
|
+
def initialize(access_token, server_url = ENV["CORE_URL"])
|
9
|
+
@access_token = access_token
|
10
|
+
@server_url = server_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def me
|
14
|
+
response = get('/me')
|
15
|
+
fail response.inspect unless response.code == 200
|
16
|
+
response["me"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(url, params = {})
|
20
|
+
HTTParty.get(full_url_for(url), headers: headers, query: params)
|
21
|
+
end
|
22
|
+
|
23
|
+
def post(url, params = {})
|
24
|
+
HTTParty.post(full_url_for(url), headers: headers, body: params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def put(url, params = {})
|
28
|
+
HTTParty.put(full_url_for(url), headers: headers, body: params)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def full_url_for(url)
|
34
|
+
server_url + base_url + url + ".json"
|
35
|
+
end
|
36
|
+
|
37
|
+
def base_url
|
38
|
+
"/api/v1"
|
39
|
+
end
|
40
|
+
|
41
|
+
def headers
|
42
|
+
{"Authorization" => "Bearer #{access_token}"}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -26,6 +26,11 @@ module Roqua
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
+
def get(url, params = {})
|
30
|
+
# TODO: Handle authentication here
|
31
|
+
HTTParty.get(server_url + base_url + url + ".json", query: params)
|
32
|
+
end
|
33
|
+
|
29
34
|
def post(url, params = {})
|
30
35
|
# TODO: Handle authentication here
|
31
36
|
HTTParty.post(server_url + base_url + url + ".json", body: params)
|
@@ -1,4 +1,13 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'roqua/core_api/sessions/oauth_session'
|
2
3
|
require 'roqua/core_api/sessions/organization_session'
|
3
4
|
require 'roqua/core_api/sessions/dossier_group_session'
|
4
5
|
require 'roqua/core_api/sessions/dossier_session'
|
6
|
+
|
7
|
+
module Roqua
|
8
|
+
module CoreApi
|
9
|
+
def self.oauth_session(access_token)
|
10
|
+
Sessions::OAuthSession.new(access_token)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roqua-core-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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-
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/roqua/core_api/sessions.rb
|
148
148
|
- lib/roqua/core_api/sessions/dossier_group_session.rb
|
149
149
|
- lib/roqua/core_api/sessions/dossier_session.rb
|
150
|
+
- lib/roqua/core_api/sessions/oauth_session.rb
|
150
151
|
- lib/roqua/core_api/sessions/organization_session.rb
|
151
152
|
- lib/roqua/core_api/version.rb
|
152
153
|
- spec/core_api_spec.rb
|