class Ebay::Finding::Api::Client

Public Class Methods

new(app_id, sandbox = true) click to toggle source
# File lib/ebay/finding/api/client.rb, line 8
def initialize(app_id, sandbox = true)
  @app_id  = app_id
  @sandbox = sandbox
  @base_options = { "SECURITY-APPNAME" => @app_id, "SERVICE-VERSION" => SERVICE_VERSION, "REST-PAYLOAD" => "TRUE",
                    "RESPONSE-DATA-FORMAT" => "JSON" }
end

Public Instance Methods

find_items_by_keywords(keyword) click to toggle source
# File lib/ebay/finding/api/client.rb, line 15
def find_items_by_keywords(keyword)
  operation_name = "findItemsByKeywords"
  options = @base_options.merge("OPERATION-NAME" => operation_name, "keywords" => keyword)

  Response.new(operation_name, connection.get("/services/search/FindingService/v1", options))
end
find_items_by_product(type, product_id) click to toggle source
# File lib/ebay/finding/api/client.rb, line 22
def find_items_by_product(type, product_id)
  operation_name = "findItemsByProduct"

  unless PRODUCT_TYPES.include? type
    raise ArgumentError.new("You need to pass string 'ISBN', 'UPC', 'EAN' or 'ReferenceID' to first argument")
  end
  options = @base_options.merge("OPERATION-NAME" => operation_name, "productId.@type" => type,
                                "productId" => product_id)

  Response.new(operation_name, connection.get("/services/search/FindingService/v1", options))
end

Private Instance Methods

connection() click to toggle source
# File lib/ebay/finding/api/client.rb, line 36
def connection
  @connection ||= Faraday.new(url: @sandbox ? SANDBOX_ENDPOINT : PRODUCTION_ENDPOINT)
end