validic 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/validic.rb +8 -0
- data/lib/validic/client.rb +2 -2
- data/lib/validic/rest/request.rb +9 -9
- data/lib/validic/version.rb +1 -1
- data/spec/validic/client_spec.rb +19 -0
- data/spec/validic/rest/weight_spec.rb +8 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 745339ec8c3810a9ddd01ec1ca50a23d9f4fea61
|
4
|
+
data.tar.gz: 153c7119593ea8eb978b1f44a47a9b687d40fc7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c434af9057e82f0ee62c4cd55e8f9fa4f7253fa8adfe01c5e619af6dfd9f665808767bf0fc2b0a4ccfa889c6e6eddddf7169d08fc71a40dc5ebb99ca3cad7a7
|
7
|
+
data.tar.gz: 7bf576f8089d439396fae428c8d69a4e1b9240aeee6647608f840f845a7ddf2fef0e3d0b849cc135a195a0509bebaf6a2d79c6c011f4ceccab84a4becce3d7b6
|
data/lib/validic.rb
CHANGED
data/lib/validic/client.rb
CHANGED
@@ -44,8 +44,8 @@ module Validic
|
|
44
44
|
#
|
45
45
|
# @params options[Hash]
|
46
46
|
def initialize(options={})
|
47
|
-
@api_url = options.fetch(:api_url,
|
48
|
-
@api_version = options.fetch(:api_version,
|
47
|
+
@api_url = options.fetch(:api_url, Validic.api_url)
|
48
|
+
@api_version = options.fetch(:api_version, Validic.api_version)
|
49
49
|
@access_token = options.fetch(:access_token, Validic.access_token)
|
50
50
|
@organization_id = options.fetch(:organization_id, Validic.organization_id)
|
51
51
|
reload_config
|
data/lib/validic/rest/request.rb
CHANGED
@@ -8,9 +8,9 @@ module Validic
|
|
8
8
|
organization_id = options[:organization_id] || Validic.organization_id
|
9
9
|
user_id = options.delete(:user_id)
|
10
10
|
if user_id
|
11
|
-
path = "
|
11
|
+
path = "#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}/latest.json"
|
12
12
|
else
|
13
|
-
path = "
|
13
|
+
path = "#{Validic.api_version}/organizations/#{organization_id}/#{type.to_s}/latest.json"
|
14
14
|
end
|
15
15
|
get(path, options)
|
16
16
|
end
|
@@ -42,19 +42,19 @@ module Validic
|
|
42
42
|
user_id = options.delete(:user_id)
|
43
43
|
activity_id = options.delete(:_id)
|
44
44
|
if activity_id
|
45
|
-
path = "
|
45
|
+
path = "#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}/#{activity_id}.json"
|
46
46
|
elsif user_id && type == :users
|
47
|
-
path = "
|
47
|
+
path = "#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}.json"
|
48
48
|
elsif user_id
|
49
|
-
path = "
|
49
|
+
path = "#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}.json"
|
50
50
|
elsif type == :me
|
51
|
-
path = "
|
51
|
+
path = "#{Validic.api_version}/me.json"
|
52
52
|
elsif type == :profile
|
53
|
-
path = "
|
53
|
+
path = "#{Validic.api_version}/profile.json"
|
54
54
|
elsif type == :organizations
|
55
|
-
path = "
|
55
|
+
path = "#{Validic.api_version}/organizations/#{organization_id}.json"
|
56
56
|
else
|
57
|
-
path = "
|
57
|
+
path = "#{Validic.api_version}/organizations/#{organization_id}/#{type.to_s}.json"
|
58
58
|
end
|
59
59
|
path
|
60
60
|
end
|
data/lib/validic/version.rb
CHANGED
data/spec/validic/client_spec.rb
CHANGED
@@ -20,6 +20,18 @@ describe Validic::Client do
|
|
20
20
|
expect(client.organization_id).to eq 1
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'overrides default url and api_key' do
|
24
|
+
Validic.configure do |config|
|
25
|
+
config.api_url = 'http://test.example.com'
|
26
|
+
config.api_version = 'v2'
|
27
|
+
end
|
28
|
+
|
29
|
+
client = Validic::Client.new
|
30
|
+
|
31
|
+
expect(client.api_url).to eq 'http://test.example.com'
|
32
|
+
expect(client.api_version).to eq 'v2'
|
33
|
+
end
|
34
|
+
|
23
35
|
it 'uses options' do
|
24
36
|
opts = {
|
25
37
|
api_url: 'http://test.example.com',
|
@@ -35,6 +47,13 @@ describe Validic::Client do
|
|
35
47
|
expect(client.access_token).to eq 'abcd'
|
36
48
|
expect(client.organization_id).to eq 2
|
37
49
|
end
|
50
|
+
|
51
|
+
it 'options uses defaults' do
|
52
|
+
client = Validic::Client.new({})
|
53
|
+
|
54
|
+
expect(client.api_url).to eq 'https://api.validic.com'
|
55
|
+
expect(client.api_version).to eq 'v1'
|
56
|
+
end
|
38
57
|
end
|
39
58
|
|
40
59
|
describe '#connection' do
|
@@ -59,12 +59,15 @@ describe Validic::REST::Weight do
|
|
59
59
|
expect(@weight).to be_a Validic::Weight
|
60
60
|
end
|
61
61
|
it 'builds the correct url' do
|
62
|
-
pending
|
63
62
|
expect(a_post('/organizations/1/users/1/weight.json')
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
.with(body: {
|
64
|
+
weight: {
|
65
|
+
timestamp: '2013-03-10T07:12:16+00:00',
|
66
|
+
utc_offset: '+00:00', weight: 177,
|
67
|
+
height: 34, data_id: '12345'
|
68
|
+
},
|
69
|
+
access_token: '1' }
|
70
|
+
)).to have_been_made
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Validic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|