validic 0.3.3 → 0.4.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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.rspec +0 -1
  4. data/Gemfile +12 -1
  5. data/Gemfile.lock +32 -62
  6. data/README.md +442 -28
  7. data/lib/validic.rb +3 -20
  8. data/lib/validic/app.rb +11 -0
  9. data/lib/validic/biometrics.rb +9 -0
  10. data/lib/validic/client.rb +35 -77
  11. data/lib/validic/diabetes.rb +4 -60
  12. data/lib/validic/error.rb +33 -0
  13. data/lib/validic/extra.rb +10 -0
  14. data/lib/validic/fitness.rb +4 -57
  15. data/lib/validic/nutrition.rb +5 -61
  16. data/lib/validic/organization.rb +6 -13
  17. data/lib/validic/profile.rb +4 -39
  18. data/lib/validic/response.rb +15 -0
  19. data/lib/validic/rest/apps.rb +21 -0
  20. data/lib/validic/rest/biometrics.rb +39 -0
  21. data/lib/validic/rest/diabetes.rb +39 -0
  22. data/lib/validic/rest/fitness.rb +40 -0
  23. data/lib/validic/rest/nutrition.rb +40 -0
  24. data/lib/validic/rest/organizations.rb +12 -0
  25. data/lib/validic/rest/profile.rb +18 -0
  26. data/lib/validic/rest/request.rb +95 -0
  27. data/lib/validic/rest/routine.rb +40 -0
  28. data/lib/validic/rest/sleep.rb +41 -0
  29. data/lib/validic/rest/tobacco_cessation.rb +40 -0
  30. data/lib/validic/rest/users.rb +55 -0
  31. data/lib/validic/rest/utils.rb +28 -0
  32. data/lib/validic/rest/weight.rb +43 -0
  33. data/lib/validic/routine.rb +4 -55
  34. data/lib/validic/sleep.rb +4 -59
  35. data/lib/validic/summary.rb +18 -0
  36. data/lib/validic/tobacco_cessation.rb +4 -53
  37. data/lib/validic/user.rb +4 -99
  38. data/lib/validic/utils.rb +13 -0
  39. data/lib/validic/version.rb +1 -1
  40. data/lib/validic/weight.rb +4 -57
  41. data/spec/fixtures/apps.json +32 -0
  42. data/spec/fixtures/biometrics-expanded.json +56 -0
  43. data/spec/fixtures/biometrics-extras.json +35 -0
  44. data/spec/fixtures/biometrics_record.json +36 -0
  45. data/spec/fixtures/biometrics_records.json +54 -0
  46. data/spec/fixtures/bulk_biometrics_records.json +55 -0
  47. data/spec/fixtures/bulk_diabetes_records.json +37 -0
  48. data/spec/fixtures/bulk_fitnesses.json +35 -0
  49. data/spec/fixtures/bulk_nutritions.json +37 -0
  50. data/spec/fixtures/bulk_sleeps.json +35 -0
  51. data/spec/fixtures/bulk_tobacco_cessations.json +33 -0
  52. data/spec/fixtures/conflict.json +5 -0
  53. data/spec/fixtures/diabetes-expanded.json +38 -0
  54. data/spec/fixtures/diabetes-extras.json +17 -0
  55. data/spec/fixtures/diabetes_record.json +18 -0
  56. data/spec/fixtures/diabetes_records.json +36 -0
  57. data/spec/fixtures/fitness-expanded.json +1521 -0
  58. data/spec/fixtures/fitness-extras.json +15 -0
  59. data/spec/fixtures/fitness.json +16 -0
  60. data/spec/fixtures/fitnesses.json +34 -0
  61. data/spec/fixtures/forbidden.json +5 -0
  62. data/spec/fixtures/internal_server.json +4 -0
  63. data/spec/fixtures/me.json +5 -0
  64. data/spec/fixtures/not_found.json +5 -0
  65. data/spec/fixtures/nutrition-expanded.json +123 -0
  66. data/spec/fixtures/nutrition-extras.json +13 -0
  67. data/spec/fixtures/nutrition.json +18 -0
  68. data/spec/fixtures/nutritions-expanded.json +123 -0
  69. data/spec/fixtures/nutritions.json +36 -0
  70. data/spec/fixtures/organizations.json +27 -0
  71. data/spec/fixtures/profile.json +13 -0
  72. data/spec/fixtures/refresh_token.json +7 -0
  73. data/spec/fixtures/routine-expanded.json +749 -0
  74. data/spec/fixtures/routine-extras.json +14 -0
  75. data/spec/fixtures/routine.json +17 -0
  76. data/spec/fixtures/routines.json +47 -0
  77. data/spec/fixtures/sleep-expanded.json +51 -0
  78. data/spec/fixtures/sleep-extras.json +15 -0
  79. data/spec/fixtures/sleep.json +16 -0
  80. data/spec/fixtures/sleeps.json +48 -0
  81. data/spec/fixtures/synced_apps.json +43 -0
  82. data/spec/fixtures/tobacco_cessation-expanded.json +33 -0
  83. data/spec/fixtures/tobacco_cessation-extras.json +12 -0
  84. data/spec/fixtures/tobacco_cessation.json +14 -0
  85. data/spec/fixtures/tobacco_cessations.json +32 -0
  86. data/spec/fixtures/unauthorized.json +4 -0
  87. data/spec/fixtures/unprocessable_entity.json +5 -0
  88. data/spec/fixtures/updated_user.json +9 -0
  89. data/spec/fixtures/user.json +8 -0
  90. data/spec/fixtures/user_with_profile.json +14 -0
  91. data/spec/fixtures/users.json +23 -0
  92. data/spec/fixtures/weight-expanded.json +66 -0
  93. data/spec/fixtures/weight-extras.json +15 -0
  94. data/spec/fixtures/weight.json +18 -0
  95. data/spec/fixtures/weights.json +48 -0
  96. data/spec/spec_helper.rb +47 -33
  97. data/spec/validic/client_spec.rb +5 -38
  98. data/spec/validic/error_spec.rb +73 -0
  99. data/spec/validic/expanded_spec.rb +87 -0
  100. data/spec/validic/rest/apps_spec.rb +41 -0
  101. data/spec/validic/rest/biometrics_spec.rb +131 -0
  102. data/spec/validic/rest/diabetes_spec.rb +131 -0
  103. data/spec/validic/rest/fitness_spec.rb +131 -0
  104. data/spec/validic/rest/nutrition_spec.rb +144 -0
  105. data/spec/validic/rest/organizations_spec.rb +24 -0
  106. data/spec/validic/rest/profile_spec.rb +44 -0
  107. data/spec/validic/rest/routine_spec.rb +129 -0
  108. data/spec/validic/rest/sleep_spec.rb +148 -0
  109. data/spec/validic/rest/tobacco_cessation_spec.rb +131 -0
  110. data/spec/validic/rest/users_spec.rb +170 -0
  111. data/spec/validic/rest/weight_spec.rb +150 -0
  112. data/spec/validic/summary_spec.rb +3 -0
  113. data/spec/validic_spec.rb +19 -31
  114. data/validic.gemspec +0 -13
  115. metadata +174 -194
  116. data/lib/validic/biometric.rb +0 -97
  117. data/lib/validic/request.rb +0 -46
  118. data/lib/validic/third_party_app.rb +0 -32
  119. data/spec/validic/biometrics_spec.rb +0 -43
  120. data/spec/validic/diabetes_spec.rb +0 -89
  121. data/spec/validic/fitness_spec.rb +0 -85
  122. data/spec/validic/nutrition_spec.rb +0 -91
  123. data/spec/validic/organization_spec.rb +0 -26
  124. data/spec/validic/profile_spec.rb +0 -19
  125. data/spec/validic/routine_spec.rb +0 -82
  126. data/spec/validic/sleep_spec.rb +0 -86
  127. data/spec/validic/third_party_app_spec.rb +0 -32
  128. data/spec/validic/tobacco_cessation_spec.rb +0 -81
  129. data/spec/validic/user_spec.rb +0 -81
  130. data/spec/validic/weight_spec.rb +0 -88
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad0946cb134fc6c0f3cfacae4651b8c0b963c0a4
4
- data.tar.gz: f43d9e397bfe891fcca689d48723a2930b8a1823
3
+ metadata.gz: c8852001360881e470bc390ff9e44d0c83f8c42c
4
+ data.tar.gz: e3494be76d5d6794db140f08a7228b8ed9788430
5
5
  SHA512:
6
- metadata.gz: 0309253dd92b1d88408a37c9beb8b30a2dcaa7dfd5c613093abbd86284a763320c295573cffb87913a46781fd37e886cf54a6ed67a78f7d31c15f821c7ea92a2
7
- data.tar.gz: f4c1f6a3ac30ed57f79592341a209fa49ce5385ae86814f8c97f7c88f6958a423a2f4b16bb70e7ca9c4ebf2885e7c3866262ac565f21735e390b5b10b7486b37
6
+ metadata.gz: 3ca048da5b89cbada497942557373b0b9d25bc25d296c238349edf72211caf5054a38832b3e26cc8477ea5c8ad36050476eb861e65791941ec0e867c1ab77394
7
+ data.tar.gz: 06ef87e636504d0db352769653d77bbb690e8e94d156a8c1dda454f99886f3a30897df85443aefd4e98dad4f47afb4de719b7555f81d598150668666f0157ded
data/.gitignore CHANGED
@@ -8,7 +8,6 @@ lib/bundler/man
8
8
  pkg
9
9
  rdoc
10
10
  spec/reports
11
- spec/cassette
12
11
  test/tmp
13
12
  test/version_tmp
14
13
  tmp
@@ -20,3 +19,5 @@ tmp
20
19
  .yardoc
21
20
  _yardoc
22
21
  doc/
22
+ bin/
23
+ tags
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --format documentation
3
2
  --tty
data/Gemfile CHANGED
@@ -1,4 +1,15 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in validic.gemspec
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
@@ -1,87 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- validic (0.3.3)
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
- 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)
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
- docile (1.1.2)
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
- hashie (2.0.5)
34
- i18n (0.6.9)
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
- nokogiri (1.6.1)
40
- mini_portile (~> 0.5.0)
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 (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)
48
- diff-lcs (>= 1.1.3, < 2.0)
49
- rspec-mocks (2.14.4)
50
- safe_yaml (0.9.7)
51
- shoulda (3.5.0)
52
- shoulda-context (~> 1.0, >= 1.0.1)
53
- shoulda-matchers (>= 1.4.1, < 3.0)
54
- shoulda-context (1.1.6)
55
- shoulda-matchers (2.5.0)
56
- activesupport (>= 3.0.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)
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
- vcr (~> 2.8.0)
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
- ## Stable Version: 0.3.2
8
+ Ruby API Wrapper for [Validic](http://www.validic.com/api/docs). It includes the
9
+ following functionality:
10
10
 
11
- ## Installation
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
- require 'validic'
240
+ client.provision_user(uid: '123')
241
+ ```
29
242
 
30
- # If you're using Rails 3+
31
- # config/initializers/validic.rb
32
- Validic.configure do |config|
33
- config.api_url = 'https://api.validic.com'
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
- # If you're using plain RUBY
38
- # Create Validic::Client Object
39
- options = {
40
- api_url: 'https://api.validic.com',
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
- # Create a Client Object expecting you have an initializer in place
47
- # Validic::Client Object
48
- client = Validic::Client.new
253
+ With optional profile.
254
+ ```ruby
255
+ client.update_user(user_id: '5499a29b84626b0339000094', uid: '123', profile: { gender: 'M' })
256
+ ```
49
257
 
50
- # => Get Account Fitness
51
- client.get_fitness
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
- # => Get Organization Fitness
54
- client.get_fitness({organization_id: "YOUR_organization_id",
55
- access_token: "YOUR_ACCESS_TOKEN"})
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