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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53c02e1157a3b249037c74bdf481f101df6b456a
4
- data.tar.gz: e94207ea46f138ef36ba412bdf11ae4f888f269a
3
+ metadata.gz: 745339ec8c3810a9ddd01ec1ca50a23d9f4fea61
4
+ data.tar.gz: 153c7119593ea8eb978b1f44a47a9b687d40fc7b
5
5
  SHA512:
6
- metadata.gz: 23eba8028225aef63c4d460473dd61f32263de091f3f30b1207659a06bed7a51ef4b39087174d5c6d9e7c5dc3c2348ce0813d74eecd3a4aafca873704b54f534
7
- data.tar.gz: f3c4506683851d89b4c6dac206af7eb399b128566893ce9b580a193bc0db8420003abdc6aa32adbc6744ca7495fc962c31501b4eca888dc3e8fbd10f22685d0e
6
+ metadata.gz: 6c434af9057e82f0ee62c4cd55e8f9fa4f7253fa8adfe01c5e619af6dfd9f665808767bf0fc2b0a4ccfa889c6e6eddddf7169d08fc71a40dc5ebb99ca3cad7a7
7
+ data.tar.gz: 7bf576f8089d439396fae428c8d69a4e1b9240aeee6647608f840f845a7ddf2fef0e3d0b849cc135a195a0509bebaf6a2d79c6c011f4ceccab84a4becce3d7b6
@@ -16,5 +16,13 @@ module Validic
16
16
  yield self
17
17
  true
18
18
  end
19
+
20
+ def api_url
21
+ @api_url ||= "https://api.validic.com"
22
+ end
23
+
24
+ def api_version
25
+ @api_version ||= "v1"
26
+ end
19
27
  end
20
28
  end
@@ -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, 'https://api.validic.com')
48
- @api_version = options.fetch(:api_version, 'v1')
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
@@ -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 = "/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}/latest.json"
11
+ path = "#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}/latest.json"
12
12
  else
13
- path = "/#{Validic.api_version}/organizations/#{organization_id}/#{type.to_s}/latest.json"
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 = "/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}/#{activity_id}.json"
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 = "/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}.json"
47
+ path = "#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}.json"
48
48
  elsif user_id
49
- path = "/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}.json"
49
+ path = "#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}.json"
50
50
  elsif type == :me
51
- path = "/#{Validic.api_version}/me.json"
51
+ path = "#{Validic.api_version}/me.json"
52
52
  elsif type == :profile
53
- path = "/#{Validic.api_version}/profile.json"
53
+ path = "#{Validic.api_version}/profile.json"
54
54
  elsif type == :organizations
55
- path = "/#{Validic.api_version}/organizations/#{organization_id}.json"
55
+ path = "#{Validic.api_version}/organizations/#{organization_id}.json"
56
56
  else
57
- path = "/#{Validic.api_version}/organizations/#{organization_id}/#{type.to_s}.json"
57
+ path = "#{Validic.api_version}/organizations/#{organization_id}/#{type.to_s}.json"
58
58
  end
59
59
  path
60
60
  end
@@ -1,3 +1,3 @@
1
1
  module Validic
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.6.1'.freeze
3
3
  end
@@ -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
- .with(body: { weight: { timestamp: '2013-03-10T07:12:16+00:00',
65
- utf_offset: '+00:00', weight: 177,
66
- height: 34, data_id: '12345'},
67
- access_token: '1' })).to have_been_made
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.0
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-10-13 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware