validic 0.2.1 → 0.3.1
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 +7 -0
- data/.gitignore +4 -0
- data/Gemfile.lock +50 -43
- data/LICENSE.txt +1 -1
- data/lib/validic.rb +9 -4
- data/lib/validic/{general_measurement.rb → biometric.rb} +6 -22
- data/lib/validic/client.rb +48 -7
- data/lib/validic/diabetes.rb +3 -20
- data/lib/validic/fitness.rb +5 -19
- data/lib/validic/nutrition.rb +3 -19
- data/lib/validic/organization.rb +3 -7
- data/lib/validic/request.rb +6 -0
- data/lib/validic/routine.rb +5 -19
- data/lib/validic/sleep.rb +5 -19
- data/lib/validic/third_party_app.rb +3 -8
- data/lib/validic/tobacco_cessation.rb +3 -19
- data/lib/validic/version.rb +1 -1
- data/lib/validic/weight.rb +5 -18
- data/spec/spec_helper.rb +5 -4
- data/spec/validic/biometrics_spec.rb +43 -0
- data/spec/validic/client_spec.rb +39 -1
- data/spec/validic/diabetes_spec.rb +4 -3
- data/spec/validic/fitness_spec.rb +3 -2
- data/spec/validic/nutrition_spec.rb +3 -2
- data/spec/validic/organization_spec.rb +2 -2
- data/spec/validic/profile_spec.rb +1 -28
- data/spec/validic/routine_spec.rb +3 -2
- data/spec/validic/sleep_spec.rb +3 -2
- data/spec/validic/third_party_app_spec.rb +2 -2
- data/spec/validic/tobacco_cessation_spec.rb +3 -2
- data/spec/validic/user_spec.rb +7 -3
- data/spec/validic/weight_spec.rb +3 -2
- data/spec/validic_spec.rb +8 -7
- data/validic.gemspec +6 -7
- metadata +45 -102
- data/lib/validic/activity.rb +0 -73
- data/spec/.DS_Store +0 -0
- data/spec/validic/activity_spec.rb +0 -97
- data/spec/validic/general_measurement_spec.rb +0 -120
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 33f8543ef109856fdd4dd43b1596c52489fed422
|
4
|
+
data.tar.gz: 8cf5a8e0d41473a58924c9fd8609c1493bfc3b34
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 824c8b8d0834310140fd4d77e62efd5911cd8538d460d0d164d470227df8a7890443da8fa95fa628ab9ddb72a70fac51580a76bad7ddf3b0e7bffe91760c1c0f
|
7
|
+
data.tar.gz: fdb9bafdf0710abcd37f0d4523ae7d108e40f49d3246b871330e49268acd65b0919c539e8f42312235ac5fe52b40870b79c48073749bc5d911bf2cb7b8e8cd7d
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,80 +1,87 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
validic (0.
|
4
|
+
validic (0.3.1)
|
5
5
|
activesupport
|
6
|
-
|
7
|
-
faraday_middleware (~> 0.9)
|
6
|
+
faraday_middleware (~> 0.9.0)
|
8
7
|
hashie (~> 2.0.3)
|
9
8
|
multi_json
|
10
9
|
|
11
10
|
GEM
|
12
11
|
remote: https://rubygems.org/
|
13
12
|
specs:
|
14
|
-
activesupport (
|
15
|
-
i18n (
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
activesupport (4.0.2)
|
14
|
+
i18n (~> 0.6, >= 0.6.4)
|
15
|
+
minitest (~> 4.2)
|
16
|
+
multi_json (~> 1.3)
|
17
|
+
thread_safe (~> 0.1)
|
18
|
+
tzinfo (~> 0.3.37)
|
19
|
+
addressable (2.3.5)
|
20
|
+
api_matchers (0.4.0)
|
19
21
|
activesupport (>= 3.2.5)
|
20
22
|
nokogiri (>= 1.5.2)
|
21
23
|
rspec (>= 2.10.0)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
diff-lcs (1.2.
|
26
|
-
|
24
|
+
atomic (1.1.14)
|
25
|
+
crack (0.4.1)
|
26
|
+
safe_yaml (~> 0.9.0)
|
27
|
+
diff-lcs (1.2.5)
|
28
|
+
docile (1.1.2)
|
29
|
+
faraday (0.8.9)
|
27
30
|
multipart-post (~> 1.2.0)
|
28
31
|
faraday_middleware (0.9.0)
|
29
32
|
faraday (>= 0.7.4, < 0.9)
|
30
33
|
hashie (2.0.5)
|
31
|
-
i18n (0.6.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
multi_json (1.7.2)
|
34
|
+
i18n (0.6.9)
|
35
|
+
mini_portile (0.5.2)
|
36
|
+
minitest (4.7.5)
|
37
|
+
multi_json (1.8.4)
|
36
38
|
multipart-post (1.2.0)
|
37
|
-
nokogiri (1.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
rspec-
|
42
|
-
rspec-
|
43
|
-
|
44
|
-
rspec-
|
39
|
+
nokogiri (1.6.1)
|
40
|
+
mini_portile (~> 0.5.0)
|
41
|
+
rake (10.1.1)
|
42
|
+
rspec (2.14.1)
|
43
|
+
rspec-core (~> 2.14.0)
|
44
|
+
rspec-expectations (~> 2.14.0)
|
45
|
+
rspec-mocks (~> 2.14.0)
|
46
|
+
rspec-core (2.14.7)
|
47
|
+
rspec-expectations (2.14.4)
|
45
48
|
diff-lcs (>= 1.1.3, < 2.0)
|
46
|
-
rspec-mocks (2.
|
47
|
-
|
49
|
+
rspec-mocks (2.14.4)
|
50
|
+
safe_yaml (0.9.7)
|
51
|
+
shoulda (3.5.0)
|
48
52
|
shoulda-context (~> 1.0, >= 1.0.1)
|
49
|
-
shoulda-matchers (
|
50
|
-
shoulda-context (1.1.
|
51
|
-
shoulda-matchers (
|
53
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
54
|
+
shoulda-context (1.1.6)
|
55
|
+
shoulda-matchers (2.5.0)
|
52
56
|
activesupport (>= 3.0.0)
|
53
|
-
|
54
|
-
|
55
|
-
multi_json
|
56
|
-
simplecov-html (~> 0.
|
57
|
-
simplecov-html (0.
|
57
|
+
simplecov (0.8.2)
|
58
|
+
docile (~> 1.1.0)
|
59
|
+
multi_json
|
60
|
+
simplecov-html (~> 0.8.0)
|
61
|
+
simplecov-html (0.8.0)
|
58
62
|
simplecov-rcov (0.2.3)
|
59
63
|
simplecov (>= 0.4.1)
|
60
|
-
|
61
|
-
|
64
|
+
thread_safe (0.1.3)
|
65
|
+
atomic
|
66
|
+
tzinfo (0.3.38)
|
67
|
+
vcr (2.8.0)
|
68
|
+
webmock (1.8.11)
|
62
69
|
addressable (>= 2.2.7)
|
63
|
-
crack (>= 0.
|
64
|
-
yard (0.8.
|
70
|
+
crack (>= 0.1.7)
|
71
|
+
yard (0.8.7.3)
|
65
72
|
|
66
73
|
PLATFORMS
|
67
74
|
ruby
|
68
75
|
|
69
76
|
DEPENDENCIES
|
70
77
|
api_matchers
|
71
|
-
bundler
|
78
|
+
bundler
|
72
79
|
rake
|
73
80
|
rspec
|
74
81
|
shoulda
|
75
82
|
simplecov
|
76
83
|
simplecov-rcov
|
77
84
|
validic!
|
78
|
-
vcr
|
79
|
-
webmock
|
85
|
+
vcr (~> 2.8.0)
|
86
|
+
webmock (~> 1.8.0)
|
80
87
|
yard
|
data/LICENSE.txt
CHANGED
data/lib/validic.rb
CHANGED
@@ -8,7 +8,11 @@ directory = File.expand_path(File.dirname(__FILE__))
|
|
8
8
|
module Validic
|
9
9
|
|
10
10
|
class << self
|
11
|
-
attr_accessor :api_url,
|
11
|
+
attr_accessor :api_url,
|
12
|
+
:api_version,
|
13
|
+
:access_token,
|
14
|
+
:organization_id,
|
15
|
+
:user_id
|
12
16
|
|
13
17
|
##
|
14
18
|
# Configure default
|
@@ -23,9 +27,10 @@ module Validic
|
|
23
27
|
private
|
24
28
|
|
25
29
|
def load_defaults
|
26
|
-
self.api_url
|
27
|
-
self.api_version
|
28
|
-
self.access_token
|
30
|
+
self.api_url ||= 'https://api.validic.com'
|
31
|
+
self.api_version ||= 'v1'
|
32
|
+
self.access_token ||= 'ENTERPRISE_KEY'
|
33
|
+
self.organization_id ||= '51aca5a06dedda916400002b'
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Validic
|
4
|
-
module
|
4
|
+
module Biometric
|
5
5
|
|
6
6
|
##
|
7
7
|
# Get GeneralMeasurement Activities base on `access_token`
|
8
8
|
# Default data fetched is from yesterday
|
9
9
|
#
|
10
|
-
# @params :
|
10
|
+
# @params :org_id - for organization specific
|
11
11
|
# @params :user_id - for user specific
|
12
12
|
#
|
13
13
|
# @params :start_date - optional
|
@@ -17,25 +17,9 @@ module Validic
|
|
17
17
|
# @params :expanded - optional - will show the raw data
|
18
18
|
#
|
19
19
|
# @return [Hashie::Mash] with list of GeneralMeasurement
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
options = {
|
24
|
-
start_date: options[:start_date],
|
25
|
-
end_date: options[:end_date],
|
26
|
-
access_token: options[:access_token],
|
27
|
-
source: options[:source],
|
28
|
-
expanded: options[:expanded]
|
29
|
-
}
|
30
|
-
|
31
|
-
if organization_id
|
32
|
-
response = get("/#{Validic.api_version}/organizations/#{organization_id}/biometrics.json", options)
|
33
|
-
elsif user_id
|
34
|
-
response = get("/#{Validic.api_version}/users/#{user_id}/biometrics.json", options)
|
35
|
-
else
|
36
|
-
response = get("/#{Validic.api_version}/biometrics.json", options)
|
37
|
-
end
|
38
|
-
response if response
|
20
|
+
def get_biometrics(params={})
|
21
|
+
params = extract_params(params)
|
22
|
+
get_endpoint(:biometrics, params)
|
39
23
|
end
|
40
24
|
|
41
25
|
##
|
@@ -72,7 +56,7 @@ module Validic
|
|
72
56
|
# @params :source
|
73
57
|
#
|
74
58
|
# @return success
|
75
|
-
def
|
59
|
+
def create_biometric(options={})
|
76
60
|
options = {
|
77
61
|
access_token: options[:access_token],
|
78
62
|
general_measurement: {
|
data/lib/validic/client.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require 'forwardable'
|
3
3
|
require 'validic/request'
|
4
4
|
require 'validic/organization'
|
5
|
-
require 'validic/activity'
|
6
5
|
require 'validic/user'
|
7
6
|
require 'validic/profile'
|
8
7
|
require 'validic/fitness'
|
@@ -10,7 +9,7 @@ require 'validic/weight'
|
|
10
9
|
require 'validic/nutrition'
|
11
10
|
require 'validic/sleep'
|
12
11
|
require 'validic/diabetes'
|
13
|
-
require 'validic/
|
12
|
+
require 'validic/biometric'
|
14
13
|
require 'validic/routine'
|
15
14
|
require 'validic/tobacco_cessation'
|
16
15
|
require 'validic/third_party_app'
|
@@ -21,7 +20,6 @@ module Validic
|
|
21
20
|
|
22
21
|
include Request
|
23
22
|
include Organization
|
24
|
-
include Activity
|
25
23
|
include User
|
26
24
|
include Profile
|
27
25
|
include Fitness
|
@@ -29,12 +27,15 @@ module Validic
|
|
29
27
|
include Nutrition
|
30
28
|
include Sleep
|
31
29
|
include Diabetes
|
32
|
-
include
|
30
|
+
include Biometric
|
33
31
|
include Routine
|
34
32
|
include TobaccoCessation
|
35
33
|
include ThirdPartyApp
|
36
34
|
|
37
|
-
attr_reader :api_url,
|
35
|
+
attr_reader :api_url,
|
36
|
+
:api_version,
|
37
|
+
:access_token,
|
38
|
+
:organization_id
|
38
39
|
|
39
40
|
##
|
40
41
|
# Create a new Validic::Client object
|
@@ -44,6 +45,7 @@ module Validic
|
|
44
45
|
@api_url = options[:api_url] || Validic.api_url
|
45
46
|
@api_version = options[:api_version] || Validic.api_version || 'v1'
|
46
47
|
@access_token = options[:access_token] || Validic.access_token
|
48
|
+
@organization_id = options[:organization_id] || Validic.organization_id
|
47
49
|
end
|
48
50
|
|
49
51
|
##
|
@@ -52,7 +54,7 @@ module Validic
|
|
52
54
|
# @return [Faraday::Connection]
|
53
55
|
def connection
|
54
56
|
params = {}
|
55
|
-
@connection = Faraday.new(url: api_url, params: params, headers: default_headers, ssl: {verify:
|
57
|
+
@connection = Faraday.new(url: api_url, params: params, headers: default_headers, ssl: {verify: true}) do |faraday|
|
56
58
|
faraday.use FaradayMiddleware::Mashify
|
57
59
|
faraday.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
58
60
|
faraday.use FaradayMiddleware::FollowRedirects
|
@@ -60,10 +62,49 @@ module Validic
|
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
65
|
+
##
|
66
|
+
# Pull the latest endpoint
|
67
|
+
def latest(type, org_id=nil, user_id=nil, params={})
|
68
|
+
organization_id = org_id.nil? ? Validic.organization_id : org_id
|
69
|
+
user_id = org_id.nil? ? Validic.user_id : org_id
|
70
|
+
|
71
|
+
url = "/#{Validic.api_version}/organizations/#{organization_id}/#{type.to_s}/latest.json"
|
72
|
+
|
73
|
+
if user_id
|
74
|
+
url = "/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}/latest.json"
|
75
|
+
end
|
76
|
+
|
77
|
+
get(url, params)
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Generic Pull of Validic Objects
|
82
|
+
def get_endpoint(type, params={})
|
83
|
+
|
84
|
+
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/#{type.to_s}.json"
|
85
|
+
|
86
|
+
if Validic.user_id
|
87
|
+
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/users/#{Validic.user_id}/#{type.to_s}.json"
|
88
|
+
end
|
89
|
+
|
90
|
+
get(url, params)
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Generic POST to Validic
|
95
|
+
def post_to_validic(type, params={})
|
96
|
+
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/#{type.to_s}.json"
|
97
|
+
|
98
|
+
if Validic.user_id
|
99
|
+
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/users/#{Validic.user_id}/#{type.to_s}.json"
|
100
|
+
end
|
101
|
+
post(url, params)
|
102
|
+
end
|
103
|
+
|
63
104
|
private
|
64
105
|
|
65
106
|
def default_headers
|
66
|
-
|
107
|
+
{
|
67
108
|
accept: 'application/json',
|
68
109
|
content_type: 'application/json',
|
69
110
|
user_agent: "Ruby Gem by Validic #{Validic::VERSION}"
|
data/lib/validic/diabetes.rb
CHANGED
@@ -17,26 +17,9 @@ module Validic
|
|
17
17
|
# @params :expanded - optional - will show the raw data
|
18
18
|
#
|
19
19
|
# @return [Hashie::Mash] with list of Diabetes
|
20
|
-
def get_diabetes(
|
21
|
-
|
22
|
-
|
23
|
-
options = {
|
24
|
-
start_date: options[:start_date],
|
25
|
-
end_date: options[:end_date],
|
26
|
-
access_token: options[:access_token],
|
27
|
-
source: options[:source],
|
28
|
-
expanded: options[:expanded]
|
29
|
-
}
|
30
|
-
|
31
|
-
if organization_id
|
32
|
-
response = get("/#{Validic.api_version}/organizations/#{organization_id}/diabetes.json", options)
|
33
|
-
elsif user_id
|
34
|
-
response = get("/#{Validic.api_version}/users/#{user_id}/diabetes.json", options)
|
35
|
-
else
|
36
|
-
response = get("/#{Validic.api_version}/diabetes.json", options)
|
37
|
-
end
|
38
|
-
|
39
|
-
response if response
|
20
|
+
def get_diabetes(params={})
|
21
|
+
params = extract_params(params)
|
22
|
+
get_endpoint(:diabetes, params)
|
40
23
|
end
|
41
24
|
|
42
25
|
##
|
data/lib/validic/fitness.rb
CHANGED
@@ -17,27 +17,13 @@ module Validic
|
|
17
17
|
# @params :expanded - optional - will show the raw data
|
18
18
|
#
|
19
19
|
# @return [Hashie::Mash] with list of Fitness
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
options = {
|
24
|
-
start_date: options[:start_date],
|
25
|
-
end_date: options[:end_date],
|
26
|
-
access_token: options[:access_token],
|
27
|
-
source: options[:source],
|
28
|
-
expanded: options[:expanded]
|
29
|
-
}
|
30
|
-
|
31
|
-
if options[:access_token] && organization_id
|
32
|
-
response = get("/#{Validic.api_version}/organizations/#{organization_id}/fitness.json", options)
|
33
|
-
elsif user_id
|
34
|
-
response = get("/#{Validic.api_version}/users/#{user_id}/fitness.json", options)
|
35
|
-
else
|
36
|
-
response = get("/#{Validic.api_version}/fitness.json", options)
|
37
|
-
end
|
38
|
-
response if response
|
20
|
+
def get_fitness(params={})
|
21
|
+
params = extract_params(params)
|
22
|
+
get_endpoint(:fitness, params)
|
39
23
|
end
|
40
24
|
|
25
|
+
alias :get_fitnesses :get_fitness
|
26
|
+
|
41
27
|
##
|
42
28
|
# Create Fitness base on `access_token` and `authentication_token`
|
43
29
|
#
|
data/lib/validic/nutrition.rb
CHANGED
@@ -17,25 +17,9 @@ module Validic
|
|
17
17
|
# @params :expanded - optional - will show the raw data
|
18
18
|
#
|
19
19
|
# @return [Hashie::Mash] with list of Nutrition
|
20
|
-
def get_nutritions(
|
21
|
-
|
22
|
-
|
23
|
-
options = {
|
24
|
-
start_date: options[:start_date],
|
25
|
-
end_date: options[:end_date],
|
26
|
-
access_token: options[:access_token],
|
27
|
-
source: options[:source],
|
28
|
-
expanded: options[:expanded]
|
29
|
-
}
|
30
|
-
|
31
|
-
if organization_id
|
32
|
-
response = get("/#{Validic.api_version}/organizations/#{organization_id}/nutrition.json", options)
|
33
|
-
elsif user_id
|
34
|
-
response = get("/#{Validic.api_version}/users/#{user_id}/nutrition.json", options)
|
35
|
-
else
|
36
|
-
response = get("/#{Validic.api_version}/nutrition.json", options)
|
37
|
-
end
|
38
|
-
response if response
|
20
|
+
def get_nutritions(params={})
|
21
|
+
params = extract_params(params)
|
22
|
+
get_endpoint(:nutrition, params)
|
39
23
|
end
|
40
24
|
|
41
25
|
##
|
data/lib/validic/organization.rb
CHANGED
@@ -8,13 +8,9 @@ module Validic
|
|
8
8
|
#
|
9
9
|
# @params :access_token
|
10
10
|
# @return [Hashie::Mash] with list of Organization
|
11
|
-
def get_organization(
|
12
|
-
|
13
|
-
|
14
|
-
access_token: options[:access_token]
|
15
|
-
}
|
16
|
-
response = get("/#{Validic.api_version}/organizations/#{organization_id}.json", options)
|
17
|
-
response if response
|
11
|
+
def get_organization(params={})
|
12
|
+
params = extract_params(params)
|
13
|
+
get("/#{Validic.api_version}/organizations/#{Validic.organization_id}.json", params)
|
18
14
|
end
|
19
15
|
|
20
16
|
##
|