Sha256: ed443be7d74da48d032e2cce9b46115b23a0691502555cdaa0ec683c31065e0f

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8

module Nimbu
  module Endpoints
    class Products < Endpoint
      def list(*args)
        arguments(args)

        response = get_request("/products", arguments.params)
        return response unless block_given?
        response.each { |el| yield el }
      end
      alias :all :list

      def get(*args)
        arguments(args, :required => [:product_id])

        get_request("/products/#{product_id}", arguments.params)
      end
      alias :find :get

      def count(*args)
        arguments(args)

        get_request("/products/count", arguments.params)
      end

      def create(*args)
        arguments(args)

        post_request("/products", arguments.params)
      end

      def update(*args)
        arguments(args, :required => [:product_id])

        patch_request("/products/#{product_id}", arguments.params)
      end
      alias :edit :update

      def delete(*args)
        arguments(args, :required => [:product_id])

        delete_request("/products/#{product_id}", arguments.params)
      end
      alias :remove :delete

    end # Products
  end # Endpoints
end # Nimbu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nimbu-api-0.4.1 lib/nimbu-api/endpoints/products.rb
nimbu-api-0.4.0 lib/nimbu-api/endpoints/products.rb