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.
- 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
data/lib/validic.rb
CHANGED
@@ -1,37 +1,20 @@
|
|
1
|
-
require
|
2
|
-
require "faraday_middleware"
|
3
|
-
require "validic/client"
|
4
|
-
require "validic/version"
|
5
|
-
|
6
|
-
directory = File.expand_path(File.dirname(__FILE__))
|
1
|
+
require 'validic/client'
|
7
2
|
|
8
3
|
module Validic
|
9
|
-
|
4
|
+
BASE_URL = "https://api.validic.com/v1"
|
10
5
|
class << self
|
11
6
|
attr_accessor :api_url,
|
12
7
|
:api_version,
|
13
8
|
:access_token,
|
14
|
-
:organization_id
|
15
|
-
:user_id
|
9
|
+
:organization_id
|
16
10
|
|
17
11
|
##
|
18
12
|
# Configure default
|
19
13
|
#
|
20
14
|
# @yield [Validic]
|
21
15
|
def configure
|
22
|
-
load_defaults
|
23
16
|
yield self
|
24
17
|
true
|
25
18
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def load_defaults
|
30
|
-
self.api_url ||= 'https://api.validic.com'
|
31
|
-
self.api_version ||= 'v1'
|
32
|
-
self.access_token ||= 'ENTERPRISE_KEY'
|
33
|
-
self.organization_id ||= '51aca5a06dedda916400002b'
|
34
|
-
end
|
35
19
|
end
|
36
|
-
|
37
20
|
end
|
data/lib/validic/app.rb
ADDED
data/lib/validic/client.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
require 'validic/
|
5
|
-
require 'validic/
|
6
|
-
require 'validic/
|
7
|
-
require 'validic/fitness'
|
8
|
-
require 'validic/
|
9
|
-
require 'validic/
|
10
|
-
require 'validic/
|
11
|
-
require 'validic/
|
12
|
-
require 'validic/
|
13
|
-
require 'validic/
|
14
|
-
require 'validic/tobacco_cessation'
|
15
|
-
require 'validic/
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
require 'validic/rest/apps'
|
5
|
+
require 'validic/rest/biometrics'
|
6
|
+
require 'validic/rest/diabetes'
|
7
|
+
require 'validic/rest/fitness'
|
8
|
+
require 'validic/rest/nutrition'
|
9
|
+
require 'validic/rest/organizations'
|
10
|
+
require 'validic/rest/profile'
|
11
|
+
require 'validic/rest/request'
|
12
|
+
require 'validic/rest/routine'
|
13
|
+
require 'validic/rest/sleep'
|
14
|
+
require 'validic/rest/tobacco_cessation'
|
15
|
+
require 'validic/rest/users'
|
16
|
+
require 'validic/rest/utils'
|
17
|
+
require 'validic/rest/weight'
|
18
|
+
require 'validic/version'
|
16
19
|
|
17
20
|
module Validic
|
18
21
|
class Client
|
19
|
-
|
20
|
-
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
25
|
-
include
|
26
|
-
include
|
27
|
-
include
|
28
|
-
include Sleep
|
29
|
-
include
|
30
|
-
include
|
31
|
-
include
|
32
|
-
include
|
33
|
-
include ThirdPartyApp
|
22
|
+
include REST::Apps
|
23
|
+
include REST::Biometrics
|
24
|
+
include REST::Diabetes
|
25
|
+
include REST::Fitness
|
26
|
+
include REST::Nutrition
|
27
|
+
include REST::Organizations
|
28
|
+
include REST::Profile
|
29
|
+
include REST::Request
|
30
|
+
include REST::Routine
|
31
|
+
include REST::Sleep
|
32
|
+
include REST::TobaccoCessation
|
33
|
+
include REST::Users
|
34
|
+
include REST::Utils
|
35
|
+
include REST::Weight
|
34
36
|
|
35
37
|
attr_accessor :api_url,
|
36
38
|
:api_version,
|
@@ -42,11 +44,10 @@ module Validic
|
|
42
44
|
#
|
43
45
|
# @params options[Hash]
|
44
46
|
def initialize(options={})
|
45
|
-
@api_url = options[:api_url].nil? ?
|
47
|
+
@api_url = options[:api_url].nil? ? 'https://api.validic.com' : options[:api_url]
|
46
48
|
@api_version = options[:api_version].nil? ? 'v1' : options[:api_version]
|
47
49
|
@access_token = options[:access_token].nil? ? Validic.access_token : options[:access_token]
|
48
50
|
@organization_id = options[:organization_id].nil? ? Validic.organization_id : options[:organization_id]
|
49
|
-
|
50
51
|
reload_config
|
51
52
|
end
|
52
53
|
|
@@ -55,56 +56,14 @@ module Validic
|
|
55
56
|
#
|
56
57
|
# @return [Faraday::Connection]
|
57
58
|
def connection
|
58
|
-
|
59
|
-
|
60
|
-
faraday.use FaradayMiddleware::Mashify
|
59
|
+
Faraday.new(url: @api_url, headers: default_headers, ssl: { verify: true }) do |faraday|
|
60
|
+
# faraday.use FaradayMiddleware::Mashify
|
61
61
|
faraday.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
62
62
|
faraday.use FaradayMiddleware::FollowRedirects
|
63
63
|
faraday.adapter Faraday.default_adapter
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
##
|
68
|
-
# Pull the latest endpoint
|
69
|
-
def latest(type, org_id=nil, user_id=nil, params={})
|
70
|
-
organization_id = org_id.nil? ? Validic.organization_id : org_id
|
71
|
-
user_id = org_id.nil? ? Validic.user_id : org_id
|
72
|
-
|
73
|
-
url = "/#{Validic.api_version}/organizations/#{organization_id}/#{type.to_s}/latest.json"
|
74
|
-
|
75
|
-
if user_id
|
76
|
-
url = "/#{Validic.api_version}/organizations/#{organization_id}/users/#{user_id}/#{type.to_s}/latest.json"
|
77
|
-
end
|
78
|
-
|
79
|
-
get(url, params)
|
80
|
-
end
|
81
|
-
|
82
|
-
##
|
83
|
-
# Generic Pull of Validic Objects
|
84
|
-
def get_endpoint(type, params={})
|
85
|
-
|
86
|
-
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/#{type.to_s}.json"
|
87
|
-
|
88
|
-
if Validic.user_id && type != :users
|
89
|
-
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/users/#{Validic.user_id}/#{type.to_s}.json"
|
90
|
-
elsif Validic.user_id && type == :users
|
91
|
-
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/users/#{Validic.user_id}.json"
|
92
|
-
end
|
93
|
-
|
94
|
-
get(url, params)
|
95
|
-
end
|
96
|
-
|
97
|
-
##
|
98
|
-
# Generic POST to Validic
|
99
|
-
def post_to_validic(type, params={})
|
100
|
-
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/#{type.to_s}.json"
|
101
|
-
|
102
|
-
if Validic.user_id
|
103
|
-
url = "/#{Validic.api_version}/organizations/#{Validic.organization_id}/users/#{Validic.user_id}/#{type.to_s}.json"
|
104
|
-
end
|
105
|
-
post(url, params)
|
106
|
-
end
|
107
|
-
|
108
67
|
private
|
109
68
|
|
110
69
|
def default_headers
|
@@ -121,6 +80,5 @@ module Validic
|
|
121
80
|
Validic.access_token = access_token
|
122
81
|
Validic.organization_id = organization_id
|
123
82
|
end
|
124
|
-
|
125
83
|
end
|
126
84
|
end
|
data/lib/validic/diabetes.rb
CHANGED
@@ -1,64 +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 Diabetes
|
20
|
-
def get_diabetes(params={})
|
21
|
-
params = extract_params(params)
|
22
|
-
get_endpoint(:diabetes, params)
|
2
|
+
class Diabetes
|
3
|
+
include Validic::Utils
|
4
|
+
def initialize(attrs = {})
|
5
|
+
attributes_builder(attrs, self)
|
23
6
|
end
|
24
|
-
|
25
|
-
##
|
26
|
-
# Create Diabetes 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 :c_peptide
|
32
|
-
# @params :fasting_plasma_glucose_test
|
33
|
-
# @params :hba1c
|
34
|
-
# @params :insulin
|
35
|
-
# @params :oral_glucose_tolerance_test
|
36
|
-
# @params :random_plasma_glucose_test
|
37
|
-
# @params :triglyceride
|
38
|
-
# @params :timestamp
|
39
|
-
# @params :source
|
40
|
-
#
|
41
|
-
# @return success
|
42
|
-
def create_diabetes(options={})
|
43
|
-
options = {
|
44
|
-
authentication_token: options[:authentication_token],
|
45
|
-
access_token: options[:access_token],
|
46
|
-
diabetes: {
|
47
|
-
c_peptide: options[:c_peptide],
|
48
|
-
fasting_plasma_glucose_test: options[:fasting_plasma_glucose_test],
|
49
|
-
hba1c: options[:hba1c],
|
50
|
-
insulin: options[:insulin],
|
51
|
-
oral_glucose_tolerance_test: options[:oral_glucose_tolerance_test],
|
52
|
-
random_plasma_glucose_test: options[:random_plasma_glucose_test],
|
53
|
-
triglyceride: options[:triglyceride],
|
54
|
-
timestamp: options[:timestamp],
|
55
|
-
source: options[:source]
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
response = post("/#{Validic.api_version}/diabetes.json", options)
|
60
|
-
response if response
|
61
|
-
end
|
62
|
-
|
63
7
|
end
|
64
8
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Validic
|
2
|
+
class Error < StandardError
|
3
|
+
ClientError = Class.new(self)
|
4
|
+
ServerError = Class.new(self)
|
5
|
+
|
6
|
+
Unauthorized = Class.new(ClientError)
|
7
|
+
NotFound = Class.new(ClientError)
|
8
|
+
Forbidden = Class.new(ClientError)
|
9
|
+
UnprocessableEntity = Class.new(ClientError)
|
10
|
+
Conflict = Class.new(ClientError)
|
11
|
+
InternalServerError = Class.new(ServerError)
|
12
|
+
|
13
|
+
ERRORS = {
|
14
|
+
401 => Validic::Error::Unauthorized,
|
15
|
+
403 => Validic::Error::Forbidden,
|
16
|
+
404 => Validic::Error::NotFound,
|
17
|
+
409 => Validic::Error::Conflict,
|
18
|
+
422 => Validic::Error::UnprocessableEntity,
|
19
|
+
500 => Validic::Error::InternalServerError
|
20
|
+
}
|
21
|
+
|
22
|
+
def self.from_response(body)
|
23
|
+
code, errors = [body['code'], body['errors']]
|
24
|
+
message = "#{code}: #{errors}"
|
25
|
+
new(message)
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(message = '', code = nil)
|
29
|
+
super(message)
|
30
|
+
@code = code
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/validic/fitness.rb
CHANGED
@@ -1,61 +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 Fitness
|
20
|
-
def get_fitness(params={})
|
21
|
-
params = extract_params(params)
|
22
|
-
get_endpoint(:fitness, params)
|
2
|
+
class Fitness
|
3
|
+
include Validic::Utils
|
4
|
+
def initialize(attrs = {})
|
5
|
+
attributes_builder(attrs, self)
|
23
6
|
end
|
24
|
-
|
25
|
-
alias :get_fitnesses :get_fitness
|
26
|
-
|
27
|
-
##
|
28
|
-
# Create Fitness 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 :timestamp
|
34
|
-
# @params :primary_type
|
35
|
-
# @params :intensity
|
36
|
-
# @params :start_time
|
37
|
-
# @params :total_distance
|
38
|
-
# @params :duration
|
39
|
-
# @params :source
|
40
|
-
#
|
41
|
-
# @return success
|
42
|
-
def create_fitness(options={})
|
43
|
-
options = {
|
44
|
-
access_token: options[:access_token],
|
45
|
-
fitness: {
|
46
|
-
timestamp: options[:timestamp],
|
47
|
-
primary_type: options[:primary_type],
|
48
|
-
intensity: options[:intensity],
|
49
|
-
start_time: options[:start_time],
|
50
|
-
total_distance: options[:total_distance],
|
51
|
-
duration: options[:duration],
|
52
|
-
source: options[:source]
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
response = post("/#{Validic.api_version}/fitness.json", options)
|
57
|
-
response if response
|
58
|
-
end
|
59
|
-
|
60
7
|
end
|
61
8
|
end
|
data/lib/validic/nutrition.rb
CHANGED
@@ -1,65 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'validic/utils'
|
3
2
|
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 Nutrition
|
20
|
-
def get_nutritions(params={})
|
21
|
-
params = extract_params(params)
|
22
|
-
get_endpoint(:nutrition, params)
|
3
|
+
class Nutrition
|
4
|
+
include Validic::Utils
|
5
|
+
def initialize(attrs = {})
|
6
|
+
attributes_builder(attrs, self)
|
23
7
|
end
|
24
|
-
|
25
|
-
##
|
26
|
-
# Create Nutrition 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 :calories
|
32
|
-
# @params :carbohydrates
|
33
|
-
# @params :fat
|
34
|
-
# @params :fiber
|
35
|
-
# @params :protein
|
36
|
-
# @params :sodium
|
37
|
-
# @params :water
|
38
|
-
# @params :timestamp
|
39
|
-
# @params :meal
|
40
|
-
# @params :source
|
41
|
-
#
|
42
|
-
# @return success
|
43
|
-
def create_nutrition(options={})
|
44
|
-
options = {
|
45
|
-
access_token: options[:access_token],
|
46
|
-
nutrition: {
|
47
|
-
calories: options[:calories],
|
48
|
-
carbohydrates: options[:carbohydrates],
|
49
|
-
fat: options[:fat],
|
50
|
-
fiber: options[:fiber],
|
51
|
-
protein: options[:protein],
|
52
|
-
sodium: options[:sodium],
|
53
|
-
water: options[:water],
|
54
|
-
timestamp: options[:timestamp],
|
55
|
-
meal: options[:meal],
|
56
|
-
source: options[:source]
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
response = post("/#{Validic.api_version}/nutrition.json", options)
|
61
|
-
response if response
|
62
|
-
end
|
63
|
-
|
64
8
|
end
|
65
9
|
end
|