Sha256: c62e0c145e1d5082bf36408dabd0e9f83f33ee90a90f3075176dbf2a9eb9e53d

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Alegra
  class Items
    attr_reader :client

    def initialize(client)
      @client = client
    end

    # @param id [ Interger ]
    # @return [ Hash ]
    def find(id)
      client.get("items/#{ id }")
    end

    # Return all items
    # @return [ Array ]
    def list()
      client.get('items')
    end

    # @param params [ Hash ]
    # @return [ Hash ]
    #       - name [ String ]
    #       - description [ String ]
    #       - reference [ String ]
    #       - price [ Array ]
    #       - category [ Hash ]
    #       - inventory [ Hash ]
    #       - tax [ Array ]
    def create(params)
      _params = params.deep_camel_case_lower_keys
      client.post('items', _params)
    end

    # @param id [ Integer ]
    # @param params [ Hash ]
    # @return [ Hash ]
    #       - name [ String ]
    #       - description [ String ]
    #       - reference [ String ]
    #       - price [ Array ]
    #       - category [ Hash ]
    #       - inventory [ Hash ]
    #       - tax [ Array ]
    def update(id, params)
      _params = params.deep_camel_case_lower_keys
      client.put("items/#{ id }", _params)
    end

    # @param id [ Integer ]
    # @return [ Hash ]
    def delete(id)
      client.delete("items/#{ id }")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alegra-0.1.2.3 lib/alegra/items.rb
alegra-0.1.2.2 lib/alegra/items.rb
alegra-0.1.2.1 lib/alegra/items.rb
alegra-0.1.2 lib/alegra/items.rb