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
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'validic/tobacco_cessation'
|
2
|
+
|
3
|
+
module Validic
|
4
|
+
module REST
|
5
|
+
module TobaccoCessation
|
6
|
+
|
7
|
+
def get_tobacco_cessation(options = {})
|
8
|
+
resp = get_request(:tobacco_cessation, options)
|
9
|
+
build_response_attr(resp)
|
10
|
+
end
|
11
|
+
alias :get_tobacco_cessations :get_tobacco_cessation
|
12
|
+
|
13
|
+
def create_tobacco_cessation(options = {})
|
14
|
+
user_id = options.delete(:user_id)
|
15
|
+
options = { user_id: user_id, tobacco_cessation: options }
|
16
|
+
response = post_request(:tobacco_cessation, options)
|
17
|
+
Validic::TobaccoCessation.new(response['tobacco_cessation'])
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_tobacco_cessation(options = {})
|
21
|
+
user_id, _id = options.delete(:user_id), options.delete(:_id)
|
22
|
+
options = { user_id: user_id, _id: _id, tobacco_cessation: options }
|
23
|
+
response = put_request(:tobacco_cessation, options)
|
24
|
+
Validic::TobaccoCessation.new(response['tobacco_cessation'])
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete_tobacco_cessation(options = {})
|
28
|
+
user_id, _id = options.delete(:user_id), options.delete(:_id)
|
29
|
+
options = { user_id: user_id, _id: _id }
|
30
|
+
delete_request(:tobacco_cessation, options)
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def latest_tobacco_cessation(options = {})
|
35
|
+
resp = latest(:tobacco_cessation, options)
|
36
|
+
build_response_attr(resp)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'validic/user'
|
2
|
+
|
3
|
+
module Validic
|
4
|
+
module REST
|
5
|
+
module Users
|
6
|
+
|
7
|
+
def get_users(options = {})
|
8
|
+
resp = get_request(:users, options)
|
9
|
+
build_response_attr(resp)
|
10
|
+
end
|
11
|
+
alias :get_user :get_users
|
12
|
+
|
13
|
+
def refresh_token(options = {})
|
14
|
+
response = get_request(:refresh_token, options)
|
15
|
+
Validic::User.new(response['user'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def me(options = {})
|
19
|
+
response = get_request(:me, options)
|
20
|
+
response['me']['_id']
|
21
|
+
end
|
22
|
+
|
23
|
+
def provision_user(options = {})
|
24
|
+
response = post_request(:users, { user: options })
|
25
|
+
Validic::User.new(response['user'])
|
26
|
+
end
|
27
|
+
alias :user_provision :provision_user
|
28
|
+
|
29
|
+
def update_user(options = {})
|
30
|
+
user_id = options.delete(:user_id)
|
31
|
+
response = put_request(:users, { user_id: user_id, user: options })
|
32
|
+
Validic::User.new(response['user'])
|
33
|
+
end
|
34
|
+
alias :user_update :update_user
|
35
|
+
|
36
|
+
def delete_user(options = {})
|
37
|
+
delete_request(:users, { user_id: options[:user_id] })
|
38
|
+
true
|
39
|
+
end
|
40
|
+
alias :user_delete :delete_user
|
41
|
+
|
42
|
+
def suspend_user(options = {})
|
43
|
+
put_request(:users, { user_id: options[:user_id], suspend: '1' })
|
44
|
+
true
|
45
|
+
end
|
46
|
+
alias :user_suspend :suspend_user
|
47
|
+
|
48
|
+
def unsuspend_user(options = {})
|
49
|
+
put_request(:users, { user_id: options[:user_id], suspend: '0' })
|
50
|
+
true
|
51
|
+
end
|
52
|
+
alias :user_unsuspend :unsuspend_user
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'validic/response'
|
2
|
+
require 'validic/summary'
|
3
|
+
|
4
|
+
module Validic
|
5
|
+
module REST
|
6
|
+
module Utils
|
7
|
+
private
|
8
|
+
|
9
|
+
def build_response_attr(resp)
|
10
|
+
summary = Validic::Summary.new(resp.delete("summary"))
|
11
|
+
Validic::Response.new(summary, response_object(resp))
|
12
|
+
end
|
13
|
+
|
14
|
+
def response_object(resp)
|
15
|
+
return resp.values.first if resp.values.first.is_a? Hash
|
16
|
+
klass = Validic.const_get(camelize_response_key(resp))
|
17
|
+
resp.values.flatten.collect { |obj| klass.new(obj) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def camelize_response_key(resp)
|
21
|
+
key = resp.keys.first
|
22
|
+
key = key.include?('_') ? key.split('_').map(&:capitalize).join : key.capitalize
|
23
|
+
key.chop! if %w(Users Apps).include?(key) #strip last letter off to match ::User or ::App
|
24
|
+
key
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'validic/weight'
|
2
|
+
|
3
|
+
module Validic
|
4
|
+
module REST
|
5
|
+
module Weight
|
6
|
+
|
7
|
+
def get_weight(params={})
|
8
|
+
resp = get_request(:weight, params)
|
9
|
+
build_response_attr(resp)
|
10
|
+
end
|
11
|
+
|
12
|
+
alias :get_weights :get_weight
|
13
|
+
|
14
|
+
def create_weight(options={})
|
15
|
+
user_id = options.delete(:user_id)
|
16
|
+
options = { user_id: user_id, weight: options }
|
17
|
+
resp = post_request(:weight, options)
|
18
|
+
|
19
|
+
Validic::Weight.new(resp['weight'])
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_weight(options={})
|
23
|
+
user_id, _id = options.delete(:user_id), options.delete(:_id)
|
24
|
+
options = { user_id: user_id, _id: _id, weight: options }
|
25
|
+
response = put_request(:weight, options)
|
26
|
+
Validic::Weight.new(response["weight"])
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete_weight(options = {})
|
30
|
+
user_id, _id = options.delete(:user_id), options.delete(:_id)
|
31
|
+
options = { user_id: user_id, _id: _id }
|
32
|
+
delete_request(:weight, options)
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def latest_weight(options={})
|
37
|
+
resp = latest(:weight, options)
|
38
|
+
build_response_attr(resp)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/validic/routine.rb
CHANGED
@@ -1,59 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Validic
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# Default data fetched is from yesterday
|
9
|
-
#
|
10
|
-
# @params :organization_id - for organization specific
|
11
|
-
# @params :user_id - for user specific
|
12
|
-
#
|
13
|
-
# @params :start_date - optional
|
14
|
-
# @params :end_date - optional
|
15
|
-
# @params :access_token - override for default access_token
|
16
|
-
# @params :source - optional - data per source (e.g 'fitbit')
|
17
|
-
# @params :expanded - optional - will show the raw data
|
18
|
-
#
|
19
|
-
# @return [Hashie::Mash] with list of Routine
|
20
|
-
def get_routine(params={})
|
21
|
-
params = extract_params(params)
|
22
|
-
get_endpoint(:routine, params)
|
2
|
+
class Routine
|
3
|
+
include Validic::Utils
|
4
|
+
def initialize(attrs = {})
|
5
|
+
attributes_builder(attrs, self)
|
23
6
|
end
|
24
|
-
|
25
|
-
alias :get_routines :get_routine
|
26
|
-
|
27
|
-
##
|
28
|
-
# Create Routine base on `access_token` and `authentication_token`
|
29
|
-
#
|
30
|
-
# @params :access_token - *required if not specified on your initializer / organization access_token
|
31
|
-
# @params :authentication_token - *required / authentication_token of a specific user
|
32
|
-
#
|
33
|
-
# @params :steps
|
34
|
-
# @params :stairs_climbed
|
35
|
-
# @params :calories_burned
|
36
|
-
# @params :calories_consumed
|
37
|
-
# @params :timestamp
|
38
|
-
# @params :source
|
39
|
-
#
|
40
|
-
# @return success
|
41
|
-
def create_routine(options={})
|
42
|
-
options = {
|
43
|
-
access_token: options[:access_token],
|
44
|
-
routine: {
|
45
|
-
steps: options[:steps],
|
46
|
-
stairs_climbed: options[:stairs_climbed],
|
47
|
-
calories_burned: options[:calories_burned],
|
48
|
-
calories_consumed: options[:calories_consumed],
|
49
|
-
timestamp: options[:timestamp],
|
50
|
-
source: options[:source]
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
response = post("/#{Validic.api_version}/routine.json", options)
|
55
|
-
response if response
|
56
|
-
end
|
57
|
-
|
58
7
|
end
|
59
8
|
end
|
data/lib/validic/sleep.rb
CHANGED
@@ -1,63 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Validic
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# Default data fetched is from yesterday
|
9
|
-
#
|
10
|
-
# @params :organization_id - for organization specific
|
11
|
-
# @params :user_id - for user specific
|
12
|
-
#
|
13
|
-
# @params :start_date - optional
|
14
|
-
# @params :end_date - optional
|
15
|
-
# @params :access_token - override for default access_token
|
16
|
-
# @params :source - optional - data per source (e.g 'fitbit')
|
17
|
-
# @params :expanded - optional - will show the raw data
|
18
|
-
#
|
19
|
-
# @return [Hashie::Mash] with list of Sleep
|
20
|
-
def get_sleep(params={})
|
21
|
-
params = extract_params(params)
|
22
|
-
get_endpoint(:sleep, params)
|
2
|
+
class Sleep
|
3
|
+
include Validic::Utils
|
4
|
+
def initialize(attrs = {})
|
5
|
+
attributes_builder(attrs, self)
|
23
6
|
end
|
24
|
-
|
25
|
-
alias :get_sleeps :get_sleep
|
26
|
-
|
27
|
-
##
|
28
|
-
# Create Sleep base on `access_token` and `authentication_token`
|
29
|
-
#
|
30
|
-
# @params :access_token - *required if not specified on your initializer / organization access_token
|
31
|
-
# @params :authentication_token - *required / authentication_token of a specific user
|
32
|
-
#
|
33
|
-
# @params :total_sleep
|
34
|
-
# @params :awake
|
35
|
-
# @params :deep
|
36
|
-
# @params :light
|
37
|
-
# @params :rem
|
38
|
-
# @params :times_woken
|
39
|
-
# @params :timestamp
|
40
|
-
# @params :source
|
41
|
-
#
|
42
|
-
# @return success
|
43
|
-
def create_sleep(options={})
|
44
|
-
options = {
|
45
|
-
access_token: options[:access_token],
|
46
|
-
sleep: {
|
47
|
-
total_sleep: options[:total_sleep],
|
48
|
-
awake: options[:awake],
|
49
|
-
deep: options[:deep],
|
50
|
-
light: options[:light],
|
51
|
-
rem: options[:rem],
|
52
|
-
times_woken: options[:times_woken],
|
53
|
-
timestamp: options[:timestamp],
|
54
|
-
source: options[:source]
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
response = post("/#{Validic.api_version}/sleep.json", options)
|
59
|
-
response if response
|
60
|
-
end
|
61
|
-
|
62
7
|
end
|
63
8
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Validic
|
2
|
+
class Summary
|
3
|
+
attr_reader :timestamp, :start_date, :end_date, :offset, :message,
|
4
|
+
:results, :limit, :previous, :next, :status
|
5
|
+
def initialize(sum_hash)
|
6
|
+
@timestamp = sum_hash["timestamp"]
|
7
|
+
@status = sum_hash["status"]
|
8
|
+
@offset = sum_hash["offset"]
|
9
|
+
@message = sum_hash["message"]
|
10
|
+
@results = sum_hash["results"]
|
11
|
+
@start_date = sum_hash["start_date"]
|
12
|
+
@end_date = sum_hash["end_date"]
|
13
|
+
@limit = sum_hash["limit"]
|
14
|
+
@previous = sum_hash["previous"]
|
15
|
+
@next = sum_hash["next"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,57 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Validic
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# Default data fetched is from yesterday
|
9
|
-
#
|
10
|
-
# @params :organization_id - for organization specific
|
11
|
-
# @params :user_id - for user specific
|
12
|
-
#
|
13
|
-
# @params :start_date - optional
|
14
|
-
# @params :end_date - optional
|
15
|
-
# @params :access_token - override for default access_token
|
16
|
-
# @params :source - optional - data per source (e.g 'fitbit')
|
17
|
-
# @params :expanded - optional - will show the raw data
|
18
|
-
#
|
19
|
-
# @return [Hashie::Mash] with list of TobaccoCessation
|
20
|
-
def get_tobacco_cessations(params={})
|
21
|
-
params = extract_params(params)
|
22
|
-
get_endpoint(:tobacco_cessation, params)
|
2
|
+
class TobaccoCessation
|
3
|
+
include Validic::Utils
|
4
|
+
def initialize(attrs = {})
|
5
|
+
attributes_builder(attrs, self)
|
23
6
|
end
|
24
|
-
|
25
|
-
##
|
26
|
-
# Create TobaccoCessation base on `access_token` and `authentication_token`
|
27
|
-
#
|
28
|
-
# @params :access_token - *required if not specified on your initializer / organization access_token
|
29
|
-
# @params :authentication_token - *required / authentication_token of a specific user
|
30
|
-
#
|
31
|
-
# @params :cigarettes_allowed
|
32
|
-
# @params :cigarettes_smoked
|
33
|
-
# @params :cravings
|
34
|
-
# @params :last_smoked
|
35
|
-
# @params :timestamp
|
36
|
-
# @params :source
|
37
|
-
#
|
38
|
-
# @return success
|
39
|
-
def create_tobacco_cessation(options={})
|
40
|
-
options = {
|
41
|
-
access_token: options[:access_token],
|
42
|
-
tobacco_cessation: {
|
43
|
-
cigarettes_allowed: options[:cigarettes_allowed],
|
44
|
-
cigarettes_smoked: options[:cigarettes_smoked],
|
45
|
-
cravings: options[:cravings],
|
46
|
-
last_smoked: options[:last_smoked],
|
47
|
-
timestamp: options[:timestamp],
|
48
|
-
source: options[:source]
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
response = post("/#{Validic.api_version}/tobacco_cessation.json", options)
|
53
|
-
response if response
|
54
|
-
end
|
55
|
-
|
56
7
|
end
|
57
8
|
end
|
data/lib/validic/user.rb
CHANGED
@@ -1,103 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Validic
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
22
|
-
##
|
23
|
-
# Get User id base on `access_token`
|
24
|
-
#
|
25
|
-
# @return id
|
26
|
-
def me(options={})
|
27
|
-
options = {
|
28
|
-
access_token: options[:access_token]
|
29
|
-
}
|
30
|
-
response = get("/#{Validic.api_version}/me.json", options)
|
31
|
-
response if response
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
# POST User info for provisioning base on `access_token`
|
36
|
-
#
|
37
|
-
# @params[:organization_id] -- organization_id -- String
|
38
|
-
# @params[:access_token] -- organization's access_token -- String
|
39
|
-
# @params[:uid] -- uid for the new user -- String
|
40
|
-
# @params[:height] -- info for user -- Integer
|
41
|
-
# @params[:weight] -- info for user -- String
|
42
|
-
# @params[:location] -- info for user -- String
|
43
|
-
# @params[:gender] -- info for user -- String
|
44
|
-
# @params[:birth_year] -- info for user -- String
|
45
|
-
#
|
46
|
-
# @return user object
|
47
|
-
def user_provision(options={})
|
48
|
-
organization_id = options[:organization_id]
|
49
|
-
options = {
|
50
|
-
access_token: options[:access_token],
|
51
|
-
user: {
|
52
|
-
uid: options[:uid],
|
53
|
-
profile: {
|
54
|
-
height: options[:height],
|
55
|
-
gender: options[:gender],
|
56
|
-
location: options[:location],
|
57
|
-
weight: options[:weight]
|
58
|
-
}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
response = post("/#{Validic.api_version}/organizations/#{organization_id}/users.json", options)
|
62
|
-
response if response
|
63
|
-
end
|
64
|
-
|
65
|
-
##
|
66
|
-
#
|
67
|
-
# PUT request for suspending a user
|
68
|
-
#
|
69
|
-
# @params[:organization_id] -- String
|
70
|
-
# @params[:access_token] -- String -- organization's access_token
|
71
|
-
# @params[:user_id] -- String -- user's ID to suspend
|
72
|
-
# @params[:suspend] -- Boolean -- (1/0)
|
73
|
-
#
|
74
|
-
# @return user object
|
75
|
-
def user_suspend(options={})
|
76
|
-
organization_id = options[:organization_id]
|
77
|
-
user_id = options[:user_id]
|
78
|
-
options = {
|
79
|
-
suspend: options[:suspend],
|
80
|
-
access_token: options[:access_token]
|
81
|
-
}
|
82
|
-
|
83
|
-
response = put("/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}.json", options)
|
84
|
-
response
|
85
|
-
end
|
86
|
-
|
87
|
-
##
|
88
|
-
#
|
89
|
-
# DELETE request for deleting a user
|
90
|
-
#
|
91
|
-
# @params[:organization_id] -- String
|
92
|
-
# @params[:access_token] -- String -- organization's access_token
|
93
|
-
# @params[:uid] -- String -- user's ID to suspend
|
94
|
-
#
|
95
|
-
# @return [Hashie::Mash] with response
|
96
|
-
def user_delete(options={})
|
97
|
-
organization_id = options[:organization_id]
|
98
|
-
|
99
|
-
response = delete("/#{Validic.api_version}/organizations/#{organization_id}/users.json", options)
|
100
|
-
response
|
2
|
+
class User
|
3
|
+
include Validic::Utils
|
4
|
+
def initialize(attrs = {})
|
5
|
+
attributes_builder(attrs, self)
|
101
6
|
end
|
102
7
|
end
|
103
8
|
end
|