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
@@ -1,26 +0,0 @@
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: "51aca5a06dedda916400002b", 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
- end
26
-
@@ -1,19 +0,0 @@
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
- pending
15
- @profile.should_not be_nil
16
- end
17
- end
18
-
19
- end
@@ -1,82 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::Routine do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_routines" do
9
- before do
10
- @routine = client.get_routines({})
11
- end
12
-
13
- it "returns JSON response of Validic::Routine", vcr: true do
14
- @routine.should_not be_nil
15
- end
16
-
17
- it "status 200" do
18
- @routine.summary.status.should == 200
19
- end
20
-
21
- it "has summary node" do
22
- @routine.summary.should_not be_nil
23
- end
24
- end
25
-
26
- context "#create_routine" do
27
- it "should create new routine record" do
28
- pending
29
- @new_routine = client.create_routine({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
30
- access_token: "DEMO_KEY",
31
- timestamp: "2013-05-16 07:12:16 -05:00",
32
- steps: 10000,
33
- stairs_climbed: 50,
34
- calories_burned: 2500,
35
- calories_consumed: 3000,
36
- source: "Sample App"})
37
- @new_routine.should_not be_nil
38
- @new_routine.routine.timestamp.should eq "2013-05-16 07:12:16 -05:00"
39
- @new_routine.routine.steps.should eq 10000.0
40
- @new_routine.routine.stairs_climbed.should eq 50.0
41
- @new_routine.routine.calories_burned.should eq 2500.0
42
- @new_routine.routine.calories_consumed.should eq 3000.0
43
- @new_routine.routine.source.should eq "Sample App"
44
- end
45
- end
46
-
47
- context "#get_routines by organization" do
48
- before do
49
- @routine = client.get_routines({organization_id: "51aca5a06dedda916400002b", access_token: "ENTERPRISE_KEY"})
50
- end
51
-
52
- it "returns JSON response of Validic::Routine", vcr: true do
53
- @routine.should_not be_nil
54
- end
55
-
56
- it "status 200" do
57
- @routine.summary.status.should == 200
58
- end
59
-
60
- it "has summary node" do
61
- @routine.summary.should_not be_nil
62
- end
63
- end
64
-
65
- context "#get_routines by user" do
66
- before do
67
- @routine = client.get_routines({user_id: ENV['TEST_USER_ID']})
68
- end
69
-
70
- it "returns JSON response of Validic::Routine", vcr: true do
71
- @routine.should_not be_nil
72
- end
73
-
74
- it "status 200" do
75
- @routine.summary.status.should == 200
76
- end
77
-
78
- it "has summary node" do
79
- @routine.summary.should_not be_nil
80
- end
81
- end
82
- end
@@ -1,86 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::Sleep do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_sleeps" do
9
- before do
10
- @sleep = client.get_sleeps({})
11
- end
12
-
13
- it "returns JSON response of Validic::Sleep", vcr: true do
14
- @sleep.should_not be_nil
15
- end
16
-
17
- it "status 200" do
18
- @sleep.summary.status.should == 200
19
- end
20
-
21
- it "has summary node" do
22
- @sleep.summary.should_not be_nil
23
- end
24
- end
25
-
26
- context "#create_sleep" do
27
- it "should create new sleep record" do
28
- pending
29
- @new_sleep = client.create_sleep({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
30
- access_token: "DEMO_KEY",
31
- total_sleep: 210,
32
- awake: 10,
33
- deep: 120,
34
- light: 50,
35
- rem: 30,
36
- times_woken: 3,
37
- timestamp: "2013-05-16 07:12:16 -05:00",
38
- source: "Sample App"})
39
- @new_sleep.should_not be_nil
40
- @new_sleep.sleep.timestamp.should eq "2013-05-16 07:12:16 -05:00"
41
- @new_sleep.sleep.total_sleep.should eq 210.0
42
- @new_sleep.sleep.awake.should eq 10.0
43
- @new_sleep.sleep.deep.should eq 120.0
44
- @new_sleep.sleep.light.should eq 50.0
45
- @new_sleep.sleep.rem.should eq 30.0
46
- @new_sleep.sleep.times_woken.should eq 3.0
47
- @new_sleep.sleep.source.should eq "Sample App"
48
- end
49
- end
50
-
51
- context "#get_sleeps by organization" do
52
- before do
53
- @sleep = client.get_sleeps({organization_id: "51aca5a06dedda916400002b", access_token: "ENTERPRISE_KEY"})
54
- end
55
-
56
- it "returns JSON response of Validic::Sleep", vcr: true do
57
- @sleep.should_not be_nil
58
- end
59
-
60
- it "status 200" do
61
- @sleep.summary.status.should == 200
62
- end
63
-
64
- it "has summary node" do
65
- @sleep.summary.should_not be_nil
66
- end
67
- end
68
-
69
- context "#get_sleeps by user" do
70
- before do
71
- @sleep = client.get_sleeps({user_id: ENV['TEST_USER_ID']})
72
- end
73
-
74
- it "returns JSON response of Validic::Sleep", vcr: true do
75
- @sleep.should_not be_nil
76
- end
77
-
78
- it "status 200" do
79
- @sleep.summary.status.should == 200
80
- end
81
-
82
- it "has summary node" do
83
- @sleep.summary.should_not be_nil
84
- end
85
- end
86
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::ThirdPartyApp do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_apps" do
9
- before do
10
- @app_response = client.get_apps
11
- end
12
-
13
- it "returns JSON response of Validic::ThirdPartyApp", vcr: true do
14
- @app_response.should_not be_nil
15
- end
16
-
17
- it "has apps node" do
18
- @app_response.apps.should_not be_nil
19
- end
20
- end
21
-
22
- context "#get_synced_apps" do
23
- before do
24
- @synced_app_response = client.get_synced_apps({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN']})
25
- end
26
-
27
- it "returns JSON response of Validic::ThirdPartyApp", vcr: true do
28
- @synced_app_response.should_not be_nil
29
- end
30
- end
31
-
32
- end
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::TobaccoCessation do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_tobacco_cessation" do
9
- before do
10
- @tobacco_cessation = client.get_tobacco_cessations({})
11
- end
12
-
13
- it "returns JSON response of Validic::TobaccoCessation", vcr: true do
14
- @tobacco_cessation.should_not be_nil
15
- end
16
-
17
- it "status 200" do
18
- @tobacco_cessation.summary.status.should == 200
19
- end
20
-
21
- it "has summary node" do
22
- @tobacco_cessation.summary.should_not be_nil
23
- end
24
- end
25
-
26
- context "#create_tobacco_cessation" do
27
- it "should create new tobacco_cessation record" do
28
- pending
29
- @new_tobacco_cessation = client.create_tobacco_cessation({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
30
- access_token: "DEMO_KEY",
31
- timestamp: "2013-05-01 07:12:16 -05:00",
32
- cigarettes_allowed: 10,
33
- cigarettes_smoked: 11,
34
- cravings: 15,
35
- last_smoked: "2013-05-16 07:12:16 -05:00",
36
- source: "Sample App"})
37
- @new_tobacco_cessation.should_not be_nil
38
- @new_tobacco_cessation.tobacco_cessation.timestamp.should eq "2013-05-01 07:12:16 -05:00"
39
- @new_tobacco_cessation.tobacco_cessation.cigarettes_allowed.should eq 10.0
40
- @new_tobacco_cessation.tobacco_cessation.cigarettes_smoked.should eq 11.0
41
- @new_tobacco_cessation.tobacco_cessation.cravings.should eq 15.0
42
- @new_tobacco_cessation.tobacco_cessation.last_smoked.should eq "2013-05-16 07:12:16 -05:00"
43
- end
44
- end
45
-
46
- context "#get_tobacco_cessations by organization" do
47
- before do
48
- @tobacco_cessation = client.get_tobacco_cessations({organization_id: "51aca5a06dedda916400002b", access_token: "ENTERPRISE_KEY"})
49
- end
50
-
51
- it "returns JSON response of Validic::TobaccoCessation", vcr: true do
52
- @tobacco_cessation.should_not be_nil
53
- end
54
-
55
- it "status 200" do
56
- @tobacco_cessation.summary.status.should == 200
57
- end
58
-
59
- it "has summary node" do
60
- @tobacco_cessation.summary.should_not be_nil
61
- end
62
- end
63
-
64
- context "#get_tobacco_cessations by user" do
65
- before do
66
- @tobacco_cessation = client.get_tobacco_cessations({user_id: ENV['TEST_USER_ID']})
67
- end
68
-
69
- it "returns JSON response of Validic::TobaccoCessation", vcr: true do
70
- @tobacco_cessation.should_not be_nil
71
- end
72
-
73
- it "status 200" do
74
- @tobacco_cessation.summary.status.should == 200
75
- end
76
-
77
- it "has summary node" do
78
- @tobacco_cessation.summary.should_not be_nil
79
- end
80
- end
81
- end
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::User do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_users" do
9
- before do
10
- @users_response = client.get_users
11
- end
12
-
13
- it "returns JSON response of Validic::Organization", vcr: true do
14
- @users_response.should_not be_nil
15
- end
16
-
17
- it "status 200" do
18
- @users_response.summary.status.should == 200
19
- end
20
-
21
- it "has summary node" do
22
- @users_response.summary.should_not be_nil
23
- end
24
-
25
- end
26
-
27
- context "#me" do
28
- before do
29
- @me = client.me({})
30
- end
31
-
32
- it "returns JSON response of Validic::User", vcr: true do
33
- pending
34
- @me.should_not be_nil
35
- end
36
-
37
- it "should return the user id" do
38
- pending
39
- @me.user._id.should_not be_nil
40
- end
41
- end
42
-
43
- context "#user_provisioning" do
44
- it "should create a new user under an organization" do
45
- pending
46
- @new_user = client.user_provision(organization_id: "51aca5a06dedda916400002b",
47
- uid: "123asdfg",
48
- height: 167,
49
- weight: 69,
50
- location: "TX",
51
- gender: "M")
52
- @new_user.users.access_token.should_not be_nil
53
- @new_user.users.profile.height.should eq "167"
54
- @new_user.users.profile.weight.should eq 69
55
- @new_user.users.profile.location.should eq 'TX'
56
- @new_user.users.profile.gender.should eq 'M'
57
- end
58
- end
59
-
60
- context "#user_suspend" do
61
- it "should suspend a user" do
62
- pending
63
- @suspend_user = client.user_suspend(organization_id: "51aca5a06dedda916400002b",
64
- user_id: ENV['TEST_USER_ID'],
65
- access_token: "9c03ad2bcb022425944e4686d398ef8398f537c2f7c113495ffa7bc9cfa49286",
66
- suspend: 1)
67
- @suspend_user.message.should eq "The user has been suspended successfully"
68
- end
69
- end
70
-
71
- context "#user_delete" do
72
- it "should delete a user" do
73
- pending
74
- @delete_user = client.user_delete(organization_id: "51aca5a06dedda916400002b",
75
- uid: ENV['TEST_USER_ID'],
76
- access_token: "9c03ad2bcb022425944e4686d398ef8398f537c2f7c113495ffa7bc9cfa49286")
77
- @delete_user.status.should eq 200
78
- end
79
- end
80
-
81
- end
@@ -1,88 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Validic::Weight do
5
-
6
- let(:client) { Validic::Client.new }
7
-
8
- context "#get_weights" do
9
- before do
10
- @weight = client.get_weights({})
11
- end
12
-
13
- it "returns JSON response of Validic::Weight", vcr: true do
14
- @weight.should_not be_nil
15
- end
16
-
17
- it "status 200" do
18
- @weight.summary.status.should == 200
19
- end
20
-
21
- it "has summary node" do
22
- @weight.summary.should_not be_nil
23
- end
24
- end
25
-
26
- context "#create_weight" do
27
- it "should create new weight record" do
28
- pending
29
- @new_weight = client.create_weight({authentication_token: ENV['TEST_USER_AUTHENTICATION_TOKEN'],
30
- access_token: "DEMO_KEY",
31
- timestamp: "2013-05-16 07:12:16 -05:00",
32
- bmi: 133.26,
33
- fat_percent: 130.5,
34
- mass_weight: 139.45,
35
- free_mass: 140.50,
36
- weight: 69.76,
37
- height: 167.75,
38
- source: "Sample App"})
39
-
40
- @new_weight.should_not be_nil
41
- @new_weight.weight.timestamp.should eq "2013-05-16 07:12:16 -05:00"
42
- @new_weight.weight.bmi.should eq 133.26
43
- @new_weight.weight.fat_percent.should eq 130.5
44
- @new_weight.weight.mass_weight.should eq 139.45
45
- @new_weight.weight.height.should eq "167.75"
46
- @new_weight.weight.free_mass.should eq 140.50
47
- @new_weight.weight.weight.should eq 69.76
48
- @new_weight.weight.source.should eq "Sample App"
49
- end
50
- end
51
-
52
- context "#get_weights by organization" do
53
- before do
54
- @weight = client.get_weights({organization_id: "51aca5a06dedda916400002b", access_token: "ENTERPRISE_KEY"})
55
- end
56
-
57
- it "returns JSON response of Validic::Weight", vcr: true do
58
- @weight.should_not be_nil
59
- end
60
-
61
- it "status 200" do
62
- @weight.summary.status.should == 200
63
- end
64
-
65
- it "has summary node" do
66
- @weight.summary.should_not be_nil
67
- end
68
- end
69
-
70
- context "#get_weights by user" do
71
- before do
72
- @weight = client.get_weights({user_id: ENV['TEST_USER_ID']})
73
- end
74
-
75
- it "returns JSON response of Validic::Weight", vcr: true do
76
- @weight.should_not be_nil
77
- end
78
-
79
- it "status 200" do
80
- @weight.summary.status.should == 200
81
- end
82
-
83
- it "has summary node" do
84
- @weight.summary.should_not be_nil
85
- end
86
- end
87
-
88
- end