validic 0.3.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rspec +0 -1
- data/Gemfile +12 -1
- data/Gemfile.lock +32 -62
- data/README.md +442 -28
- data/lib/validic.rb +3 -20
- data/lib/validic/app.rb +11 -0
- data/lib/validic/biometrics.rb +9 -0
- data/lib/validic/client.rb +35 -77
- data/lib/validic/diabetes.rb +4 -60
- data/lib/validic/error.rb +33 -0
- data/lib/validic/extra.rb +10 -0
- data/lib/validic/fitness.rb +4 -57
- data/lib/validic/nutrition.rb +5 -61
- data/lib/validic/organization.rb +6 -13
- data/lib/validic/profile.rb +4 -39
- data/lib/validic/response.rb +15 -0
- data/lib/validic/rest/apps.rb +21 -0
- data/lib/validic/rest/biometrics.rb +39 -0
- data/lib/validic/rest/diabetes.rb +39 -0
- data/lib/validic/rest/fitness.rb +40 -0
- data/lib/validic/rest/nutrition.rb +40 -0
- data/lib/validic/rest/organizations.rb +12 -0
- data/lib/validic/rest/profile.rb +18 -0
- data/lib/validic/rest/request.rb +95 -0
- data/lib/validic/rest/routine.rb +40 -0
- data/lib/validic/rest/sleep.rb +41 -0
- data/lib/validic/rest/tobacco_cessation.rb +40 -0
- data/lib/validic/rest/users.rb +55 -0
- data/lib/validic/rest/utils.rb +28 -0
- data/lib/validic/rest/weight.rb +43 -0
- data/lib/validic/routine.rb +4 -55
- data/lib/validic/sleep.rb +4 -59
- data/lib/validic/summary.rb +18 -0
- data/lib/validic/tobacco_cessation.rb +4 -53
- data/lib/validic/user.rb +4 -99
- data/lib/validic/utils.rb +13 -0
- data/lib/validic/version.rb +1 -1
- data/lib/validic/weight.rb +4 -57
- data/spec/fixtures/apps.json +32 -0
- data/spec/fixtures/biometrics-expanded.json +56 -0
- data/spec/fixtures/biometrics-extras.json +35 -0
- data/spec/fixtures/biometrics_record.json +36 -0
- data/spec/fixtures/biometrics_records.json +54 -0
- data/spec/fixtures/bulk_biometrics_records.json +55 -0
- data/spec/fixtures/bulk_diabetes_records.json +37 -0
- data/spec/fixtures/bulk_fitnesses.json +35 -0
- data/spec/fixtures/bulk_nutritions.json +37 -0
- data/spec/fixtures/bulk_sleeps.json +35 -0
- data/spec/fixtures/bulk_tobacco_cessations.json +33 -0
- data/spec/fixtures/conflict.json +5 -0
- data/spec/fixtures/diabetes-expanded.json +38 -0
- data/spec/fixtures/diabetes-extras.json +17 -0
- data/spec/fixtures/diabetes_record.json +18 -0
- data/spec/fixtures/diabetes_records.json +36 -0
- data/spec/fixtures/fitness-expanded.json +1521 -0
- data/spec/fixtures/fitness-extras.json +15 -0
- data/spec/fixtures/fitness.json +16 -0
- data/spec/fixtures/fitnesses.json +34 -0
- data/spec/fixtures/forbidden.json +5 -0
- data/spec/fixtures/internal_server.json +4 -0
- data/spec/fixtures/me.json +5 -0
- data/spec/fixtures/not_found.json +5 -0
- data/spec/fixtures/nutrition-expanded.json +123 -0
- data/spec/fixtures/nutrition-extras.json +13 -0
- data/spec/fixtures/nutrition.json +18 -0
- data/spec/fixtures/nutritions-expanded.json +123 -0
- data/spec/fixtures/nutritions.json +36 -0
- data/spec/fixtures/organizations.json +27 -0
- data/spec/fixtures/profile.json +13 -0
- data/spec/fixtures/refresh_token.json +7 -0
- data/spec/fixtures/routine-expanded.json +749 -0
- data/spec/fixtures/routine-extras.json +14 -0
- data/spec/fixtures/routine.json +17 -0
- data/spec/fixtures/routines.json +47 -0
- data/spec/fixtures/sleep-expanded.json +51 -0
- data/spec/fixtures/sleep-extras.json +15 -0
- data/spec/fixtures/sleep.json +16 -0
- data/spec/fixtures/sleeps.json +48 -0
- data/spec/fixtures/synced_apps.json +43 -0
- data/spec/fixtures/tobacco_cessation-expanded.json +33 -0
- data/spec/fixtures/tobacco_cessation-extras.json +12 -0
- data/spec/fixtures/tobacco_cessation.json +14 -0
- data/spec/fixtures/tobacco_cessations.json +32 -0
- data/spec/fixtures/unauthorized.json +4 -0
- data/spec/fixtures/unprocessable_entity.json +5 -0
- data/spec/fixtures/updated_user.json +9 -0
- data/spec/fixtures/user.json +8 -0
- data/spec/fixtures/user_with_profile.json +14 -0
- data/spec/fixtures/users.json +23 -0
- data/spec/fixtures/weight-expanded.json +66 -0
- data/spec/fixtures/weight-extras.json +15 -0
- data/spec/fixtures/weight.json +18 -0
- data/spec/fixtures/weights.json +48 -0
- data/spec/spec_helper.rb +47 -33
- data/spec/validic/client_spec.rb +5 -38
- data/spec/validic/error_spec.rb +73 -0
- data/spec/validic/expanded_spec.rb +87 -0
- data/spec/validic/rest/apps_spec.rb +41 -0
- data/spec/validic/rest/biometrics_spec.rb +131 -0
- data/spec/validic/rest/diabetes_spec.rb +131 -0
- data/spec/validic/rest/fitness_spec.rb +131 -0
- data/spec/validic/rest/nutrition_spec.rb +144 -0
- data/spec/validic/rest/organizations_spec.rb +24 -0
- data/spec/validic/rest/profile_spec.rb +44 -0
- data/spec/validic/rest/routine_spec.rb +129 -0
- data/spec/validic/rest/sleep_spec.rb +148 -0
- data/spec/validic/rest/tobacco_cessation_spec.rb +131 -0
- data/spec/validic/rest/users_spec.rb +170 -0
- data/spec/validic/rest/weight_spec.rb +150 -0
- data/spec/validic/summary_spec.rb +3 -0
- data/spec/validic_spec.rb +19 -31
- data/validic.gemspec +0 -13
- metadata +174 -194
- data/lib/validic/biometric.rb +0 -97
- data/lib/validic/request.rb +0 -46
- data/lib/validic/third_party_app.rb +0 -32
- data/spec/validic/biometrics_spec.rb +0 -43
- data/spec/validic/diabetes_spec.rb +0 -89
- data/spec/validic/fitness_spec.rb +0 -85
- data/spec/validic/nutrition_spec.rb +0 -91
- data/spec/validic/organization_spec.rb +0 -26
- data/spec/validic/profile_spec.rb +0 -19
- data/spec/validic/routine_spec.rb +0 -82
- data/spec/validic/sleep_spec.rb +0 -86
- data/spec/validic/third_party_app_spec.rb +0 -32
- data/spec/validic/tobacco_cessation_spec.rb +0 -81
- data/spec/validic/user_spec.rb +0 -81
- data/spec/validic/weight_spec.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8852001360881e470bc390ff9e44d0c83f8c42c
|
4
|
+
data.tar.gz: e3494be76d5d6794db140f08a7228b8ed9788430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ca048da5b89cbada497942557373b0b9d25bc25d296c238349edf72211caf5054a38832b3e26cc8477ea5c8ad36050476eb861e65791941ec0e867c1ab77394
|
7
|
+
data.tar.gz: 06ef87e636504d0db352769653d77bbb690e8e94d156a8c1dda454f99886f3a30897df85443aefd4e98dad4f47afb4de719b7555f81d598150668666f0157ded
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
gem 'rake'
|
4
|
+
gem 'yard'
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'pry'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'rspec', '~> 3.1.0'
|
12
|
+
gem 'webmock', '~> 1.20.4'
|
13
|
+
end
|
14
|
+
|
4
15
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,87 +1,57 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
validic (0.
|
5
|
-
activesupport
|
4
|
+
validic (0.4.1)
|
6
5
|
faraday_middleware (~> 0.9.0)
|
7
|
-
hashie (~> 2.0.3)
|
8
6
|
multi_json
|
9
7
|
|
10
8
|
GEM
|
11
9
|
remote: https://rubygems.org/
|
12
10
|
specs:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
thread_safe (~> 0.1)
|
18
|
-
tzinfo (~> 0.3.37)
|
19
|
-
addressable (2.3.5)
|
20
|
-
api_matchers (0.4.0)
|
21
|
-
activesupport (>= 3.2.5)
|
22
|
-
nokogiri (>= 1.5.2)
|
23
|
-
rspec (>= 2.10.0)
|
24
|
-
atomic (1.1.14)
|
25
|
-
crack (0.4.1)
|
26
|
-
safe_yaml (~> 0.9.0)
|
11
|
+
addressable (2.3.8)
|
12
|
+
coderay (1.1.0)
|
13
|
+
crack (0.4.2)
|
14
|
+
safe_yaml (~> 1.0.0)
|
27
15
|
diff-lcs (1.2.5)
|
28
|
-
|
29
|
-
faraday (0.9.0)
|
16
|
+
faraday (0.9.1)
|
30
17
|
multipart-post (>= 1.2, < 3)
|
31
18
|
faraday_middleware (0.9.1)
|
32
19
|
faraday (>= 0.7.4, < 0.10)
|
33
|
-
|
34
|
-
|
35
|
-
mini_portile (0.5.2)
|
36
|
-
minitest (4.7.5)
|
37
|
-
multi_json (1.8.4)
|
20
|
+
method_source (0.8.2)
|
21
|
+
multi_json (1.11.0)
|
38
22
|
multipart-post (2.0.0)
|
39
|
-
|
40
|
-
|
23
|
+
pry (0.10.1)
|
24
|
+
coderay (~> 1.1.0)
|
25
|
+
method_source (~> 0.8.1)
|
26
|
+
slop (~> 3.4)
|
41
27
|
rake (10.1.1)
|
42
|
-
rspec (
|
43
|
-
rspec-core (~>
|
44
|
-
rspec-expectations (~>
|
45
|
-
rspec-mocks (~>
|
46
|
-
rspec-core (
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
multi_json
|
60
|
-
simplecov-html (~> 0.8.0)
|
61
|
-
simplecov-html (0.8.0)
|
62
|
-
simplecov-rcov (0.2.3)
|
63
|
-
simplecov (>= 0.4.1)
|
64
|
-
thread_safe (0.1.3)
|
65
|
-
atomic
|
66
|
-
tzinfo (0.3.38)
|
67
|
-
vcr (2.8.0)
|
68
|
-
webmock (1.8.11)
|
69
|
-
addressable (>= 2.2.7)
|
70
|
-
crack (>= 0.1.7)
|
28
|
+
rspec (3.1.0)
|
29
|
+
rspec-core (~> 3.1.0)
|
30
|
+
rspec-expectations (~> 3.1.0)
|
31
|
+
rspec-mocks (~> 3.1.0)
|
32
|
+
rspec-core (3.1.7)
|
33
|
+
rspec-support (~> 3.1.0)
|
34
|
+
rspec-expectations (3.1.2)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.1.0)
|
37
|
+
rspec-mocks (3.1.3)
|
38
|
+
rspec-support (~> 3.1.0)
|
39
|
+
rspec-support (3.1.2)
|
40
|
+
safe_yaml (1.0.4)
|
41
|
+
slop (3.6.0)
|
42
|
+
webmock (1.20.4)
|
43
|
+
addressable (>= 2.3.6)
|
44
|
+
crack (>= 0.3.2)
|
71
45
|
yard (0.8.7.3)
|
72
46
|
|
73
47
|
PLATFORMS
|
74
48
|
ruby
|
75
49
|
|
76
50
|
DEPENDENCIES
|
77
|
-
api_matchers
|
78
51
|
bundler
|
52
|
+
pry
|
79
53
|
rake
|
80
|
-
rspec
|
81
|
-
shoulda
|
82
|
-
simplecov
|
83
|
-
simplecov-rcov
|
54
|
+
rspec (~> 3.1.0)
|
84
55
|
validic!
|
85
|
-
|
86
|
-
webmock (~> 1.8.0)
|
56
|
+
webmock (~> 1.20.4)
|
87
57
|
yard
|
data/README.md
CHANGED
@@ -1,15 +1,53 @@
|
|
1
|
-
# Validic
|
2
|
-
|
3
|
-
Ruby API Wrapper for [Validic](http://www.validic.com)
|
1
|
+
# Validic #
|
4
2
|
|
5
3
|
## Build Status
|
6
4
|
[![Codeship Status for Validic/validic](https://www.codeship.io/projects/cc4ff330-9f72-0130-3cf3-0e5a3e2104f7/status?branch=master)](https://www.codeship.io/projects/3456)
|
7
5
|
|
6
|
+
## Stable Version: 0.4.1
|
8
7
|
|
9
|
-
|
8
|
+
Ruby API Wrapper for [Validic](http://www.validic.com/api/docs). It includes the
|
9
|
+
following functionality:
|
10
10
|
|
11
|
-
##
|
11
|
+
## Breaking Changes ##
|
12
|
+
- Methods for user provisioning, suspending, and deleting have been renamed
|
13
|
+
- Methods will now default to initialized values unless overridden in options
|
14
|
+
|
15
|
+
### Organization ###
|
16
|
+
- Organization metadata
|
17
|
+
|
18
|
+
### Users ###
|
19
|
+
- Provision new Validic users
|
20
|
+
- Update, Suspend, or Delete users
|
21
|
+
- Get users from organization credentials
|
22
|
+
- Find user id from authentication token
|
23
|
+
- Refresh user authentication token
|
24
|
+
|
25
|
+
### Profiles ###
|
26
|
+
- Get profile information from user authentication token
|
27
|
+
- Create and modify user profiles
|
28
|
+
|
29
|
+
### Apps ###
|
30
|
+
- List available third party apps
|
31
|
+
- List synced apps for a particular user
|
12
32
|
|
33
|
+
### Activities ###
|
34
|
+
- Fitness, Routine, Nutrition, Sleep, Weight, Diabetes, Biometrics, Tobacco
|
35
|
+
Cessation
|
36
|
+
- Get activities scoped to user or organization
|
37
|
+
- Activities from specific sources
|
38
|
+
- Specified time ranges
|
39
|
+
|
40
|
+
### Connect ###
|
41
|
+
- Create activities as a Validic Connect partner
|
42
|
+
- Post extra data
|
43
|
+
- Update or Delete activities by Validic activity id
|
44
|
+
|
45
|
+
### Latest Endpoint ###
|
46
|
+
- Get latest data recorded, regardless of when the activity occurred
|
47
|
+
- Scope to organization or user level
|
48
|
+
- Specify start and end points
|
49
|
+
|
50
|
+
## Installation
|
13
51
|
Add this line to your application's Gemfile:
|
14
52
|
|
15
53
|
gem 'validic'
|
@@ -24,35 +62,411 @@ Or install it yourself as:
|
|
24
62
|
|
25
63
|
## Usage
|
26
64
|
|
65
|
+
##### Rails 3+
|
66
|
+
First, instantiate the client.
|
67
|
+
```ruby
|
68
|
+
require 'validic'
|
69
|
+
|
70
|
+
# config/initializers/validic.rb
|
71
|
+
Validic.configure do |config|
|
72
|
+
config.api_url = 'https://api.validic.com'
|
73
|
+
config.api_version = 'v1'
|
74
|
+
config.access_token = 'ORGANIZATION_ACCESS_TOKEN',
|
75
|
+
config.organization_id = 'ORGANIZATION_ID'
|
76
|
+
end
|
77
|
+
|
78
|
+
# Create a Client Object provided you have an initializer
|
79
|
+
client = Validic::Client.new
|
80
|
+
```
|
81
|
+
|
82
|
+
##### Plain ruby
|
83
|
+
```ruby
|
84
|
+
|
85
|
+
options = {
|
86
|
+
api_url: 'https://api.validic.com',
|
87
|
+
api_version: 'v1',
|
88
|
+
access_token: 'ORGANIZATION_ACCESS_TOKEN',
|
89
|
+
organization_id: 'ORGANIZATION_ID'
|
90
|
+
}
|
91
|
+
client = Validic::Client.new options
|
92
|
+
```
|
93
|
+
|
94
|
+
Now you can use the wrapper's helper methods to interface with the Validic API.
|
95
|
+
```ruby
|
96
|
+
# Get current organization metadata
|
97
|
+
client.get_organization
|
98
|
+
```
|
99
|
+
|
100
|
+
When your requests return an object they are returned as a Validic::Response
|
101
|
+
object. The Validic::Response typically includes summary metadata and an array
|
102
|
+
of record objects.
|
103
|
+
```ruby
|
104
|
+
client.get_routine.summary.results
|
105
|
+
client.get_routine.records.first.steps
|
106
|
+
```
|
107
|
+
|
108
|
+
You can pass a hash of options to calls that fetch data.
|
109
|
+
```ruby
|
110
|
+
client.get_routine(start_date: '2015-01-01T00:00:00+00:00')
|
111
|
+
```
|
112
|
+
|
113
|
+
### More Examples ###
|
114
|
+
|
115
|
+
You can override initialized organization id and access tokens for all helper
|
116
|
+
methods by passing parameters in an options hash as a final parameter.
|
117
|
+
|
118
|
+
Below are examples of all helper methods.
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
require 'validic'
|
122
|
+
|
123
|
+
# Alternatively you can use an initializer
|
124
|
+
options = {
|
125
|
+
api_url: 'https://api.validic.com',
|
126
|
+
api_version: 'v1',
|
127
|
+
access_token: 'ORGANIZATION_ACCESS_TOKEN',
|
128
|
+
organization_id: 'ORGANIZATION_ID'
|
129
|
+
}
|
130
|
+
client = Validic::Client.new options
|
131
|
+
```
|
132
|
+
|
133
|
+
## Organization methods
|
134
|
+
|
135
|
+
### Get Requests
|
136
|
+
Get requests will always return a Validic::Response object. It will look like this:
|
137
|
+
```ruby
|
138
|
+
sleeps = client.get_sleep
|
139
|
+
=> #<Validic::Response:0x007ff3c9e4daa8
|
140
|
+
@records=
|
141
|
+
[#<Validic::Sleep:0x007ff3c9e4eb60
|
142
|
+
@_id="54b9242798b4b18fff00000d",
|
143
|
+
@awake=12.0,
|
144
|
+
@deep=nil,
|
145
|
+
@last_updated="2015-01-16T14:45:59+00:00",
|
146
|
+
@light=nil,
|
147
|
+
@rem=nil,
|
148
|
+
@source="healthy_yet",
|
149
|
+
@source_name="HealthyYet",
|
150
|
+
@times_woken=nil,
|
151
|
+
@timestamp="2015-01-16T14:45:38+00:00",
|
152
|
+
@total_sleep=nil,
|
153
|
+
@user_id="54a2eda484626bb50a00002c",
|
154
|
+
@utc_offset="+00:00">
|
155
|
+
@summary=
|
156
|
+
#<Validic::Summary:0x007ff3c9e4eea8
|
157
|
+
@end_date="2015-01-17T23:59:59+00:00",
|
158
|
+
@limit=100,
|
159
|
+
@message="Ok",
|
160
|
+
@next=nil,
|
161
|
+
@offset=0,
|
162
|
+
@previous=nil,
|
163
|
+
@results=2,
|
164
|
+
@start_date="2015-01-15T00:00:00+00:00",
|
165
|
+
@status=200,
|
166
|
+
@timestamp=nil>>
|
167
|
+
```
|
168
|
+
|
169
|
+
Now you have access to a `Summary` object and an array of activity objects. You can step through either object like so:
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
sleeps.summary
|
173
|
+
=> #<Validic::Summary:0x007ff3ca2d98d8
|
174
|
+
@end_date="2015-01-17T23:59:59+00:00",
|
175
|
+
@limit=100,
|
176
|
+
@message="Ok",
|
177
|
+
@next=nil,
|
178
|
+
@offset=0,
|
179
|
+
@previous=nil,
|
180
|
+
@results=2,
|
181
|
+
@start_date="2015-01-15T00:00:00+00:00",
|
182
|
+
@status=200,
|
183
|
+
@timestamp=nil>
|
184
|
+
|
185
|
+
|
186
|
+
sleeps.summary.status
|
187
|
+
=> 200
|
188
|
+
|
189
|
+
|
190
|
+
sleeps.records.first
|
191
|
+
=> #<Validic::Sleep:0x007ff3ca2d9590
|
192
|
+
@_id="54b9242798b4b18fff00000d",
|
193
|
+
@awake=12.0,
|
194
|
+
@deep=nil,
|
195
|
+
@last_updated="2015-01-16T14:45:59+00:00",
|
196
|
+
@light=nil,
|
197
|
+
@rem=nil,
|
198
|
+
@source="healthy_yet",
|
199
|
+
@source_name="HealthyYet",
|
200
|
+
@times_woken=nil,
|
201
|
+
@timestamp="2015-01-16T14:45:38+00:00",
|
202
|
+
@total_sleep=nil,
|
203
|
+
@user_id="54a2eda484626bb50a00002c",
|
204
|
+
@utc_offset="+00:00">
|
205
|
+
|
206
|
+
|
207
|
+
sleeps.records.first.awake
|
208
|
+
=> 12.0
|
209
|
+
```
|
210
|
+
|
211
|
+
##### Get current organization
|
212
|
+
```ruby
|
213
|
+
client.get_organization
|
214
|
+
```
|
215
|
+
|
216
|
+
## [User methods](https://validic.com/api/docs#users)
|
217
|
+
|
218
|
+
##### Get users from organization credentials
|
219
|
+
```ruby
|
220
|
+
client.get_users
|
221
|
+
```
|
222
|
+
|
223
|
+
Get user by Validic user id.
|
224
|
+
```ruby
|
225
|
+
client.get_users(user_id: '5499a29b84626b0339000094')
|
226
|
+
```
|
227
|
+
|
228
|
+
##### Refresh authentication token
|
229
|
+
```ruby
|
230
|
+
client.refresh_token(user_id: '5499a29b84626b0339000094')
|
231
|
+
```
|
232
|
+
|
233
|
+
##### Get user id from authentication token
|
234
|
+
```ruby
|
235
|
+
client.me(authentication_token: 'L9RFSRnJvkwfiZm8vEc4')
|
236
|
+
```
|
237
|
+
|
238
|
+
##### Provision new users
|
27
239
|
```ruby
|
28
|
-
|
240
|
+
client.provision_user(uid: '123')
|
241
|
+
```
|
29
242
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
config.api_version = 'v1'
|
35
|
-
end
|
243
|
+
With optional profile.
|
244
|
+
```ruby
|
245
|
+
client.provision_user(uid: '123', profile: { gender: 'M' })
|
246
|
+
```
|
36
247
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
api_version: 'v1',
|
42
|
-
access_token: 'DEMO_KEY' # Replace this with your key
|
43
|
-
}
|
44
|
-
client = Validic::Client.new options
|
248
|
+
##### Updating a user
|
249
|
+
```ruby
|
250
|
+
client.update_user(user_id: '5499a29b84626b0339000094', uid: '123')
|
251
|
+
```
|
45
252
|
|
46
|
-
|
47
|
-
|
48
|
-
|
253
|
+
With optional profile.
|
254
|
+
```ruby
|
255
|
+
client.update_user(user_id: '5499a29b84626b0339000094', uid: '123', profile: { gender: 'M' })
|
256
|
+
```
|
49
257
|
|
50
|
-
|
51
|
-
|
258
|
+
##### Suspend a user
|
259
|
+
```ruby
|
260
|
+
client.suspend_user(user_id: '5499a29b84626b0339000094')
|
261
|
+
```
|
262
|
+
|
263
|
+
##### Unsuspend a user
|
264
|
+
```ruby
|
265
|
+
client.unsuspend_user(user_id: '5499a29b84626b0339000094')
|
266
|
+
```
|
267
|
+
|
268
|
+
##### Delete a user
|
269
|
+
```ruby
|
270
|
+
client.delete_user(user_id: '5499a29b84626b0339000094')
|
271
|
+
```
|
272
|
+
|
273
|
+
## [Profile methods](https://validic.com/api/docs#profile)
|
274
|
+
|
275
|
+
##### Get a user profile
|
276
|
+
```ruby
|
277
|
+
client.get_profile(authentication_token: 'L9RFSRnJvkwfiZm8vEc4')
|
278
|
+
```
|
52
279
|
|
53
|
-
|
54
|
-
|
55
|
-
|
280
|
+
##### Create a user profile
|
281
|
+
```ruby
|
282
|
+
client.create_profile(authentication_token: 'L9RFSRnJvkwfiZm8vEc4', gender: 'M')
|
283
|
+
```
|
284
|
+
|
285
|
+
## Apps methods
|
286
|
+
|
287
|
+
##### Get a list of available third-party-apps
|
288
|
+
```ruby
|
289
|
+
client.get_org_apps
|
290
|
+
```
|
291
|
+
|
292
|
+
##### Get a list of apps a user is synced to
|
293
|
+
```ruby
|
294
|
+
client.get_user_synced_apps(authentication_token: 'L9RFSRnJvkwfiZm8vEc4')
|
295
|
+
```
|
296
|
+
|
297
|
+
## Activity methods
|
298
|
+
|
299
|
+
###### You can also filter the results of the following methods by passing an options hash
|
300
|
+
|
301
|
+
##### Get an array of fitness records
|
302
|
+
```ruby
|
303
|
+
client.get_fitness
|
304
|
+
```
|
305
|
+
|
306
|
+
##### Get an array of routine records
|
307
|
+
```ruby
|
308
|
+
client.get_routine
|
309
|
+
```
|
310
|
+
|
311
|
+
##### Get an array of nutrition records
|
312
|
+
```ruby
|
313
|
+
client.get_nutritions
|
314
|
+
```
|
315
|
+
|
316
|
+
##### Get an array of weight records
|
317
|
+
```ruby
|
318
|
+
client.get_weight
|
319
|
+
```
|
320
|
+
|
321
|
+
##### Get an array of diabetes records
|
322
|
+
```ruby
|
323
|
+
client.get_diabetes
|
324
|
+
```
|
325
|
+
|
326
|
+
##### Get an array of biometrics records
|
327
|
+
```ruby
|
328
|
+
client.get_biometrics
|
329
|
+
```
|
330
|
+
|
331
|
+
##### Get an array of sleep records
|
332
|
+
```ruby
|
333
|
+
client.get_sleep
|
334
|
+
```
|
335
|
+
|
336
|
+
##### Get an array of tobacco cessation records
|
337
|
+
```ruby
|
338
|
+
client.get_tobacco_cessations
|
339
|
+
```
|
340
|
+
|
341
|
+
## [Validic Connect](https://validic.com/api/partners)
|
342
|
+
|
343
|
+
|
344
|
+
##### CRUD Operations
|
345
|
+
As a Validic Connect partner you have access to all CRUD operations including create, update and delete. The gem supports all 3 of these:
|
346
|
+
|
347
|
+
**Create**
|
348
|
+
```ruby
|
349
|
+
client.create_sleep(user_id: 'VALIDIC_USER_ID, activity_id: 'UNIQUE_ACTIVITY_ID', awake: 2, rem: 1, deep: 7)
|
350
|
+
=> #<Validic::Sleep:0x007fafcc2cdd40
|
351
|
+
@_id="54b93e1b84626b0581000012",
|
352
|
+
@activity_id="22323",
|
353
|
+
@awake=2.0,
|
354
|
+
@deep=7.0,
|
355
|
+
@extras=nil,
|
356
|
+
@last_updated="2015-01-16T16:36:43+00:00",
|
357
|
+
@light=nil,
|
358
|
+
@rem=1.0,
|
359
|
+
@source="healthy_yet",
|
360
|
+
@source_name="Healthy Yet",
|
361
|
+
@times_woken=nil,
|
362
|
+
@timestamp="2015-01-16T16:36:43+00:00",
|
363
|
+
@total_sleep=nil,
|
364
|
+
@utc_offset=nil,
|
365
|
+
@validated=false>
|
366
|
+
```
|
367
|
+
|
368
|
+
**Update**
|
369
|
+
|
370
|
+
```ruby
|
371
|
+
client.update_sleep(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID', timestamp: DateTime.now.new_offset(0).iso8601, rem: 4)
|
372
|
+
|
373
|
+
=> #<Validic::Sleep:0x007fafcc38fd28
|
374
|
+
@_id="54b93e1b84626b0581000012",
|
375
|
+
@activity_id="22323",
|
376
|
+
@awake=2.0,
|
377
|
+
@deep=7.0,
|
378
|
+
@extras=nil,
|
379
|
+
@last_updated="2015-01-16T16:38:23+00:00",
|
380
|
+
@light=nil,
|
381
|
+
@rem=4.0,
|
382
|
+
@source="healthy_yet",
|
383
|
+
@source_name="Healthy Yet",
|
384
|
+
@times_woken=nil,
|
385
|
+
@timestamp="2015-01-16T16:38:02+00:00",
|
386
|
+
@total_sleep=nil,
|
387
|
+
@utc_offset=nil,
|
388
|
+
@validated=false>
|
389
|
+
[13] pry(main)>
|
390
|
+
```
|
391
|
+
|
392
|
+
**Delete**
|
393
|
+
|
394
|
+
```ruby
|
395
|
+
client.delete_sleep(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID')
|
396
|
+
=> true
|
397
|
+
```
|
398
|
+
|
399
|
+
All objects have the same actions as outlined below.
|
400
|
+
|
401
|
+
|
402
|
+
##### [Fitness](https://validic.com/api/docs/#fitness)
|
403
|
+
```ruby
|
404
|
+
client.create_fitness(user_id: 'VALIDIC_USER_ID', activity_id: 'UNIQUE_ACTIVITY_ID', options)
|
405
|
+
client.update_fitness(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID', options)
|
406
|
+
client.delete_fitness(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID')
|
407
|
+
```
|
408
|
+
|
409
|
+
##### [Routine](https://validic.com/api/docs/#routine)
|
410
|
+
```ruby
|
411
|
+
client.create_routine(user_id: 'VALIDIC_USER_ID', activity_id: 'UNIQUE_ACTIVITY_ID', options)
|
412
|
+
client.update_routine(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID', options)
|
413
|
+
client.delete_routine(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID')
|
414
|
+
```
|
415
|
+
|
416
|
+
##### [Nutrition](https://validic.com/api/docs/#nutrition)
|
417
|
+
```ruby
|
418
|
+
client.create_nutrition(user_id: 'VALIDIC_USER_ID', activity_id: 'UNIQUE_ENTRY_ID', options)
|
419
|
+
client.update_nutrition(user_id: 'VALIDIC_USER_ID', _id: 'UNIQUE_ENTRY_ID', options)
|
420
|
+
client.delete_nutrition(user_id: 'VALIDIC_USER_ID', _id: 'UNIQUE_ENTRY_ID')
|
421
|
+
```
|
422
|
+
|
423
|
+
##### [Weight](https://validic.com/api/docs/#weight)
|
424
|
+
```ruby
|
425
|
+
client.create_weight(user_id: 'VALIDIC_USER_ID', data_id: 'UNIQUE_ENTRY_ID', options)
|
426
|
+
client.update_weight(user_id: 'VALIDIC_USER_ID', _id: 'UNIQUE_ENTRY_ID', options)
|
427
|
+
client.delete_weight(user_id: 'VALIDIC_USER_ID', _id: 'UNIQUE_ENTRY_ID')
|
428
|
+
```
|
429
|
+
|
430
|
+
##### [Diabetes](https://validic.com/api/docs/#diabetes)
|
431
|
+
```ruby
|
432
|
+
client.create_diabetes(user_id: 'VALIDIC_USER_ID', activity_id: 'UNIQUE_ACTIVITY_ID', options)
|
433
|
+
client.update_diabetes(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID', options)
|
434
|
+
client.delete_diabetes(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID')
|
435
|
+
```
|
436
|
+
|
437
|
+
##### [Biometrics](https://validic.com/api/docs/#biometrics)
|
438
|
+
```ruby
|
439
|
+
client.create_biometrics(user_id: 'VALIDIC_USER_ID', data_id: 'UNIQUE_ENTRY_ID', options)
|
440
|
+
client.update_biometrics(user_id: 'VALIDIC_USER_ID', _id: 'UNIQUE_ENTRY_ID', options)
|
441
|
+
client.delete_biometrics(user_id: 'VALIDIC_USER_ID', _id: 'UNIQUE_ENTRY_ID')
|
442
|
+
```
|
443
|
+
|
444
|
+
##### [Sleep](https://validic.com/api/docs/#sleep)
|
445
|
+
```ruby
|
446
|
+
client.create_sleep(user_id: 'VALIDIC_USER_ID', activity_id: 'UNIQUE_ACTIVITY_ID', options)
|
447
|
+
client.update_sleep(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_SLEEP_ID', options)
|
448
|
+
client.delete_sleep(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID')
|
449
|
+
```
|
450
|
+
|
451
|
+
##### [Tobacco Cessation](https://validic.com/api/docs/#tobacco_cessation)
|
452
|
+
```ruby
|
453
|
+
client.create_tobacco_cessation(user_id: 'VALIDIC_USER_ID', activity_id: 'UNIQUE_ACTIVITY_ID' options)
|
454
|
+
client.update_tobacco_cessation(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID', options)
|
455
|
+
client.delete_tobacco_cessation(user_id: 'VALIDIC_USER_ID', _id: 'VALIDIC_ACTIVITY_ID')
|
456
|
+
```
|
457
|
+
|
458
|
+
##### You can also create data with your own custom extras as JSON
|
459
|
+
```ruby
|
460
|
+
client.create_fitness(user_id: 'VALIDIC_USER_ID', activity_id: 'UNIQUE_ACTIVITY_ID', extras: "{\"stars\": 3}")
|
461
|
+
```
|
462
|
+
|
463
|
+
## [Latest Records](https://validic.com/api/bulkdata/#latest)
|
464
|
+
|
465
|
+
###### You can also pass an options hash to filter latest results
|
466
|
+
|
467
|
+
##### Pull latest records for specified type
|
468
|
+
```ruby
|
469
|
+
client.latest_routine
|
56
470
|
```
|
57
471
|
|
58
472
|
## Contributing
|