Module: Validic::REST::Weight

Included in:
Client
Defined in:
lib/validic/rest/weight.rb

Instance Method Summary collapse

Instance Method Details

#create_weight(options = {}) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/validic/rest/weight.rb', line 12

def create_weight(options={})
  user_id = options.delete(:user_id)
  options = { user_id: user_id, weight: options }
  resp = post_request(:weight, options)

  Validic::Weight.new(resp['weight'])
end

#delete_weight(options = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/validic/rest/weight.rb', line 27

def delete_weight(options = {})
  user_id, _id = options.delete(:user_id), options.delete(:_id)
  options = { user_id: user_id, _id: _id }
  delete_request(:weight, options)
  true
end

#get_weight(params = {}) ⇒ Object Also known as: get_weights



7
8
9
# File 'lib/validic/rest/weight.rb', line 7

def get_weight(params={})
  build_response(get_request(:weight, params))
end

#latest_weight(options = {}) ⇒ Object



34
35
36
# File 'lib/validic/rest/weight.rb', line 34

def latest_weight(options={})
  build_response(latest(:weight, options))
end

#update_weight(options = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/validic/rest/weight.rb', line 20

def update_weight(options={})
  user_id, _id = options.delete(:user_id), options.delete(:_id)
  options = { user_id: user_id, _id: _id, weight: options }
  response = put_request(:weight, options)
  Validic::Weight.new(response["weight"])
end