Sha256: 81cb4dae089a0f1bd0593487722ecb2b2a44d3bc4176d6a3e03af27f3f7769e0

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'validic/weight'

module Validic
  module REST
    module Weight

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

      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

      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

      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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
validic-0.6.1 lib/validic/rest/weight.rb
validic-0.6.0 lib/validic/rest/weight.rb
validic-0.5.1 lib/validic/rest/weight.rb
validic-0.5.0 lib/validic/rest/weight.rb