Sha256: 085221682eb45698056e7862ecfc9708e8d0f681a4a97958b3b716ac153e80e7

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module ExtendWarranties
  module Api
    class Products < Base

      def all(store_id, args = {})
        raise ArgumentError, 'store_id is required' if store_id.blank?

        resp = connection.get "/stores/#{store_id}/products", args
        handle_response(resp)
      end

      def create(store_id, args = {})
        raise ArgumentError, 'store_id is required' if store_id.blank?

        resp = connection.post "/stores/#{store_id}/products", args
        handle_response(resp)
      end

      def update(store_id, product_id, args = {})
        raise ArgumentError, 'store_id is required' if store_id.blank?

        resp = connection.put "/stores/#{store_id}/products/#{product_id}", args
        handle_response(resp)
      end

      def find_by_id(store_id, product_id, args = {})
        raise ArgumentError, 'store_id is required' if store_id.blank?
        raise ArgumentError, 'product_id is required' if product_id.blank?

        resp = connection.get "/stores/#{store_id}/products/#{product_id}", args
        handle_response(resp)
      end

      def delete(store_id, product_id, args={})
        raise ArgumentError, 'store_id is required' if store_id.blank?
        raise ArgumentError, 'product_id is required' if product_id.blank?

        resp = connection.delete "/stores/#{store_id}/products/#{product_id}", args
        handle_response(resp)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
extend_warranties-0.1.0 lib/extend_warranties/api/products.rb