Sha256: 8be566905d777dc384a54a13945b5ab9a0d2a3e07f2856d721656d6b6fd586f0

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

require 'lipseys/api'

module Lipseys
  class Items < Base

    include Lipseys::API

    ENDPOINTS = {
      catalog_feed:          "items/catalogfeed".freeze,
      pricing_quantity_feed: "items/pricingquantityfeed".freeze,
      validate_item:         "items/validateitem".freeze,
      catalog_feed_item:     "items/catalogfeed/item".freeze,
    }

    def initialize(client)
      @client = client
    end

    def catalog_feed
      endpoint = ENDPOINTS[:catalog_feed]

      get_request(endpoint, auth_header(@client.access_token))
    end

    def pricing_quantity_feed
      endpoint = ENDPOINTS[:pricing_quantity_feed]

      get_request(endpoint, auth_header(@client.access_token))
    end

    # `identifier` can be Item #, Mfg Model #, or UPC
    def validate_item(identifier)
      endpoint = ENDPOINTS[:validate_item]
      headers  = [
        *auth_header(@client.access_token),
        *content_type_header('application/json'),
      ].to_h

      post_request(endpoint, "'#{identifier}'", headers)
    end

    # `identifier` can be Item #, Mfg Model #, or UPC
    def catalog_feed_item(identifier)
      endpoint = ENDPOINTS[:catalog_feed_item]
      headers  = [
        *auth_header(@client.access_token),
        *content_type_header('application/json'),
      ].to_h

      post_request(endpoint, "'#{identifier}'", headers)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lipseys-6.2.1 lib/lipseys/items.rb
lipseys-6.2.0 lib/lipseys/items.rb
lipseys-6.1.1 lib/lipseys/items.rb
lipseys-6.1.0 lib/lipseys/items.rb
lipseys-6.0.2 lib/lipseys/items.rb
lipseys-6.0.1 lib/lipseys/items.rb
lipseys-6.0.0 lib/lipseys/items.rb