validic 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +3 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +80 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +61 -0
  7. data/Rakefile +7 -0
  8. data/lib/validic.rb +32 -0
  9. data/lib/validic/activity.rb +73 -0
  10. data/lib/validic/client.rb +74 -0
  11. data/lib/validic/diabetes.rb +81 -0
  12. data/lib/validic/fitness.rb +75 -0
  13. data/lib/validic/general_measurement.rb +113 -0
  14. data/lib/validic/nutrition.rb +81 -0
  15. data/lib/validic/organization.rb +46 -0
  16. data/lib/validic/profile.rb +43 -0
  17. data/lib/validic/request.rb +36 -0
  18. data/lib/validic/routine.rb +73 -0
  19. data/lib/validic/sleep.rb +77 -0
  20. data/lib/validic/third_party_app.rb +37 -0
  21. data/lib/validic/tobacco_cessation.rb +73 -0
  22. data/lib/validic/user.rb +71 -0
  23. data/lib/validic/version.rb +3 -0
  24. data/lib/validic/weight.rb +74 -0
  25. data/spec/.DS_Store +0 -0
  26. data/spec/spec_helper.rb +43 -0
  27. data/spec/validic/activity_spec.rb +97 -0
  28. data/spec/validic/client_spec.rb +11 -0
  29. data/spec/validic/diabetes_spec.rb +88 -0
  30. data/spec/validic/fitness_spec.rb +84 -0
  31. data/spec/validic/general_measurement_spec.rb +120 -0
  32. data/spec/validic/nutrition_spec.rb +90 -0
  33. data/spec/validic/organization_spec.rb +46 -0
  34. data/spec/validic/profile_spec.rb +46 -0
  35. data/spec/validic/routine_spec.rb +81 -0
  36. data/spec/validic/sleep_spec.rb +85 -0
  37. data/spec/validic/third_party_app_spec.rb +32 -0
  38. data/spec/validic/tobacco_cessation_spec.rb +80 -0
  39. data/spec/validic/user_spec.rb +49 -0
  40. data/spec/validic/weight_spec.rb +87 -0
  41. data/spec/validic_spec.rb +38 -0
  42. data/validic.gemspec +37 -0
  43. metadata +353 -0
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Validic::Client do
5
+
6
+ it "creates a Faraday::Connection" do
7
+ client = Validic::Client.new
8
+ client.connection.should be_kind_of Faraday::Connection
9
+ end
10
+
11
+ end
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Validic::Diabetes do
5
+
6
+ let(:client) { Validic::Client.new }
7
+
8
+ context "#get_diabetes" do
9
+ before do
10
+ @user_diabetes = client.get_diabetes({})
11
+ end
12
+
13
+ it "returns JSON response of Validic::Diabetes", vcr: true do
14
+ @user_diabetes.should_not be_nil
15
+ end
16
+
17
+ it "status 200" do
18
+ @user_diabetes.summary.status.should == 200
19
+ end
20
+
21
+ it "has summary node" do
22
+ @user_diabetes.summary.should_not be_nil
23
+ end
24
+ end
25
+
26
+ context "#create_diabetes" do
27
+ it "should create new diabetes record" do
28
+ @new_diabetes = client.create_diabetes({authentication_token: "mqwpDx8RYcmSFBJDmy3J",
29
+ access_token: "DEMO_KEY",
30
+ c_peptide: 1,
31
+ fasting_plasma_glucose_test: 50,
32
+ hba1c: 100,
33
+ insulin: 350,
34
+ oral_glucose_tolerance_test: 100,
35
+ random_plasma_glucose_test: 200,
36
+ triglyceride: 100,
37
+ timestamp: "2013-05-16 07:12:16 -05:00",
38
+ source: "Sample App"})
39
+ @new_diabetes.should_not be_nil
40
+ @new_diabetes.diabetes.timestamp.should eq "2013-05-16 07:12:16 -05:00"
41
+ @new_diabetes.diabetes.c_peptide.should eq 1.0
42
+ @new_diabetes.diabetes.fasting_plasma_glucose_test.should eq 50.0
43
+ @new_diabetes.diabetes.hba1c.should eq 100.0
44
+ @new_diabetes.diabetes.insulin.should eq 350.0
45
+ @new_diabetes.diabetes.oral_glucose_tolerance_test.should eq 100.0
46
+ @new_diabetes.diabetes.random_plasma_glucose_test.should eq 200.0
47
+ @new_diabetes.diabetes.triglyceride 100.0
48
+ @new_diabetes.diabetes.source.should eq "Sample App"
49
+ end
50
+ end
51
+
52
+ context "#get_diabetes by organization" do
53
+ before do
54
+ @org_diabetes = client.get_diabetes({organization_id: "519e24e16a7e0cc7ef00002b", access_token: "ENTERPRISE_KEY"})
55
+ end
56
+
57
+ it "returns JSON response of Validic::Diabetes", vcr: true do
58
+ @org_diabetes.should_not be_nil
59
+ end
60
+
61
+ it "status 200" do
62
+ @org_diabetes.summary.status.should == 200
63
+ end
64
+
65
+ it "has summary node" do
66
+ @org_diabetes.summary.should_not be_nil
67
+ end
68
+ end
69
+
70
+ context "#get_diabetes by user" do
71
+ before do
72
+ @user_diabetes = client.get_diabetes({user_id: "519e24e16a7e0cc7ef00002c"})
73
+ end
74
+
75
+ it "returns JSON response of Validic::Diabetes", vcr: true do
76
+ @user_diabetes.should_not be_nil
77
+ end
78
+
79
+ it "status 200" do
80
+ @user_diabetes.summary.status.should == 200
81
+ end
82
+
83
+ it "has summary node" do
84
+ @user_diabetes.summary.should_not be_nil
85
+ end
86
+ end
87
+
88
+ end
@@ -0,0 +1,84 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Validic::Fitness do
5
+
6
+ let(:client) { Validic::Client.new }
7
+
8
+ context "#get_fitnesses" do
9
+ before do
10
+ @fitness = client.get_fitnesses({})
11
+ end
12
+
13
+ it "returns JSON response of Validic::Fitness", vcr: true do
14
+ @fitness.should_not be_nil
15
+ end
16
+
17
+ it "status 200" do
18
+ @fitness.summary.status.should == 200
19
+ end
20
+
21
+ it "has summary node" do
22
+ @fitness.summary.should_not be_nil
23
+ end
24
+ end
25
+
26
+ context "#create_fitness" do
27
+ it "should create new fitness record" do
28
+ @new_fitness = client.create_fitness({authentication_token: "mqwpDx8RYcmSFBJDmy3J",
29
+ access_token: "DEMO_KEY",
30
+ timestamp: "2013-03-10 07:12:16 -05:00",
31
+ primary_type: "Running",
32
+ intensity: "medium",
33
+ start_time: "2013-03-09 13:55:36 -05:00",
34
+ total_distance: 5149.9,
35
+ duration: 1959.90,
36
+ source: "Sample App"})
37
+
38
+ @new_fitness.fitness.timestamp.should eq "2013-03-10 07:12:16 -05:00"
39
+ @new_fitness.fitness.type.should eq "Running"
40
+ @new_fitness.fitness.intensity.should eq "medium"
41
+ @new_fitness.fitness.start_time.should eq "2013-03-09 13:55:36 -05:00"
42
+ @new_fitness.fitness.total_distance.should eq 5149.9
43
+ @new_fitness.fitness.duration.should eq 1959.90
44
+ @new_fitness.fitness.source.should eq "Sample App"
45
+ end
46
+ end
47
+
48
+ context "#get_fitnesses by organization" do
49
+ before do
50
+ @fitness = client.get_fitnesses({organization_id: "519e24e16a7e0cc7ef00002b", access_token: "ENTERPRISE_KEY"})
51
+ end
52
+
53
+ it "returns JSON response of Validic::Fitness", vcr: true do
54
+ @fitness.should_not be_nil
55
+ end
56
+
57
+ it "status 200" do
58
+ @fitness.summary.status.should == 200
59
+ end
60
+
61
+ it "has summary node" do
62
+ @fitness.summary.should_not be_nil
63
+ end
64
+ end
65
+
66
+ context "#get_fitnesses by user" do
67
+ before do
68
+ @fitness = client.get_fitnesses({user_id: "519e24e16a7e0cc7ef00002c"})
69
+ end
70
+
71
+ it "returns JSON response of Validic::Fitness", vcr: true do
72
+ @fitness.should_not be_nil
73
+ end
74
+
75
+ it "status 200" do
76
+ @fitness.summary.status.should == 200
77
+ end
78
+
79
+ it "has summary node" do
80
+ @fitness.summary.should_not be_nil
81
+ end
82
+ end
83
+
84
+ end
@@ -0,0 +1,120 @@
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
@@ -0,0 +1,90 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Validic::Nutrition do
5
+
6
+ let(:client) { Validic::Client.new }
7
+
8
+ context "#get_nutritions" do
9
+ before do
10
+ @nutrition = client.get_nutritions({})
11
+ end
12
+
13
+ it "returns JSON response of Validic::Nutrition", vcr: true do
14
+ @nutrition.should_not be_nil
15
+ end
16
+
17
+ it "status 200" do
18
+ @nutrition.summary.status.should == 200
19
+ end
20
+
21
+ it "has summary node" do
22
+ @nutrition.summary.should_not be_nil
23
+ end
24
+ end
25
+
26
+ context "#create_nutrition" do
27
+ it "should create new nutrition record" do
28
+ @new_nutrition = client.create_nutrition({authentication_token: "mqwpDx8RYcmSFBJDmy3J",
29
+ access_token: "DEMO_KEY",
30
+ calories: 850,
31
+ carbohydrates: 351,
32
+ fat: 52,
33
+ fiber: 35,
34
+ protein: 54,
35
+ sodium: 855,
36
+ water: 36,
37
+ timestamp: "2013-05-16 07:12:16 -05:00",
38
+ meal: "Dinner",
39
+ source: "Sample App"})
40
+ @new_nutrition.should_not be_nil
41
+ @new_nutrition.nutrition.timestamp.should eq "2013-05-16 07:12:16 -05:00"
42
+ @new_nutrition.nutrition.calories.should eq 850.0
43
+ @new_nutrition.nutrition.carbohydrates.should eq 351.0
44
+ @new_nutrition.nutrition.fat.should eq 52.0
45
+ @new_nutrition.nutrition.fiber.should eq 35.0
46
+ @new_nutrition.nutrition.protein.should eq 54.0
47
+ @new_nutrition.nutrition.sodium.should eq 855.0
48
+ @new_nutrition.nutrition.water.should eq 36.0
49
+ @new_nutrition.nutrition.meal.should eq "Dinner"
50
+ @new_nutrition.nutrition.source.should eq "Sample App"
51
+ end
52
+ end
53
+
54
+ context "#get_nutritions by organization" do
55
+ before do
56
+ @nutrition = client.get_nutritions({organization_id: "519e24e16a7e0cc7ef00002b", access_token: "ENTERPRISE_KEY"})
57
+ end
58
+
59
+ it "returns JSON response of Validic::Nutrition", vcr: true do
60
+ @nutrition.should_not be_nil
61
+ end
62
+
63
+ it "status 200" do
64
+ @nutrition.summary.status.should == 200
65
+ end
66
+
67
+ it "has summary node" do
68
+ @nutrition.summary.should_not be_nil
69
+ end
70
+ end
71
+
72
+ context "#get_nutritions by user" do
73
+ before do
74
+ @nutrition = client.get_nutritions({user_id: "519e24e16a7e0cc7ef00002c"})
75
+ end
76
+
77
+ it "returns JSON response of Validic::Nutrition", vcr: true do
78
+ @nutrition.should_not be_nil
79
+ end
80
+
81
+ it "status 200" do
82
+ @nutrition.summary.status.should == 200
83
+ end
84
+
85
+ it "has summary node" do
86
+ @nutrition.summary.should_not be_nil
87
+ end
88
+ end
89
+
90
+ end
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Validic::Organization do
5
+
6
+ let(:client) { Validic::Client.new }
7
+
8
+ context "#get_organization" do
9
+ before do
10
+ @organization_response = client.get_organization({organization_id: "519e24e16a7e0cc7ef00002b", access_token: "ENTERPRISE_KEY"})
11
+ end
12
+
13
+ it "returns JSON response of Validic::Organization", vcr: true do
14
+ @organization_response.should_not be_nil
15
+ end
16
+
17
+ it "status 200" do
18
+ @organization_response.summary.status.should == 200
19
+ end
20
+
21
+ it "has summary node" do
22
+ @organization_response.summary.should_not be_nil
23
+ end
24
+ end
25
+
26
+ context "#get_users" do
27
+ before do
28
+ @users_response = client.get_users({organization_id: "519e24e16a7e0cc7ef00002b", access_token: "ENTERPRISE_KEY"})
29
+ end
30
+
31
+ it "returns JSON response of Validic::Organization", vcr: true do
32
+ @users_response.should_not be_nil
33
+ end
34
+
35
+ it "status 200" do
36
+ @users_response.summary.status.should == 200
37
+ end
38
+
39
+ it "has summary node" do
40
+ @users_response.summary.should_not be_nil
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Validic::Profile do
5
+
6
+ let(:client) { Validic::Client.new }
7
+
8
+ context "#get_profile" do
9
+ before do
10
+ @profile = client.get_profile({})
11
+ end
12
+
13
+ it "returns JSON response of Validic::Profile", vcr: true do
14
+ @profile.should_not be_nil
15
+ end
16
+ end
17
+
18
+ # context "#update_profile" do
19
+ # before do
20
+ # @updated_profile = client.update_profile({gender: "M",
21
+ # location: "TX",
22
+ # birth_year: "1985",
23
+ # height: 168.75,
24
+ # weight: 69,
25
+ # first_name: "Demo",
26
+ # last_name: "User"})
27
+ # end
28
+
29
+ # it "should return gender" do
30
+ # @updated_profile.profile.gender.should eq 'M'
31
+ # end
32
+
33
+ # it "should return location" do
34
+ # @updated_profile.profile.location.should eq 'TX'
35
+ # end
36
+
37
+ # it "should return height" do
38
+ # @updated_profile.profile.height.should eq "168.75"
39
+ # end
40
+
41
+ # it "should return weight" do
42
+ # @updated_profile.profile.weight.should eq 69
43
+ # end
44
+ # end
45
+
46
+ end