validic 0.3.3 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,15 @@
1
+ {
2
+ "fitness": {
3
+ "timestamp": "2013-03-10T07:12:16+00:00",
4
+ "utc_offset": "-05:00",
5
+ "type": "Running",
6
+ "intensity": "medium",
7
+ "start_time": "2013-03-09T02:12:16-05:00",
8
+ "distance": 5149.9,
9
+ "duration": 1959,
10
+ "calories": 350,
11
+ "activity_id": "12345",
12
+ "extras": { "stars": 3 }
13
+ },
14
+ "access_token": "e7ba1f04e88f25d399a91c8cbcd72300e01309e96b7725e40b49cd1effaa5deb"
15
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "fitness": {
3
+ "_id": "51552cd8fded0807c400002a",
4
+ "timestamp": "2013-03-10T07:12:16+00:00",
5
+ "utc_offset": "-05:00",
6
+ "type": "Running",
7
+ "intensity": "medium",
8
+ "start_time": "2013-03-09T02:12:16-05:00",
9
+ "distance": 5149.9,
10
+ "duration": 1959,
11
+ "calories": 350,
12
+ "source": "sample_app",
13
+ "source_name": "Sample App",
14
+ "last_updated": "2013-03-10T07:12:16+00:00"
15
+ }
16
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "summary": {
3
+ "status": 200,
4
+ "message": "OK",
5
+ "results": 3,
6
+ "start_date": "2013-03-27T00:00:00+00:00",
7
+ "end_date": "2013-03-27T23:59:59+00:00",
8
+ "offset": 0,
9
+ "limit": 100,
10
+ "previous": null,
11
+ "next": null,
12
+ "params": {
13
+ "start_date": null,
14
+ "end_date": null,
15
+ "offset": null,
16
+ "limit": null
17
+ }
18
+ }, "fitness": [
19
+ {
20
+ "_id": "51552cd7fded0807c400001f",
21
+ "timestamp": "2013-03-10T07:12:16+00:00",
22
+ "utc_offset": "+00:00",
23
+ "type": "Walking",
24
+ "intensity": "low",
25
+ "start_time": "2013-03-10T07:12:16+00:00",
26
+ "distance": 2600,
27
+ "duration": 2460,
28
+ "calories": 350,
29
+ "source": "sample_app",
30
+ "source_name": "Sample App",
31
+ "last_updated": "2013-03-10T07:12:16+00:00"
32
+ }
33
+ ]
34
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "code": 403,
3
+ "message": "Forbidden",
4
+ "errors": "Bad request"
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "code": 500,
3
+ "message": "Internal Server Error"
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "me": {
3
+ "_id": "1"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "code": 404,
3
+ "message": "Not Found",
4
+ "errors": "No user found"
5
+ }
@@ -0,0 +1,123 @@
1
+ {
2
+ "summary": {
3
+ "status": 200,
4
+ "message": "Ok",
5
+ "results": 6,
6
+ "start_date": "2015-01-14T00:00:00+00:00",
7
+ "end_date": "2015-01-16T23:59:59+00:00",
8
+ "offset": 0,
9
+ "limit": 100,
10
+ "previous": null,
11
+ "next": null,
12
+ "params": {
13
+ "start_date": null,
14
+ "end_date": null,
15
+ "offset": 0,
16
+ "limit": 0
17
+ }
18
+ },
19
+ "nutrition": [
20
+ {
21
+ "_id": "54b6fb35d7a1e1556a002a66",
22
+ "timestamp": "2015-01-15T00:00:00+00:00",
23
+ "utc_offset": "-05:00",
24
+ "calories": 101.583,
25
+ "carbohydrates": 1.592,
26
+ "fat": 2.771,
27
+ "fiber": 0.0272,
28
+ "protein": 17.2877,
29
+ "sodium": 399.879,
30
+ "water": null,
31
+ "meal": "Dinner",
32
+ "source": "jawbone_up",
33
+ "source_name": "Jawbone Up",
34
+ "last_updated": "2015-01-14T23:26:45+00:00",
35
+ "user_id": "535573c8f1f70e2bb6000012"
36
+ },
37
+ {
38
+ "_id": "54b6fbbdc27ea944fe002b58",
39
+ "timestamp": "2015-01-14T23:25:59+00:00",
40
+ "utc_offset": "-05:00",
41
+ "calories": 320,
42
+ "carbohydrates": 78,
43
+ "fat": 0,
44
+ "fiber": 2,
45
+ "protein": 0,
46
+ "sodium": 110,
47
+ "water": null,
48
+ "meal": "Snacks",
49
+ "source": "jawbone_up",
50
+ "source_name": "Jawbone Up",
51
+ "last_updated": "2015-01-14T23:29:01+00:00",
52
+ "user_id": "535573c8f1f70e2bb6000012"
53
+ },
54
+ {
55
+ "_id": "54b6c7497bbc0529260003a1",
56
+ "timestamp": "2015-01-14T17:00:00+00:00",
57
+ "utc_offset": "-05:00",
58
+ "calories": 335,
59
+ "carbohydrates": 10,
60
+ "fat": 14,
61
+ "fiber": 0,
62
+ "protein": 42,
63
+ "sodium": 0,
64
+ "water": null,
65
+ "meal": "Lunch",
66
+ "source": "jawbone_up",
67
+ "source_name": "Jawbone Up",
68
+ "last_updated": "2015-01-14T19:45:13+00:00",
69
+ "user_id": "535573c8f1f70e2bb6000012"
70
+ },
71
+ {
72
+ "_id": "54b69a421f60717ce300303e",
73
+ "timestamp": "2015-01-14T13:00:00+00:00",
74
+ "utc_offset": "-05:00",
75
+ "calories": 323.5,
76
+ "carbohydrates": 25,
77
+ "fat": 20.5,
78
+ "fiber": 14.5,
79
+ "protein": 13.5,
80
+ "sodium": 81.5,
81
+ "water": null,
82
+ "meal": "Breakfast",
83
+ "source": "jawbone_up",
84
+ "source_name": "Jawbone Up",
85
+ "last_updated": "2015-01-14T16:34:39+00:00",
86
+ "user_id": "535573c8f1f70e2bb6000012"
87
+ },
88
+ {
89
+ "_id": "54b5c96a33229d46fb000312",
90
+ "timestamp": "2015-01-14T01:40:00+00:00",
91
+ "utc_offset": "-06:00",
92
+ "calories": 190,
93
+ "carbohydrates": 23,
94
+ "fat": 6,
95
+ "fiber": 5,
96
+ "protein": 14,
97
+ "sodium": 73,
98
+ "water": null,
99
+ "meal": "Snacks",
100
+ "source": "jawbone_up",
101
+ "source_name": "Jawbone Up",
102
+ "last_updated": "2015-01-14T01:42:02+00:00",
103
+ "user_id": "535573c8f1f70e2bb6000012"
104
+ },
105
+ {
106
+ "_id": "54b5d10133229db2020024c8",
107
+ "timestamp": "2015-01-14T01:00:00+00:00",
108
+ "utc_offset": "-06:00",
109
+ "calories": 490,
110
+ "carbohydrates": 56,
111
+ "fat": 9,
112
+ "fiber": 3,
113
+ "protein": 46,
114
+ "sodium": 140,
115
+ "water": null,
116
+ "meal": "Dinner",
117
+ "source": "jawbone_up",
118
+ "source_name": "Jawbone Up",
119
+ "last_updated": "2015-01-14T02:15:45+00:00",
120
+ "user_id": "535573c8f1f70e2bb6000012"
121
+ }
122
+ ]
123
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "nutrition": {
3
+ "timestamp": "2013-03-10T07:12:16+00:00",
4
+ "utc_offset": "-05:00",
5
+ "start_time": "2013-03-09T02:12:16-05:00",
6
+ "fat": 5149.9,
7
+ "fiber": 1959,
8
+ "calories": 350,
9
+ "activity_id": "12345",
10
+ "extras": {"stars": 3}
11
+ },
12
+ "access_token": "1"
13
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "nutrition": {
3
+ "_id": "51552cdafded0807c400004e",
4
+ "timestamp": "2013-03-10T07:12:16+00:00",
5
+ "utc_offset": "+00:00",
6
+ "calories": 865,
7
+ "carbohydrates": 121,
8
+ "fat": 31,
9
+ "fiber": 9,
10
+ "protein": 21,
11
+ "sodium": 1129,
12
+ "water": 14,
13
+ "meal": "lunch",
14
+ "source": "sample_app",
15
+ "source_name": "Sample App",
16
+ "last_updated": "2013-03-10T07:12:16+00:00"
17
+ }
18
+ }
@@ -0,0 +1,123 @@
1
+ {
2
+ "summary": {
3
+ "status": 200,
4
+ "message": "Ok",
5
+ "results": 6,
6
+ "start_date": "2015-01-14T00:00:00+00:00",
7
+ "end_date": "2015-01-16T23:59:59+00:00",
8
+ "offset": 0,
9
+ "limit": 100,
10
+ "previous": null,
11
+ "next": null,
12
+ "params": {
13
+ "start_date": null,
14
+ "end_date": null,
15
+ "offset": 0,
16
+ "limit": 0
17
+ }
18
+ },
19
+ "nutrition": [
20
+ {
21
+ "_id": "54b6fb35d7a1e1556a002a66",
22
+ "timestamp": "2015-01-15T00:00:00+00:00",
23
+ "utc_offset": "-05:00",
24
+ "calories": 101.583,
25
+ "carbohydrates": 1.592,
26
+ "fat": 2.771,
27
+ "fiber": 0.0272,
28
+ "protein": 17.2877,
29
+ "sodium": 399.879,
30
+ "water": null,
31
+ "meal": "Dinner",
32
+ "source": "jawbone_up",
33
+ "source_name": "Jawbone Up",
34
+ "last_updated": "2015-01-14T23:26:45+00:00",
35
+ "user_id": "535573c8f1f70e2bb6000012"
36
+ },
37
+ {
38
+ "_id": "54b6fbbdc27ea944fe002b58",
39
+ "timestamp": "2015-01-14T23:25:59+00:00",
40
+ "utc_offset": "-05:00",
41
+ "calories": 320,
42
+ "carbohydrates": 78,
43
+ "fat": 0,
44
+ "fiber": 2,
45
+ "protein": 0,
46
+ "sodium": 110,
47
+ "water": null,
48
+ "meal": "Snacks",
49
+ "source": "jawbone_up",
50
+ "source_name": "Jawbone Up",
51
+ "last_updated": "2015-01-14T23:29:01+00:00",
52
+ "user_id": "535573c8f1f70e2bb6000012"
53
+ },
54
+ {
55
+ "_id": "54b6c7497bbc0529260003a1",
56
+ "timestamp": "2015-01-14T17:00:00+00:00",
57
+ "utc_offset": "-05:00",
58
+ "calories": 335,
59
+ "carbohydrates": 10,
60
+ "fat": 14,
61
+ "fiber": 0,
62
+ "protein": 42,
63
+ "sodium": 0,
64
+ "water": null,
65
+ "meal": "Lunch",
66
+ "source": "jawbone_up",
67
+ "source_name": "Jawbone Up",
68
+ "last_updated": "2015-01-14T19:45:13+00:00",
69
+ "user_id": "535573c8f1f70e2bb6000012"
70
+ },
71
+ {
72
+ "_id": "54b69a421f60717ce300303e",
73
+ "timestamp": "2015-01-14T13:00:00+00:00",
74
+ "utc_offset": "-05:00",
75
+ "calories": 323.5,
76
+ "carbohydrates": 25,
77
+ "fat": 20.5,
78
+ "fiber": 14.5,
79
+ "protein": 13.5,
80
+ "sodium": 81.5,
81
+ "water": null,
82
+ "meal": "Breakfast",
83
+ "source": "jawbone_up",
84
+ "source_name": "Jawbone Up",
85
+ "last_updated": "2015-01-14T16:34:39+00:00",
86
+ "user_id": "535573c8f1f70e2bb6000012"
87
+ },
88
+ {
89
+ "_id": "54b5c96a33229d46fb000312",
90
+ "timestamp": "2015-01-14T01:40:00+00:00",
91
+ "utc_offset": "-06:00",
92
+ "calories": 190,
93
+ "carbohydrates": 23,
94
+ "fat": 6,
95
+ "fiber": 5,
96
+ "protein": 14,
97
+ "sodium": 73,
98
+ "water": null,
99
+ "meal": "Snacks",
100
+ "source": "jawbone_up",
101
+ "source_name": "Jawbone Up",
102
+ "last_updated": "2015-01-14T01:42:02+00:00",
103
+ "user_id": "535573c8f1f70e2bb6000012"
104
+ },
105
+ {
106
+ "_id": "54b5d10133229db2020024c8",
107
+ "timestamp": "2015-01-14T01:00:00+00:00",
108
+ "utc_offset": "-06:00",
109
+ "calories": 490,
110
+ "carbohydrates": 56,
111
+ "fat": 9,
112
+ "fiber": 3,
113
+ "protein": 46,
114
+ "sodium": 140,
115
+ "water": null,
116
+ "meal": "Dinner",
117
+ "source": "jawbone_up",
118
+ "source_name": "Jawbone Up",
119
+ "last_updated": "2015-01-14T02:15:45+00:00",
120
+ "user_id": "535573c8f1f70e2bb6000012"
121
+ }
122
+ ]
123
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "summary": {
3
+ "status": 200,
4
+ "message": "OK",
5
+ "results": 3,
6
+ "start_date": "2013-03-27T00:00:00+00:00",
7
+ "end_date": "2013-03-27T23:59:59+00:00",
8
+ "offset": 0,
9
+ "limit": 100,
10
+ "previous": null,
11
+ "next": null,
12
+ "params": {
13
+ "start_date": null,
14
+ "end_date": null,
15
+ "offset": null,
16
+ "limit": null
17
+ }
18
+ }, "nutrition": [
19
+ {
20
+ "_id": "51552cd9fded0807c4000043",
21
+ "timestamp": "2013-03-10T07:12:16+00:00",
22
+ "utc_offset": "+00:00",
23
+ "calories": 865,
24
+ "carbohydrates": 121,
25
+ "fat": 31,
26
+ "fiber": 9,
27
+ "protein": 21,
28
+ "sodium": 1129,
29
+ "water": 14,
30
+ "meal": "lunch",
31
+ "source": "sample_app",
32
+ "source_name": "Sample App",
33
+ "last_updated": "2013-03-10T07:12:16+00:00"
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "summary": {
3
+ "status": 200,
4
+ "message": "Ok",
5
+ "results": 1,
6
+ "start_date": null,
7
+ "end_date": null,
8
+ "offset": 0,
9
+ "limit": 100,
10
+ "params": {
11
+ "start_date": null,
12
+ "end_date": null,
13
+ "offset": null,
14
+ "limit": null,
15
+ "source": null
16
+ }
17
+ },
18
+ "organization": {
19
+ "_id": "{ORGANIZATION_ID}",
20
+ "name": "{ORGANIZATION_NAME}",
21
+ "users": 64,
22
+ "users_provisioned": 124,
23
+ "activities": 25334,
24
+ "connections": 260,
25
+ "organizations": []
26
+ }
27
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "profile": {
3
+ "uid": "123467890",
4
+ "_id": "51552cd7fded0807c4000017",
5
+ "gender": "M",
6
+ "location": "NC",
7
+ "country": "United States",
8
+ "birth_year": "1973",
9
+ "height": 167.5,
10
+ "weight": 83.9146,
11
+ "applications": []
12
+ }
13
+ }