validic 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -6
- data/lib/validic/client.rb +18 -7
- data/lib/validic/organization.rb +0 -25
- data/lib/validic/user.rb +16 -0
- data/lib/validic/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/validic/biometrics_spec.rb +1 -1
- data/spec/validic/diabetes_spec.rb +2 -2
- data/spec/validic/fitness_spec.rb +2 -2
- data/spec/validic/nutrition_spec.rb +5 -5
- data/spec/validic/organization_spec.rb +0 -20
- data/spec/validic/routine_spec.rb +2 -2
- data/spec/validic/sleep_spec.rb +2 -2
- data/spec/validic/third_party_app_spec.rb +2 -2
- data/spec/validic/tobacco_cessation_spec.rb +2 -2
- data/spec/validic/user_spec.rb +20 -2
- data/spec/validic/weight_spec.rb +2 -2
- 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: f97e21569bf865fe471589664134bd74d6262e8d
|
4
|
+
data.tar.gz: dfcbf98d9653b7c7f3c800c5707b6976d1f0bd5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14377f4da207974aa7c5a6d7f1d4ec2a63cb5f275a4d3284fbb6f9620bd10e21e2a1b403d8245b09583c7d106de5876138b2e26d68fdc8dae149d6568f1f90b9
|
7
|
+
data.tar.gz: 998e8aaf31789428b41d2b186e48c96fb31a8ddb67974bf892e81c7a0399a19662912c55048d63c0d643cafce3c9fbd9311446e513005908b7a8672c4dbb6344
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,14 +24,14 @@ Or install it yourself as:
|
|
24
24
|
```ruby
|
25
25
|
require 'validic'
|
26
26
|
|
27
|
-
# If
|
27
|
+
# If you're using Rails 3+
|
28
28
|
# config/initializers/validic.rb
|
29
29
|
Validic.configure do |config|
|
30
30
|
config.api_url = 'https://api.validic.com'
|
31
31
|
config.api_version = 'v1'
|
32
32
|
end
|
33
33
|
|
34
|
-
# If
|
34
|
+
# If you're using plain RUBY
|
35
35
|
# Create Validic::Client Object
|
36
36
|
options = {
|
37
37
|
api_url: 'https://api.validic.com',
|
@@ -44,11 +44,11 @@ Or install it yourself as:
|
|
44
44
|
# Validic::Client Object
|
45
45
|
client = Validic::Client.new
|
46
46
|
|
47
|
-
# => Get Account
|
48
|
-
client.
|
47
|
+
# => Get Account Fitness
|
48
|
+
client.get_fitness
|
49
49
|
|
50
|
-
# => Get Organization
|
51
|
-
client.
|
50
|
+
# => Get Organization Fitness
|
51
|
+
client.get_fitness({organization_id: "YOUR_organization_id",
|
52
52
|
access_token: "YOUR_ACCESS_TOKEN"})
|
53
53
|
```
|
54
54
|
|
data/lib/validic/client.rb
CHANGED
@@ -32,7 +32,7 @@ module Validic
|
|
32
32
|
include TobaccoCessation
|
33
33
|
include ThirdPartyApp
|
34
34
|
|
35
|
-
|
35
|
+
attr_accessor :api_url,
|
36
36
|
:api_version,
|
37
37
|
:access_token,
|
38
38
|
:organization_id
|
@@ -42,10 +42,12 @@ module Validic
|
|
42
42
|
#
|
43
43
|
# @params options[Hash]
|
44
44
|
def initialize(options={})
|
45
|
-
@api_url = options[:api_url]
|
46
|
-
@api_version = options[:api_version]
|
47
|
-
@access_token = options[:access_token]
|
48
|
-
@organization_id = options[:organization_id]
|
45
|
+
@api_url = options[:api_url].nil? ? Validic.api_url : options[:api_url]
|
46
|
+
@api_version = options[:api_version].nil? ? 'v1' : options[:api_version]
|
47
|
+
@access_token = options[:access_token].nil? ? Validic.access_token : options[:access_token]
|
48
|
+
@organization_id = options[:organization_id].nil? ? Validic.organization_id : options[:organization_id]
|
49
|
+
|
50
|
+
reload_config
|
49
51
|
end
|
50
52
|
|
51
53
|
##
|
@@ -54,7 +56,7 @@ module Validic
|
|
54
56
|
# @return [Faraday::Connection]
|
55
57
|
def connection
|
56
58
|
params = {}
|
57
|
-
@connection = Faraday.new(url: api_url, params: params, headers: default_headers, ssl: {verify: true}) do |faraday|
|
59
|
+
@connection = Faraday.new(url: @api_url, params: params, headers: default_headers, ssl: {verify: true}) do |faraday|
|
58
60
|
faraday.use FaradayMiddleware::Mashify
|
59
61
|
faraday.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
60
62
|
faraday.use FaradayMiddleware::FollowRedirects
|
@@ -83,8 +85,10 @@ module Validic
|
|
83
85
|
|
84
86
|
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/#{type.to_s}.json"
|
85
87
|
|
86
|
-
if Validic.user_id
|
88
|
+
if Validic.user_id && type != :users
|
87
89
|
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/users/#{Validic.user_id}/#{type.to_s}.json"
|
90
|
+
elsif Validic.user_id && type == :users
|
91
|
+
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/users/#{Validic.user_id}.json"
|
88
92
|
end
|
89
93
|
|
90
94
|
get(url, params)
|
@@ -111,5 +115,12 @@ module Validic
|
|
111
115
|
}
|
112
116
|
end
|
113
117
|
|
118
|
+
def reload_config
|
119
|
+
Validic.api_url = api_url
|
120
|
+
Validic.api_version = api_version
|
121
|
+
Validic.access_token = access_token
|
122
|
+
Validic.organization_id = organization_id
|
123
|
+
end
|
124
|
+
|
114
125
|
end
|
115
126
|
end
|
data/lib/validic/organization.rb
CHANGED
@@ -13,30 +13,5 @@ module Validic
|
|
13
13
|
get("/#{Validic.api_version}/organizations/#{Validic.organization_id}.json", params)
|
14
14
|
end
|
15
15
|
|
16
|
-
##
|
17
|
-
# Get Users base on `access_token` and organization_id
|
18
|
-
#
|
19
|
-
# @params :status - optional (active or inactive) default :all
|
20
|
-
# @params :access_token - optional
|
21
|
-
# @params :start_date - optional
|
22
|
-
# @params :end_date - optional
|
23
|
-
# @params :offset - optional
|
24
|
-
# @params :limit - optional
|
25
|
-
#
|
26
|
-
# @return [Hashie::Mash] with list of Organization
|
27
|
-
def get_users(options={})
|
28
|
-
organization_id = options[:organization_id]
|
29
|
-
options = {
|
30
|
-
access_token: options[:access_token],
|
31
|
-
start_data: options[:start_date],
|
32
|
-
end_date: options[:end_date],
|
33
|
-
offset: options[:offset],
|
34
|
-
limit: options[:limit],
|
35
|
-
status: options[:status]
|
36
|
-
}
|
37
|
-
response = get("/#{Validic.api_version}/organizations/#{organization_id}/users.json", options)
|
38
|
-
response if response
|
39
|
-
end
|
40
|
-
|
41
16
|
end
|
42
17
|
end
|
data/lib/validic/user.rb
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
module Validic
|
4
4
|
module User
|
5
5
|
|
6
|
+
##
|
7
|
+
# Get Users base on `access_token` and organization_id
|
8
|
+
#
|
9
|
+
# @params :status - optional (active or inactive) default :all
|
10
|
+
# @params :access_token - optional
|
11
|
+
# @params :start_date - optional
|
12
|
+
# @params :end_date - optional
|
13
|
+
# @params :offset - optional
|
14
|
+
# @params :limit - optional
|
15
|
+
#
|
16
|
+
# @return [Hashie::Mash] with list of Organization
|
17
|
+
def get_users(params={})
|
18
|
+
params = extract_params(params)
|
19
|
+
get_endpoint(:users, params)
|
20
|
+
end
|
21
|
+
|
6
22
|
##
|
7
23
|
# Get User id base on `access_token`
|
8
24
|
#
|
data/lib/validic/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -37,7 +37,7 @@ RSpec.configure do |c|
|
|
37
37
|
# This is using ACME Corp Credentials as per Documentation
|
38
38
|
config.api_url = 'https://api.validic.com'
|
39
39
|
config.api_version = 'v1'
|
40
|
-
config.access_token = '
|
40
|
+
config.access_token = ENV['TEST_ORG_TOKEN']
|
41
41
|
config.organization_id = '51aca5a06dedda916400002b'
|
42
42
|
end
|
43
43
|
end
|
@@ -26,7 +26,7 @@ describe Validic::Diabetes do
|
|
26
26
|
context "#create_diabetes" do
|
27
27
|
it "should create new diabetes record", vcr: true do
|
28
28
|
pending
|
29
|
-
@new_diabetes = client.create_diabetes({authentication_token:
|
29
|
+
@new_diabetes = client.create_diabetes({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
|
30
30
|
access_token: "DEMO_KEY",
|
31
31
|
c_peptide: 1,
|
32
32
|
fasting_plasma_glucose_test: 50,
|
@@ -70,7 +70,7 @@ describe Validic::Diabetes do
|
|
70
70
|
|
71
71
|
context "#get_diabetes by user" do
|
72
72
|
before do
|
73
|
-
@user_diabetes = client.get_diabetes({user_id:
|
73
|
+
@user_diabetes = client.get_diabetes({user_id: ENV['TEST_USER_ID']})
|
74
74
|
end
|
75
75
|
|
76
76
|
it "returns JSON response of Validic::Diabetes", vcr: true do
|
@@ -26,7 +26,7 @@ describe Validic::Fitness do
|
|
26
26
|
context "#create_fitness" do
|
27
27
|
it "should create new fitness record" do
|
28
28
|
pending
|
29
|
-
@new_fitness = client.create_fitness({authentication_token:
|
29
|
+
@new_fitness = client.create_fitness({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
|
30
30
|
access_token: "DEMO_KEY",
|
31
31
|
timestamp: "2013-03-10 07:12:16 -05:00",
|
32
32
|
primary_type: "Running",
|
@@ -66,7 +66,7 @@ describe Validic::Fitness do
|
|
66
66
|
|
67
67
|
context "#get_fitnesses by user" do
|
68
68
|
before do
|
69
|
-
@fitness = client.get_fitnesses({user_id:
|
69
|
+
@fitness = client.get_fitnesses({user_id: ENV['TEST_USER_ID']})
|
70
70
|
end
|
71
71
|
|
72
72
|
it "returns JSON response of Validic::Fitness", vcr: true do
|
@@ -15,7 +15,7 @@ describe Validic::Nutrition do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "status 200" do
|
18
|
-
@nutrition.summary.status.should == 200
|
18
|
+
@nutrition.summary.status.should == 200
|
19
19
|
end
|
20
20
|
|
21
21
|
it "has summary node" do
|
@@ -26,7 +26,7 @@ describe Validic::Nutrition do
|
|
26
26
|
context "#create_nutrition" do
|
27
27
|
it "should create new nutrition record" do
|
28
28
|
pending
|
29
|
-
@new_nutrition = client.create_nutrition({authentication_token:
|
29
|
+
@new_nutrition = client.create_nutrition({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
|
30
30
|
access_token: "DEMO_KEY",
|
31
31
|
calories: 850,
|
32
32
|
carbohydrates: 351,
|
@@ -62,7 +62,7 @@ describe Validic::Nutrition do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "status 200" do
|
65
|
-
@nutrition.summary.status.should == 200
|
65
|
+
@nutrition.summary.status.should == 200
|
66
66
|
end
|
67
67
|
|
68
68
|
it "has summary node" do
|
@@ -72,7 +72,7 @@ describe Validic::Nutrition do
|
|
72
72
|
|
73
73
|
context "#get_nutritions by user" do
|
74
74
|
before do
|
75
|
-
@nutrition = client.get_nutritions({user_id:
|
75
|
+
@nutrition = client.get_nutritions({user_id: ENV['TEST_USER_ID']})
|
76
76
|
end
|
77
77
|
|
78
78
|
it "returns JSON response of Validic::Nutrition", vcr: true do
|
@@ -80,7 +80,7 @@ describe Validic::Nutrition do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "status 200" do
|
83
|
-
@nutrition.summary.status.should == 200
|
83
|
+
@nutrition.summary.status.should == 200
|
84
84
|
end
|
85
85
|
|
86
86
|
it "has summary node" do
|
@@ -22,25 +22,5 @@ describe Validic::Organization do
|
|
22
22
|
@organization_response.summary.should_not be_nil
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
context "#get_users" do
|
27
|
-
before do
|
28
|
-
@users_response = client.get_users({organization_id: "51aca5a06dedda916400002b", access_token: "ENTERPRISE_KEY"})
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns JSON response of Validic::Organization", vcr: true do
|
32
|
-
@users_response.should_not be_nil
|
33
|
-
end
|
34
|
-
|
35
|
-
it "status 200" do
|
36
|
-
@users_response.summary.status.should == 200
|
37
|
-
end
|
38
|
-
|
39
|
-
it "has summary node" do
|
40
|
-
@users_response.summary.should_not be_nil
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
25
|
end
|
46
26
|
|
@@ -26,7 +26,7 @@ describe Validic::Routine do
|
|
26
26
|
context "#create_routine" do
|
27
27
|
it "should create new routine record" do
|
28
28
|
pending
|
29
|
-
@new_routine = client.create_routine({authentication_token:
|
29
|
+
@new_routine = client.create_routine({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
|
30
30
|
access_token: "DEMO_KEY",
|
31
31
|
timestamp: "2013-05-16 07:12:16 -05:00",
|
32
32
|
steps: 10000,
|
@@ -64,7 +64,7 @@ describe Validic::Routine do
|
|
64
64
|
|
65
65
|
context "#get_routines by user" do
|
66
66
|
before do
|
67
|
-
@routine = client.get_routines({user_id:
|
67
|
+
@routine = client.get_routines({user_id: ENV['TEST_USER_ID']})
|
68
68
|
end
|
69
69
|
|
70
70
|
it "returns JSON response of Validic::Routine", vcr: true do
|
data/spec/validic/sleep_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Validic::Sleep do
|
|
26
26
|
context "#create_sleep" do
|
27
27
|
it "should create new sleep record" do
|
28
28
|
pending
|
29
|
-
@new_sleep = client.create_sleep({authentication_token:
|
29
|
+
@new_sleep = client.create_sleep({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
|
30
30
|
access_token: "DEMO_KEY",
|
31
31
|
total_sleep: 210,
|
32
32
|
awake: 10,
|
@@ -68,7 +68,7 @@ describe Validic::Sleep do
|
|
68
68
|
|
69
69
|
context "#get_sleeps by user" do
|
70
70
|
before do
|
71
|
-
@sleep = client.get_sleeps({user_id:
|
71
|
+
@sleep = client.get_sleeps({user_id: ENV['TEST_USER_ID']})
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns JSON response of Validic::Sleep", vcr: true do
|
@@ -7,7 +7,7 @@ describe Validic::ThirdPartyApp do
|
|
7
7
|
|
8
8
|
context "#get_apps" do
|
9
9
|
before do
|
10
|
-
@app_response = client.get_apps
|
10
|
+
@app_response = client.get_apps
|
11
11
|
end
|
12
12
|
|
13
13
|
it "returns JSON response of Validic::ThirdPartyApp", vcr: true do
|
@@ -21,7 +21,7 @@ describe Validic::ThirdPartyApp do
|
|
21
21
|
|
22
22
|
context "#get_synced_apps" do
|
23
23
|
before do
|
24
|
-
@synced_app_response = client.get_synced_apps({authentication_token:
|
24
|
+
@synced_app_response = client.get_synced_apps({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN']})
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns JSON response of Validic::ThirdPartyApp", vcr: true do
|
@@ -26,7 +26,7 @@ describe Validic::TobaccoCessation do
|
|
26
26
|
context "#create_tobacco_cessation" do
|
27
27
|
it "should create new tobacco_cessation record" do
|
28
28
|
pending
|
29
|
-
@new_tobacco_cessation = client.create_tobacco_cessation({authentication_token:
|
29
|
+
@new_tobacco_cessation = client.create_tobacco_cessation({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
|
30
30
|
access_token: "DEMO_KEY",
|
31
31
|
timestamp: "2013-05-01 07:12:16 -05:00",
|
32
32
|
cigarettes_allowed: 10,
|
@@ -63,7 +63,7 @@ describe Validic::TobaccoCessation do
|
|
63
63
|
|
64
64
|
context "#get_tobacco_cessations by user" do
|
65
65
|
before do
|
66
|
-
@tobacco_cessation = client.get_tobacco_cessations({user_id:
|
66
|
+
@tobacco_cessation = client.get_tobacco_cessations({user_id: ENV['TEST_USER_ID']})
|
67
67
|
end
|
68
68
|
|
69
69
|
it "returns JSON response of Validic::TobaccoCessation", vcr: true do
|
data/spec/validic/user_spec.rb
CHANGED
@@ -5,6 +5,25 @@ describe Validic::User do
|
|
5
5
|
|
6
6
|
let(:client) { Validic::Client.new }
|
7
7
|
|
8
|
+
context "#get_users" do
|
9
|
+
before do
|
10
|
+
@users_response = client.get_users
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns JSON response of Validic::Organization", vcr: true do
|
14
|
+
@users_response.should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "status 200" do
|
18
|
+
@users_response.summary.status.should == 200
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has summary node" do
|
22
|
+
@users_response.summary.should_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
8
27
|
context "#me" do
|
9
28
|
before do
|
10
29
|
@me = client.me({})
|
@@ -25,7 +44,6 @@ describe Validic::User do
|
|
25
44
|
it "should create a new user under an organization" do
|
26
45
|
pending
|
27
46
|
@new_user = client.user_provision(organization_id: "51aca5a06dedda916400002b",
|
28
|
-
access_token: "ENTERPRISE_KEY",
|
29
47
|
uid: "123asdfg",
|
30
48
|
height: 167,
|
31
49
|
weight: 69,
|
@@ -43,7 +61,7 @@ describe Validic::User do
|
|
43
61
|
it "should suspend a user" do
|
44
62
|
pending
|
45
63
|
@suspend_user = client.user_suspend(organization_id: "51aca5a06dedda916400002b",
|
46
|
-
user_id:
|
64
|
+
user_id: ENV['TEST_USER_ID'],
|
47
65
|
access_token: "9c03ad2bcb022425944e4686d398ef8398f537c2f7c113495ffa7bc9cfa49286",
|
48
66
|
suspend: 1)
|
49
67
|
@suspend_user.message.should eq "The user has been suspended successfully"
|
data/spec/validic/weight_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Validic::Weight do
|
|
26
26
|
context "#create_weight" do
|
27
27
|
it "should create new weight record" do
|
28
28
|
pending
|
29
|
-
@new_weight = client.create_weight({authentication_token:
|
29
|
+
@new_weight = client.create_weight({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
|
30
30
|
access_token: "DEMO_KEY",
|
31
31
|
timestamp: "2013-05-16 07:12:16 -05:00",
|
32
32
|
bmi: 133.26,
|
@@ -69,7 +69,7 @@ describe Validic::Weight do
|
|
69
69
|
|
70
70
|
context "#get_weights by user" do
|
71
71
|
before do
|
72
|
-
@weight = client.get_weights({user_id:
|
72
|
+
@weight = client.get_weights({user_id: ENV['TEST_USER_ID']})
|
73
73
|
end
|
74
74
|
|
75
75
|
it "returns JSON response of Validic::Weight", vcr: true do
|
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julius Francisco & Jay Balanay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|