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.
@@ -1,73 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Validic
4
- module Activity
5
-
6
- ##
7
- # Get Activity base on `access_token`
8
- # Default data fetched is from yesterday
9
- #
10
- # @params :organization_id - for organization specific activity
11
- # @params :user_id - for user specific activity
12
- #
13
- # @params :start_date - optional
14
- # @params :end_date - optional
15
- # @params :access_token - override for default access_token
16
- #
17
- # @return [Hashie::Mash] with list of Activity
18
- def get_activities(options={})
19
- organization_id = options[:organization_id]
20
- user_id = options[:user_id]
21
- options = {
22
- access_token: options[:access_token],
23
- start_date: options[:start_date],
24
- end_date: options[:end_date]
25
- }
26
-
27
- if organization_id
28
- response = get("/#{Validic.api_version}/organizations/#{organization_id}/fitness.json", options)
29
- elsif user_id
30
- response = get("/#{Validic.api_version}/users/#{user_id}/fitness.json", options)
31
- else
32
- response = get("/#{Validic.api_version}/fitness.json", options)
33
- end
34
-
35
- response if response
36
- end
37
-
38
- ##
39
- # Get the latest Activities base on 'access_token'
40
- # for organization or for a specific user
41
- #
42
- # @activity_type - mandatory - specify what type of activity to fetch
43
- # List of activity_types
44
- # [ fitness, routine, weight, nutrition, sleep, diabetes, biometrics, tobacco_cessation ]
45
- #
46
- # @params :organization_id - optional - supply only this to get all user's activities belonging to organization
47
- # @params :user_id - optional - supply only this to get the user's latest activities
48
- def get_latest_activities(options={})
49
- activity_type = options[:activity_type]
50
- organization_id = options[:organization_id]
51
- user_id = options[:user_id]
52
- options = {
53
- access_token: options[:access_token]
54
- }
55
-
56
- if activity_type.blank?
57
- response = "Invalid api request. params[:activity_type] can't be blank."
58
- else
59
- if organization_id && user_id
60
- response = get("/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{activity_type}/latest", options)
61
- elsif organization_id && user_id.blank?
62
- response = get("/#{Validic.api_version}/organizations/#{organization_id}/#{activity_type}/latest", options)
63
- elsif user_id && organization_id.blank?
64
- response = get("/#{Validic.api_version}/users/#{user_id}/#{activity_type}/latest", options)
65
- else
66
- response = get("/#{Validic.api_version}/#{activity_type}/latest", options)
67
- end
68
- end
69
- response if response
70
- end
71
-
72
- end
73
- end
data/spec/.DS_Store DELETED
Binary file
@@ -1,97 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::Activity do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_activities" do
9
- before do
10
- @activities_response = client.get_activities({})
11
- end
12
-
13
- it "returns JSON response of Validic::Activity", vcr: true do
14
- @activities_response.should_not be_nil
15
- end
16
-
17
- it "status 200" do
18
- @activities_response.summary.status.should == 200
19
- end
20
-
21
- it "has summary node" do
22
- @activities_response.summary.should_not be_nil
23
- end
24
- end
25
-
26
- context "#get_activities via organization" do
27
- before do
28
- @activities_response = client.get_activities({organization_id: "519e24e16a7e0cc7ef00002b", access_token: "ENTERPRISE_KEY"})
29
- end
30
-
31
- it "returns JSON response of Validic::Activity", vcr: true do
32
- @activities_response.should_not be_nil
33
- end
34
-
35
- it "status 200" do
36
- @activities_response.summary.status.should == 200
37
- end
38
-
39
- it "has summary node" do
40
- @activities_response.summary.should_not be_nil
41
- end
42
- end
43
-
44
- context "#get_activities of a user" do
45
- before do
46
- @activities_response = client.get_activities({user_id: "519e24e16a7e0cc7ef00002c"})
47
- end
48
-
49
- it "returns JSON response of Validic::Activity", vcr: true do
50
- @activities_response.should_not be_nil
51
- end
52
-
53
- it "status 200" do
54
- @activities_response.summary.status.should == 200
55
- end
56
-
57
- it "has summary node" do
58
- @activities_response.summary.should_not be_nil
59
- end
60
- end
61
-
62
- context "#get_latest_activities of a user base on activity_type" do
63
- before do
64
- @latest_activities_response = client.get_latest_activities(user_id: "519e24e16a7e0cc7ef00002c", access_token: "9c03ad2bcb022425944e4686d398ef8398f537c2f7c113495ffa7bc9cfa49286", activity_type: "routine")
65
- end
66
-
67
- it "returns JSON response of Validic::Activity", vcr: true do
68
- @latest_activities_response.should_not be_nil
69
- end
70
-
71
- it "status 200" do
72
- @latest_activities_response.summary.status.should == 200
73
- end
74
-
75
- it "has summary node" do
76
- @latest_activities_response.summary.should_not be_nil
77
- end
78
- end
79
-
80
- context "#get_latest_activities of an organization base on activity_type" do
81
- before do
82
- @latest_activities_response = client.get_latest_activities(organization_id: "519e24e16a7e0cc7ef00002b", activity_type: "routine", access_token: "296a9c1d73c1b40af4c8e643336cb25524caf2a7679ba92c192855160572fdb1")
83
- end
84
-
85
- it "returns JSON response of Validic::Activity", vcr: true do
86
- @latest_activities_response.should_not be_nil
87
- end
88
-
89
- it "status 200" do
90
- @latest_activities_response.summary.status.should == 200
91
- end
92
-
93
- it "has summary node" do
94
- @latest_activities_response.summary.should_not be_nil
95
- end
96
- end
97
- end
@@ -1,120 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::GeneralMeasurement do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_general_measurements" do
9
- before do
10
- @general_measurement = client.get_general_measurements({})
11
- end
12
-
13
- it "returns JSON response of Validic::GeneralMeasurement", vcr: true do
14
- @general_measurement.should_not be_nil
15
- end
16
-
17
- it "status 200" do
18
- @general_measurement.summary.status.should == 200
19
- end
20
-
21
- it "has summary node" do
22
- @general_measurement.summary.should_not be_nil
23
- end
24
- end
25
-
26
- context "#create_general_measurement" do
27
- it "should create new general_measurement record" do
28
- @new_general_measurement = client.create_general_measurement({authentication_token: "mqwpDx8RYcmSFBJDmy3J",
29
- access_token: "DEMO_KEY",
30
- timestamp: "2013-05-16 07:12:16 -05:00",
31
- blood_calcium: 7.6,
32
- blood_chromium: 1.75,
33
- blood_folic_acid: 4.4,
34
- blood_magnesium: 1.24,
35
- blood_potassium: 1.9,
36
- blood_sodium: 122.1,
37
- blood_vitamin_b12: 600,
38
- blood_zinc: 120,
39
- creatine_kinase: 75,
40
- crp: 1,
41
- diastolic: 72,
42
- ferritin: 175,
43
- hdl: 41,
44
- hscrp: 0.91,
45
- il6: 0.94,
46
- resting_heartrate: 75,
47
- systolic: 115,
48
- testosterone: 255,
49
- total_cholesterol: 150,
50
- tsh: 0.8,
51
- uric_acid: 7.4,
52
- vitamin_d: 55.3,
53
- white_cell_count: 7685.34,
54
- source: "Sample App"})
55
- @new_general_measurement.should_not be_nil
56
- @new_general_measurement.general_measurement.timestamp.should eq "2013-05-16 07:12:16 -05:00"
57
- @new_general_measurement.general_measurement.blood_calcium.should eq 7.6
58
- @new_general_measurement.general_measurement.blood_chromium.should eq 1.75
59
- @new_general_measurement.general_measurement.blood_folic_acid.should eq 4.4
60
- @new_general_measurement.general_measurement.blood_magnesium.should eq 1.24
61
- @new_general_measurement.general_measurement.blood_potassium.should eq 1.9
62
- @new_general_measurement.general_measurement.blood_sodium.should eq 122.1
63
- @new_general_measurement.general_measurement.blood_vitamin_b12.should eq 600.0
64
- @new_general_measurement.general_measurement.blood_zinc.should eq 120.0
65
- @new_general_measurement.general_measurement.creatine_kinase.should eq 75.0
66
- @new_general_measurement.general_measurement.crp.should eq 1.0
67
- @new_general_measurement.general_measurement.diastolic.should eq 72.0
68
- @new_general_measurement.general_measurement.ferritin.should eq 175.0
69
- @new_general_measurement.general_measurement.hdl.should eq 41.0
70
- @new_general_measurement.general_measurement.hscrp.should eq 0.91
71
- @new_general_measurement.general_measurement.il6.should eq 0.94
72
- @new_general_measurement.general_measurement.resting_heartrate.should eq 75.0
73
- @new_general_measurement.general_measurement.systolic.should eq 115.0
74
- @new_general_measurement.general_measurement.testosterone.should eq 255.0
75
- @new_general_measurement.general_measurement.total_cholesterol.should eq 150.0
76
- @new_general_measurement.general_measurement.tsh.should eq 0.8
77
- @new_general_measurement.general_measurement.uric_acid.should eq 7.4
78
- @new_general_measurement.general_measurement.vitamin_d.should eq 55.3
79
- @new_general_measurement.general_measurement.white_cell_count.should eq 7685.34
80
- @new_general_measurement.general_measurement.source.should eq "Sample App"
81
- end
82
- end
83
-
84
- context "#get_general_measurements by organization" do
85
- before do
86
- @general_measurement = client.get_general_measurements({organization_id: "519e24e16a7e0cc7ef00002b", access_token: "ENTERPRISE_KEY"})
87
- end
88
-
89
- it "returns JSON response of Validic::GeneralMeasurement", vcr: true do
90
- @general_measurement.should_not be_nil
91
- end
92
-
93
- it "status 200" do
94
- @general_measurement.summary.status.should == 200
95
- end
96
-
97
- it "has summary node" do
98
- @general_measurement.summary.should_not be_nil
99
- end
100
- end
101
-
102
- context "#get_general_measurements by user" do
103
- before do
104
- @general_measurement = client.get_general_measurements({user_id: "519e24e16a7e0cc7ef00002c"})
105
- end
106
-
107
- it "returns JSON response of Validic::GeneralMeasurement", vcr: true do
108
- @general_measurement.should_not be_nil
109
- end
110
-
111
- it "status 200" do
112
- @general_measurement.summary.status.should == 200
113
- end
114
-
115
- it "has summary node" do
116
- @general_measurement.summary.should_not be_nil
117
- end
118
- end
119
-
120
- end