roqua-core-api 0.0.9 → 0.0.10
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 +5 -13
- data/.gitignore +2 -1
- data/ChangeLog.md +7 -1
- data/Gemfile +2 -1
- data/Guardfile +1 -1
- data/core_api.gemspec +2 -3
- data/lib/roqua/core_api/create_dossier.rb +17 -0
- data/lib/roqua/core_api/create_dossier_group.rb +15 -0
- data/lib/roqua/core_api/me.rb +12 -0
- data/lib/roqua/core_api/models.rb +1 -0
- data/lib/roqua/core_api/send_email_to.rb +23 -0
- data/lib/roqua/core_api/send_invite_email.rb +12 -0
- data/lib/roqua/core_api/sessions/auth_session.rb +57 -0
- data/lib/roqua/core_api/sessions/basic_auth_session.rb +22 -0
- data/lib/roqua/core_api/sessions/oauth_session.rb +4 -31
- data/lib/roqua/core_api/sessions.rb +8 -5
- data/lib/roqua/core_api/version.rb +1 -1
- data/lib/roqua/core_api.rb +7 -1
- data/lib/roqua/omniauth/strategies/doorkeeper.rb +1 -4
- data/spec/fabricators/auth_session_fabricator.rb +3 -0
- data/spec/fabricators/basic_auth_session_fabricator.rb +7 -0
- data/spec/fabricators/oauth_session_fabricator.rb +5 -0
- data/spec/lib/roqua/core_api/create_dossier_group_spec.rb +23 -0
- data/spec/lib/roqua/core_api/create_dossier_spec.rb +26 -0
- data/spec/lib/roqua/core_api/me_spec.rb +15 -0
- data/spec/lib/roqua/core_api/send_email_to_spec.rb +26 -0
- data/spec/lib/roqua/core_api/send_invite_email_spec.rb +10 -0
- data/spec/lib/roqua/core_api/sessions/auth_session_spec.rb +45 -0
- data/spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb +51 -0
- data/spec/lib/roqua/core_api/sessions/oauth_session_spec.rb +43 -0
- data/spec/spec_helper.rb +2 -9
- metadata +63 -63
- data/lib/roqua/core_api/sessions/dossier_group_session.rb +0 -31
- data/lib/roqua/core_api/sessions/dossier_session.rb +0 -25
- data/lib/roqua/core_api/sessions/organization_session.rb +0 -69
- data/spec/fabricators/dossier_fabricator.rb +0 -3
- data/spec/fabricators/dossier_group_fabricator.rb +0 -3
- data/spec/fabricators/dossier_group_session_fabricator.rb +0 -5
- data/spec/fabricators/organization_session_fabricator.rb +0 -3
- data/spec/lib/roqua/core_api/sessions/dossier_group_session_spec.rb +0 -21
- data/spec/lib/roqua/core_api/sessions/organization_session_spec.rb +0 -20
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OTE1MTMzMWRjY2UyOTYxMThlMTgyMzRjNDhkYmM0MDI3ZTA3OGRlZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16242225e679868d3490798412d8585f0e22b666
|
4
|
+
data.tar.gz: b618a7499c9be7d03b55e470ee8780c23776054d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YzFlZTBlYzIzMWM5Y2Y3OGM0ZTVhMTBlYzU5NjE5NzE1OGQ3NDYwYzA1NTE0
|
11
|
-
MDg1OGQ1Y2RlMTMzNDE0ZDUzMWEzNGE0NDQzMGFjYjI3ZjgxODM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTMzOGZjMjI4MjA0OTI3OTgyNDljMjI5ZWZjMzFkYjQ0N2RkMTdiZTQ5ODE5
|
14
|
-
MzliZDM0ZWYyZTdhZTg3NjMyMDA3OWE2ZDU5OGZmNzI2MTViZjc0NDc1YTMy
|
15
|
-
YjY5Njg3MDE5MTk4YTIzOTc4MDU0MjA4MzQwMzI3YTA5NTdiYjk=
|
6
|
+
metadata.gz: 3ecd95b03e4473ddf07458b71b91b36b09ac3ff61699a4caaaa80470d6cac3f5f063764628659cea451997612b43897bf34bcf578cdcde9e3d3dde472be7f118
|
7
|
+
data.tar.gz: d5dc85d752535893e40fd4881a7e10c40d311273c5bc6bc7ba5c837193feda0affeac51868fe090ac11760f83319fc01fc89ce244bef789ce327abc730ec2c43
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 0.0.10 / 2014-03-07
|
2
|
+
|
3
|
+
* Remove organization session, dossier_group session and dossier session
|
4
|
+
* Implement all apis as ActiveInteraction use cases
|
5
|
+
* Authenticate through oauth and basic auth sessions
|
6
|
+
|
1
7
|
### 0.0.9 / 2014-02-27
|
2
8
|
|
3
9
|
* Add core-api omniauth rails config
|
@@ -6,7 +12,7 @@
|
|
6
12
|
|
7
13
|
* Added logout_url method
|
8
14
|
|
9
|
-
###
|
15
|
+
### 0.0.6
|
10
16
|
|
11
17
|
* Removed start api
|
12
18
|
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
guard :rspec, failed_mode: 'none', all_after_pass: false, all_on_start: false do
|
1
|
+
guard :rspec, failed_mode: 'none', all_after_pass: false, all_on_start: false, cmd: 'bundle exec rspec --format Fuubar --colour' do
|
2
2
|
watch(%r{^spec/.+_spec\.rb$})
|
3
3
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
4
|
end
|
data/core_api.gemspec
CHANGED
@@ -17,13 +17,12 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.add_dependency 'httparty',
|
20
|
+
gem.add_dependency 'httparty', '~> 0.12.0'
|
21
|
+
gem.add_dependency 'active_interaction', '~> 1.0.4'
|
21
22
|
|
22
23
|
gem.add_development_dependency 'bundler', '~> 1.0'
|
23
24
|
gem.add_development_dependency 'rake', '~> 10.0'
|
24
25
|
gem.add_development_dependency 'yard', '~> 0.8'
|
25
26
|
gem.add_development_dependency 'rspec', '~> 3.0.0.beta1'
|
26
|
-
gem.add_development_dependency 'vcr', '~> 2.8.0'
|
27
|
-
gem.add_development_dependency 'webmock', '~> 1.17.1'
|
28
27
|
gem.add_development_dependency 'fabrication', '~> 2.9.6'
|
29
28
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Roqua
|
2
|
+
module CoreApi
|
3
|
+
# @api private
|
4
|
+
class CreateDossier < ActiveInteraction::Base
|
5
|
+
model :session, class: Sessions::OAuthSession
|
6
|
+
string :dossier_group_id
|
7
|
+
hash :attributes, strip: false
|
8
|
+
|
9
|
+
def execute
|
10
|
+
response = session.post "/dossiers", person: attributes.delete(:person),
|
11
|
+
dossier: attributes,
|
12
|
+
dossier_group_id: dossier_group_id
|
13
|
+
Models::Dossier.new(response)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Roqua
|
2
|
+
module CoreApi
|
3
|
+
# @api private
|
4
|
+
class CreateDossierGroup < ActiveInteraction::Base
|
5
|
+
model :session, class: Sessions::OAuthSession
|
6
|
+
string :organization_id
|
7
|
+
hash :attributes, strip: false
|
8
|
+
|
9
|
+
def execute
|
10
|
+
response = session.post "/dossier_groups", dossier_group: attributes, organization_id: organization_id
|
11
|
+
Models::DossierGroup.new(response)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Roqua
|
2
|
+
module CoreApi
|
3
|
+
# @api private
|
4
|
+
class SendEmailTo < ActiveInteraction::Base
|
5
|
+
string :person_id
|
6
|
+
hash :attributes do
|
7
|
+
string :subject
|
8
|
+
string :body
|
9
|
+
string :bcc, default: nil
|
10
|
+
string :content_type, default: 'text/html'
|
11
|
+
string :mail_type, default: nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# Possible variables in the body are:
|
15
|
+
# %firstname%,
|
16
|
+
# %lastname%,
|
17
|
+
# %initials%
|
18
|
+
def execute
|
19
|
+
CoreApi.basic_auth_session.post "/emails", email: attributes, person_id: person_id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Roqua
|
2
|
+
module CoreApi
|
3
|
+
module Sessions
|
4
|
+
class AuthSession
|
5
|
+
attr_reader :core_host
|
6
|
+
|
7
|
+
def initialize(core_host: ENV['ROQUA_CORE_HOST'])
|
8
|
+
@core_host = core_host
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(path, params = {})
|
12
|
+
perform_request_or_fail do
|
13
|
+
HTTParty.get(full_url_for(path), headers: headers, query: params, basic_auth: basic_auth)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def post(path, params = {})
|
18
|
+
perform_request_or_fail do
|
19
|
+
HTTParty.post(full_url_for(path), headers: headers, body: params, basic_auth: basic_auth)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def patch(path, params = {})
|
24
|
+
perform_request_or_fail do
|
25
|
+
HTTParty.patch(full_url_for(path), headers: headers, body: params, basic_auth: basic_auth)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete(path, params = {})
|
30
|
+
HTTParty.delete(full_url_for(path), headers: headers, query: params, basic_auth: basic_auth)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def perform_request_or_fail(&block)
|
36
|
+
response = yield
|
37
|
+
fail response.parsed_response unless (200..299).include? response.code
|
38
|
+
response
|
39
|
+
end
|
40
|
+
|
41
|
+
def full_url_for(path)
|
42
|
+
core_host + api_base + path + '.json'
|
43
|
+
end
|
44
|
+
|
45
|
+
def api_base
|
46
|
+
'/api/v1'
|
47
|
+
end
|
48
|
+
|
49
|
+
def headers
|
50
|
+
end
|
51
|
+
|
52
|
+
def basic_auth
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Roqua
|
2
|
+
module CoreApi
|
3
|
+
module Sessions
|
4
|
+
class BasicAuthSession < AuthSession
|
5
|
+
attr_reader :username
|
6
|
+
attr_reader :password
|
7
|
+
|
8
|
+
def initialize(username: ENV['ROQUA_CORE_KEY'], password: ENV['ROQUA_CORE_SECRET'], **additional_arguments)
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
super additional_arguments
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def basic_auth
|
17
|
+
{username: username, password: password}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,47 +1,20 @@
|
|
1
1
|
module Roqua
|
2
2
|
module CoreApi
|
3
3
|
module Sessions
|
4
|
-
class OAuthSession
|
4
|
+
class OAuthSession < AuthSession
|
5
5
|
attr_reader :access_token
|
6
|
-
attr_reader :server_url
|
7
6
|
|
8
|
-
def initialize(access_token
|
7
|
+
def initialize(access_token:, **additional_arguments)
|
9
8
|
@access_token = access_token
|
10
|
-
|
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)
|
9
|
+
super additional_arguments
|
29
10
|
end
|
30
11
|
|
31
12
|
def logout_url(redirect_to:)
|
32
|
-
"#{
|
13
|
+
"#{core_host}/session/destroy?token=#{access_token}&redirect_to=#{CGI.escape redirect_to}"
|
33
14
|
end
|
34
15
|
|
35
16
|
private
|
36
17
|
|
37
|
-
def full_url_for(url)
|
38
|
-
server_url + base_url + url + ".json"
|
39
|
-
end
|
40
|
-
|
41
|
-
def base_url
|
42
|
-
"/api/v1"
|
43
|
-
end
|
44
|
-
|
45
18
|
def headers
|
46
19
|
{"Authorization" => "Bearer #{access_token}"}
|
47
20
|
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'roqua/core_api/sessions/auth_session'
|
2
3
|
require 'roqua/core_api/sessions/oauth_session'
|
3
|
-
require 'roqua/core_api/sessions/
|
4
|
-
require 'roqua/core_api/sessions/dossier_group_session'
|
5
|
-
require 'roqua/core_api/sessions/dossier_session'
|
4
|
+
require 'roqua/core_api/sessions/basic_auth_session'
|
6
5
|
|
7
6
|
module Roqua
|
8
7
|
module CoreApi
|
9
|
-
def self.oauth_session(
|
10
|
-
Sessions::OAuthSession.new(
|
8
|
+
def self.oauth_session(*arguments, &block)
|
9
|
+
Sessions::OAuthSession.new(*arguments, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.basic_auth_session(*arguments, &block)
|
13
|
+
Sessions::BasicAuthSession.new(*arguments, &block)
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
data/lib/roqua/core_api.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
require 'active_interaction'
|
1
2
|
require 'roqua/core_api/version'
|
2
|
-
require 'roqua/core_api/models'
|
3
3
|
require 'roqua/core_api/sessions'
|
4
|
+
require 'roqua/core_api/models'
|
5
|
+
require 'roqua/core_api/me'
|
6
|
+
require 'roqua/core_api/create_dossier'
|
7
|
+
require 'roqua/core_api/create_dossier_group'
|
8
|
+
require 'roqua/core_api/send_email_to'
|
9
|
+
require 'roqua/core_api/send_invite_email'
|
@@ -11,10 +11,7 @@ module OmniAuth
|
|
11
11
|
|
12
12
|
info do
|
13
13
|
{dossier_id: raw_info['dossier_id'],
|
14
|
-
|
15
|
-
organization_id: raw_info['organization_id'],
|
16
|
-
username: raw_info['username'],
|
17
|
-
email: raw_info['email']}
|
14
|
+
username: raw_info['username']}
|
18
15
|
end
|
19
16
|
|
20
17
|
def raw_info
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CreateDossierGroup do
|
4
|
+
let(:session) { Fabricate :oauth_session }
|
5
|
+
|
6
|
+
it 'performs a post on the /dossier_groups api path' do
|
7
|
+
expect(session).to receive(:post).with '/dossier_groups', dossier_group: {some: 'attributes'},
|
8
|
+
organization_id: 'some_organization_id'
|
9
|
+
CreateDossierGroup.run!(session: session, attributes: {some: 'attributes'}, organization_id: 'some_organization_id')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a Dossier model' do
|
13
|
+
allow(session).to receive(:post).with('/dossier_groups', dossier_group: {some: 'attributes'},
|
14
|
+
organization_id: 'some_organization_id')
|
15
|
+
.and_return 'id' => 'some_id', 'name' => 'some_name'
|
16
|
+
dossier_group = CreateDossierGroup.run!(session: session,
|
17
|
+
attributes: {some: 'attributes'},
|
18
|
+
organization_id: 'some_organization_id')
|
19
|
+
expect(dossier_group).to be_a(DossierGroup)
|
20
|
+
expect(dossier_group.id).to eq('some_id')
|
21
|
+
expect(dossier_group.name).to eq('some_name')
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CreateDossier do
|
4
|
+
let(:session) { Fabricate :oauth_session }
|
5
|
+
|
6
|
+
it 'performs a post on the /dossiers api path' do
|
7
|
+
expect(session).to receive(:post).with '/dossiers', person: 'person',
|
8
|
+
dossier: {other: 'attributes'},
|
9
|
+
dossier_group_id: 'some_dossier_group_id'
|
10
|
+
CreateDossier.run!(session: session,
|
11
|
+
attributes: {person: 'person', other: 'attributes'},
|
12
|
+
dossier_group_id: 'some_dossier_group_id')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns a Dossier model' do
|
16
|
+
allow(session).to receive(:post).with('/dossiers', person: 'person',
|
17
|
+
dossier: {other: 'attributes'},
|
18
|
+
dossier_group_id: 'some_dossier_group_id')
|
19
|
+
.and_return 'id' => 'some_id'
|
20
|
+
dossier = CreateDossier.run!(session: session,
|
21
|
+
attributes: {person: 'person', other: 'attributes'},
|
22
|
+
dossier_group_id: 'some_dossier_group_id')
|
23
|
+
expect(dossier).to be_a(Dossier)
|
24
|
+
expect(dossier.id).to eq('some_id')
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Me do
|
4
|
+
let(:session) { Fabricate :oauth_session }
|
5
|
+
|
6
|
+
it 'performs a get on the /me api path' do
|
7
|
+
expect(session).to receive(:get).with('/me').and_return({})
|
8
|
+
Me.run!(session: session)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns the me entry from the response' do
|
12
|
+
allow(session).to receive(:get).with('/me').and_return 'me' => 'some_info'
|
13
|
+
expect(Me.run!(session: session)).to eq('some_info')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SendEmailTo do
|
4
|
+
let(:session) { Sessions::BasicAuthSession.new }
|
5
|
+
before { allow(Sessions::BasicAuthSession).to receive(:new).and_return session }
|
6
|
+
|
7
|
+
it 'performs a post on the emails api path providing the person_id and the email attributes' do
|
8
|
+
email_attributes = {subject: 'some_subject',
|
9
|
+
body: 'some_body',
|
10
|
+
bcc: 'some@bcc',
|
11
|
+
content_type: 'some/content/type',
|
12
|
+
mail_type: 'some_mail_type'}
|
13
|
+
expect(session).to receive(:post).with '/emails', person_id: 'some_person_id', email: email_attributes
|
14
|
+
SendEmailTo.run!(person_id: 'some_person_id', attributes: email_attributes)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'defaults the content_type to text/html' do
|
18
|
+
email_attributes = {subject: 'some_subject',
|
19
|
+
body: 'some_body',
|
20
|
+
bcc: 'some@bcc',
|
21
|
+
mail_type: 'some_mail_type'}
|
22
|
+
expect(session).to receive(:post).with '/emails', person_id: 'some_person_id',
|
23
|
+
email: email_attributes.merge(content_type: 'text/html')
|
24
|
+
SendEmailTo.run!(person_id: 'some_person_id', attributes: email_attributes)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SendInviteEmail do
|
4
|
+
let(:session) { Fabricate :oauth_session }
|
5
|
+
|
6
|
+
it 'performs a post on the send_invite_email api path' do
|
7
|
+
expect(session).to receive(:post).with '/send_invite_email'
|
8
|
+
SendInviteEmail.run!(session: session)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AuthSession do
|
4
|
+
let(:session) { Fabricate :auth_session }
|
5
|
+
let(:response) { double('response', code: 201, parsed_response: 'some_response') }
|
6
|
+
|
7
|
+
describe '#initialize' do
|
8
|
+
it 'sets the core_host instance attribute' do
|
9
|
+
session = AuthSession.new core_host: 'some_core_host'
|
10
|
+
expect(session.core_host).to eq('some_core_host')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'defaults the core_host to the ROQUA_CORE_HOST env variable' do
|
14
|
+
orginal_env_core_host = ENV['ROQUA_CORE_HOST']
|
15
|
+
ENV['ROQUA_CORE_HOST'] = 'some_env_core_host'
|
16
|
+
session = AuthSession.new
|
17
|
+
ENV['ROQUA_CORE_HOST'] = orginal_env_core_host
|
18
|
+
expect(session.core_host).to eq('some_env_core_host')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#get' do
|
23
|
+
it 'performs a get request' do
|
24
|
+
allow(session).to receive(:basic_auth).and_return(username: 'some_username', password: 'some_password')
|
25
|
+
allow(session).to receive(:headers).and_return(some: 'header')
|
26
|
+
expect(HTTParty).to receive(:get).with('http://core.dev/api/v1/some_path.json',
|
27
|
+
query: {some: 'param'},
|
28
|
+
headers: {some: 'header'},
|
29
|
+
basic_auth: {username: 'some_username', password: 'some_password'})
|
30
|
+
.and_return(response)
|
31
|
+
session.get '/some_path', some: 'param'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'throws an error if the reponse is not within the 200 range' do
|
35
|
+
allow(response).to receive(:code).and_return(500)
|
36
|
+
allow(HTTParty).to receive(:get).and_return(response)
|
37
|
+
expect { session.get '/some_path' }.to raise_error(RuntimeError, 'some_response')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns the response' do
|
41
|
+
allow(HTTParty).to receive(:get).and_return(response)
|
42
|
+
expect(session.get '/some_path').to eq(response)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BasicAuthSession do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'sets the username instance variable' do
|
6
|
+
session = Roqua::CoreApi.basic_auth_session username: 'some_username'
|
7
|
+
expect(session.username).to eq('some_username')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'defaults the username to the ROQUA_CORE_KEY env variable' do
|
11
|
+
orginal_env_core_key = ENV['ROQUA_CORE_KEY']
|
12
|
+
ENV['ROQUA_CORE_KEY'] = 'some_env_core_key'
|
13
|
+
session = Roqua::CoreApi.basic_auth_session
|
14
|
+
ENV['ROQUA_CORE_KEY'] = orginal_env_core_key
|
15
|
+
expect(session.username).to eq('some_env_core_key')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'sets the password instance variable' do
|
19
|
+
session = Roqua::CoreApi.basic_auth_session password: 'some_password'
|
20
|
+
expect(session.password).to eq('some_password')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'defaults the password to the ROQUA_CORE_SECRET env variable' do
|
24
|
+
orginal_env_core_secret = ENV['ROQUA_CORE_SECRET']
|
25
|
+
ENV['ROQUA_CORE_SECRET'] = 'some_env_core_secret'
|
26
|
+
session = Roqua::CoreApi.basic_auth_session
|
27
|
+
ENV['ROQUA_CORE_SECRET'] = orginal_env_core_secret
|
28
|
+
expect(session.password).to eq('some_env_core_secret')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'allows to override the core_host variable' do
|
32
|
+
session = Roqua::CoreApi.basic_auth_session core_host: 'some_core_host'
|
33
|
+
expect(session.core_host).to eq('some_core_host')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'defaults the AuthSession core_host ROQUA_CORE_HOST env variable default value' do
|
37
|
+
orginal_env_core_host = ENV['ROQUA_CORE_HOST']
|
38
|
+
ENV['ROQUA_CORE_HOST'] = 'some_env_core_host'
|
39
|
+
session = Roqua::CoreApi.basic_auth_session
|
40
|
+
ENV['ROQUA_CORE_HOST'] = orginal_env_core_host
|
41
|
+
expect(session.core_host).to eq('some_env_core_host')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#basic_auth' do
|
46
|
+
it 'returns the username and password variables' do
|
47
|
+
session = Roqua::CoreApi.basic_auth_session username: 'some_username', password: 'some_password'
|
48
|
+
expect(session.send :basic_auth).to eq(username: 'some_username', password: 'some_password')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OAuthSession do
|
4
|
+
let(:session) { Fabricate :oauth_session }
|
5
|
+
let(:response) { double('response', code: 201, parsed_response: 'some_response') }
|
6
|
+
|
7
|
+
describe '#initialize' do
|
8
|
+
it 'sets the access_token instance variable' do
|
9
|
+
session = Roqua::CoreApi.oauth_session access_token: 'some_access_token'
|
10
|
+
expect(session.access_token).to eq('some_access_token')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'allows to override the core_host variable' do
|
14
|
+
session = Roqua::CoreApi.oauth_session access_token: 'some_access_token', core_host: 'some_core_host'
|
15
|
+
expect(session.core_host).to eq('some_core_host')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'defaults the AuthSession core_host ROQUA_CORE_HOST env variable default value' do
|
19
|
+
orginal_env_core_host = ENV['ROQUA_CORE_HOST']
|
20
|
+
ENV['ROQUA_CORE_HOST'] = 'some_env_core_host'
|
21
|
+
session = Roqua::CoreApi.oauth_session access_token: 'some_access_token'
|
22
|
+
ENV['ROQUA_CORE_HOST'] = orginal_env_core_host
|
23
|
+
expect(session.core_host).to eq('some_env_core_host')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#logout_url' do
|
28
|
+
it 'returns the oauth session destroy url with an escaped redirect_to parameter' do
|
29
|
+
expect(session.logout_url redirect_to: 'some redirect to')
|
30
|
+
.to eq('http://core.dev/session/destroy?token=some_access_token&redirect_to=some+redirect+to')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'headers' do
|
35
|
+
it 'sets the Authorization header' do
|
36
|
+
expect(HTTParty).to receive(:get).with(an_instance_of(String),
|
37
|
+
headers: {"Authorization" => "Bearer some_access_token"},
|
38
|
+
query: {},
|
39
|
+
basic_auth: nil).and_return(response)
|
40
|
+
session.get 'some_path'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'fabrication'
|
3
|
-
|
4
|
-
require 'vcr'
|
5
|
-
VCR.configure do |c|
|
6
|
-
c.cassette_library_dir = 'spec/fixtures'
|
7
|
-
c.allow_http_connections_when_no_cassette = false
|
8
|
-
c.hook_into :webmock
|
9
|
-
c.configure_rspec_metadata!
|
10
|
-
end
|
11
|
-
|
12
3
|
require 'roqua-core-api'
|
13
4
|
include Roqua::CoreApi
|
5
|
+
include Roqua::CoreApi::Sessions
|
6
|
+
include Roqua::CoreApi::Models
|
metadata
CHANGED
@@ -1,125 +1,111 @@
|
|
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.10
|
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-
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.12.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.12.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: active_interaction
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.4
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - ~>
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '1.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - ~>
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - ~>
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '10.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - ~>
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '10.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: yard
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - ~>
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0.8'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - ~>
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0.8'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - ~>
|
87
|
+
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: 3.0.0.beta1
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - ~>
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: 3.0.0.beta1
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: vcr
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 2.8.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 2.8.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: webmock
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 1.17.1
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ~>
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 1.17.1
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: fabrication
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- - ~>
|
101
|
+
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: 2.9.6
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- - ~>
|
108
|
+
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: 2.9.6
|
125
111
|
description: Provides authenticated access to Core
|
@@ -128,10 +114,10 @@ executables: []
|
|
128
114
|
extensions: []
|
129
115
|
extra_rdoc_files: []
|
130
116
|
files:
|
131
|
-
- .document
|
132
|
-
- .gitignore
|
133
|
-
- .rspec
|
134
|
-
- .yardopts
|
117
|
+
- ".document"
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".yardopts"
|
135
121
|
- ChangeLog.md
|
136
122
|
- Gemfile
|
137
123
|
- Guardfile
|
@@ -141,25 +127,34 @@ files:
|
|
141
127
|
- core_api.gemspec
|
142
128
|
- lib/roqua-core-api.rb
|
143
129
|
- lib/roqua/core_api.rb
|
130
|
+
- lib/roqua/core_api/create_dossier.rb
|
131
|
+
- lib/roqua/core_api/create_dossier_group.rb
|
132
|
+
- lib/roqua/core_api/me.rb
|
144
133
|
- lib/roqua/core_api/models.rb
|
145
134
|
- lib/roqua/core_api/models/dossier.rb
|
146
135
|
- lib/roqua/core_api/models/dossier_group.rb
|
147
136
|
- lib/roqua/core_api/models/person.rb
|
137
|
+
- lib/roqua/core_api/send_email_to.rb
|
138
|
+
- lib/roqua/core_api/send_invite_email.rb
|
148
139
|
- lib/roqua/core_api/sessions.rb
|
149
|
-
- lib/roqua/core_api/sessions/
|
150
|
-
- lib/roqua/core_api/sessions/
|
140
|
+
- lib/roqua/core_api/sessions/auth_session.rb
|
141
|
+
- lib/roqua/core_api/sessions/basic_auth_session.rb
|
151
142
|
- lib/roqua/core_api/sessions/oauth_session.rb
|
152
|
-
- lib/roqua/core_api/sessions/organization_session.rb
|
153
143
|
- lib/roqua/core_api/version.rb
|
154
144
|
- lib/roqua/omniauth/rails_initializer.rb
|
155
145
|
- lib/roqua/omniauth/strategies/doorkeeper.rb
|
156
146
|
- spec/core_api_spec.rb
|
157
|
-
- spec/fabricators/
|
158
|
-
- spec/fabricators/
|
159
|
-
- spec/fabricators/
|
160
|
-
- spec/
|
161
|
-
- spec/lib/roqua/core_api/
|
162
|
-
- spec/lib/roqua/core_api/
|
147
|
+
- spec/fabricators/auth_session_fabricator.rb
|
148
|
+
- spec/fabricators/basic_auth_session_fabricator.rb
|
149
|
+
- spec/fabricators/oauth_session_fabricator.rb
|
150
|
+
- spec/lib/roqua/core_api/create_dossier_group_spec.rb
|
151
|
+
- spec/lib/roqua/core_api/create_dossier_spec.rb
|
152
|
+
- spec/lib/roqua/core_api/me_spec.rb
|
153
|
+
- spec/lib/roqua/core_api/send_email_to_spec.rb
|
154
|
+
- spec/lib/roqua/core_api/send_invite_email_spec.rb
|
155
|
+
- spec/lib/roqua/core_api/sessions/auth_session_spec.rb
|
156
|
+
- spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
|
157
|
+
- spec/lib/roqua/core_api/sessions/oauth_session_spec.rb
|
163
158
|
- spec/spec_helper.rb
|
164
159
|
homepage: https://github.com/roqua/core/blob/master/core_api/README.markdown
|
165
160
|
licenses:
|
@@ -171,12 +166,12 @@ require_paths:
|
|
171
166
|
- lib
|
172
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
168
|
requirements:
|
174
|
-
- -
|
169
|
+
- - ">="
|
175
170
|
- !ruby/object:Gem::Version
|
176
171
|
version: '0'
|
177
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
173
|
requirements:
|
179
|
-
- -
|
174
|
+
- - ">="
|
180
175
|
- !ruby/object:Gem::Version
|
181
176
|
version: '0'
|
182
177
|
requirements: []
|
@@ -187,11 +182,16 @@ specification_version: 4
|
|
187
182
|
summary: API wrapper gem around Core's API
|
188
183
|
test_files:
|
189
184
|
- spec/core_api_spec.rb
|
190
|
-
- spec/fabricators/
|
191
|
-
- spec/fabricators/
|
192
|
-
- spec/fabricators/
|
193
|
-
- spec/
|
194
|
-
- spec/lib/roqua/core_api/
|
195
|
-
- spec/lib/roqua/core_api/
|
185
|
+
- spec/fabricators/auth_session_fabricator.rb
|
186
|
+
- spec/fabricators/basic_auth_session_fabricator.rb
|
187
|
+
- spec/fabricators/oauth_session_fabricator.rb
|
188
|
+
- spec/lib/roqua/core_api/create_dossier_group_spec.rb
|
189
|
+
- spec/lib/roqua/core_api/create_dossier_spec.rb
|
190
|
+
- spec/lib/roqua/core_api/me_spec.rb
|
191
|
+
- spec/lib/roqua/core_api/send_email_to_spec.rb
|
192
|
+
- spec/lib/roqua/core_api/send_invite_email_spec.rb
|
193
|
+
- spec/lib/roqua/core_api/sessions/auth_session_spec.rb
|
194
|
+
- spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
|
195
|
+
- spec/lib/roqua/core_api/sessions/oauth_session_spec.rb
|
196
196
|
- spec/spec_helper.rb
|
197
197
|
has_rdoc:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Roqua
|
2
|
-
module CoreApi
|
3
|
-
module Sessions
|
4
|
-
class DossierGroupSession < OrganizationSession
|
5
|
-
attr_reader :dossier_group_id
|
6
|
-
|
7
|
-
def initialize(dossier_group_id, organization_id, server_url = ENV["CORE_URL"], auth: nil)
|
8
|
-
@dossier_group_id = dossier_group_id
|
9
|
-
super(organization_id, server_url, auth: auth)
|
10
|
-
end
|
11
|
-
|
12
|
-
# create_dossier(.. , person: { email: 'user@domain.com' })
|
13
|
-
def create_dossier(attributes)
|
14
|
-
response = post "/dossiers", person: attributes.delete(:person), dossier: attributes
|
15
|
-
fail response.inspect unless response.code == 201
|
16
|
-
Models::Dossier.new(response)
|
17
|
-
end
|
18
|
-
|
19
|
-
def dossier_session(dossier_id)
|
20
|
-
DossierSession.new dossier_id, dossier_group_id, organization_id, server_url
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def base_url
|
26
|
-
super + "/dossier_groups/#{dossier_group_id}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Roqua
|
2
|
-
module CoreApi
|
3
|
-
module Sessions
|
4
|
-
class DossierSession < DossierGroupSession
|
5
|
-
attr_reader :dossier_id
|
6
|
-
|
7
|
-
def initialize(dossier_id, dossier_group_id, organization_id, server_url = ENV["CORE_URL"])
|
8
|
-
@dossier_id = dossier_id
|
9
|
-
super(dossier_group_id, organization_id, server_url)
|
10
|
-
end
|
11
|
-
|
12
|
-
def send_invite_email
|
13
|
-
response = post '/send_invite_email'
|
14
|
-
fail response.inspect unless response.code == 201
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def base_url
|
20
|
-
super + "/dossiers/#{dossier_id}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module Roqua
|
2
|
-
module CoreApi
|
3
|
-
module Sessions
|
4
|
-
# OrganizationSession represents a session which is scoped to a specific organization
|
5
|
-
# in the Core database. It deals with managing dossier groups and dossiers,
|
6
|
-
# but only on a anonymous base. It is not allowed to know who these dossiers
|
7
|
-
# represent.
|
8
|
-
class OrganizationSession
|
9
|
-
attr_reader :server_url
|
10
|
-
attr_reader :organization_id
|
11
|
-
|
12
|
-
# auth = { username: '..', password: '..' }
|
13
|
-
def initialize(organization_id, server_url = ENV["CORE_URL"], auth:nil)
|
14
|
-
@server_url = server_url
|
15
|
-
@organization_id = organization_id
|
16
|
-
@basic_auth = auth
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_dossier_group(attributes)
|
20
|
-
response = post "/dossier_groups", dossier_group: attributes
|
21
|
-
fail response.inspect unless response.code == 201
|
22
|
-
Models::DossierGroup.new(response)
|
23
|
-
end
|
24
|
-
|
25
|
-
def dossier_group_session(dossier_group_id)
|
26
|
-
DossierGroupSession.new dossier_group_id, organization_id, server_url
|
27
|
-
end
|
28
|
-
|
29
|
-
# send_email_to(dossier_group.id, dossier.id, person.id,
|
30
|
-
# subject: '..',
|
31
|
-
# body: 'Hello %firstname%, ..',
|
32
|
-
# bcc: 'bcc@test.com',
|
33
|
-
# content_type: 'text/html',
|
34
|
-
# mail_type: 'daily_recap')
|
35
|
-
# Possible variables in the body are:
|
36
|
-
# %firstname%,
|
37
|
-
# %lastname%,
|
38
|
-
# %initials%
|
39
|
-
def send_email_to(dossier_group_id, dossier_id, person_id, attributes)
|
40
|
-
response = post "/dossier_groups/#{dossier_group_id}/dossiers/#{dossier_id}/people/#{person_id}/emails",
|
41
|
-
email: attributes
|
42
|
-
fail response.inspect unless response.code == 201
|
43
|
-
response
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def get(url, params = {})
|
49
|
-
# TODO: Handle authentication here
|
50
|
-
HTTParty.get(server_url + base_url + url + ".json", query: params, basic_auth: @basic_auth)
|
51
|
-
end
|
52
|
-
|
53
|
-
def post(url, params = {})
|
54
|
-
# TODO: Handle authentication here
|
55
|
-
HTTParty.post(server_url + base_url + url + ".json", body: params, basic_auth: @basic_auth)
|
56
|
-
end
|
57
|
-
|
58
|
-
def put(url, params = {})
|
59
|
-
# TODO: Handle authentication here
|
60
|
-
HTTParty.put(server_url + base_url + url + ".json", body: params, basic_auth: @basic_auth)
|
61
|
-
end
|
62
|
-
|
63
|
-
def base_url
|
64
|
-
"/api/v1/organizations/#{organization_id}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Roqua
|
4
|
-
module CoreApi
|
5
|
-
module Sessions
|
6
|
-
describe DossierGroupSession do
|
7
|
-
let(:session) { Fabricate :dossier_group_session }
|
8
|
-
|
9
|
-
describe '#dossier_session' do
|
10
|
-
it 'initializes a dossier session with a given dossier_group' do
|
11
|
-
dossier_id = 'some_dossier_id'
|
12
|
-
expect(DossierSession).to receive(:new)
|
13
|
-
.with(dossier_id, session.dossier_group_id,
|
14
|
-
session.organization_id, session.server_url)
|
15
|
-
session.dossier_session dossier_id
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Roqua
|
4
|
-
module CoreApi
|
5
|
-
module Sessions
|
6
|
-
describe OrganizationSession do
|
7
|
-
let(:session) { Fabricate :organization_session }
|
8
|
-
|
9
|
-
describe '#dossier_group_session' do
|
10
|
-
it 'initializes an dossier_group session with a given dossier_group_id' do
|
11
|
-
dossier_group_id = 'some_dossier_group_id'
|
12
|
-
expect(DossierGroupSession).to receive(:new).with(dossier_group_id, session.organization_id,
|
13
|
-
session.server_url)
|
14
|
-
session.dossier_group_session dossier_group_id
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|