Class: Ebay::Finding::Api::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ebay/finding/api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(app_id, sandbox = true) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
# 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

Instance Method Details

#find_items_by_keywords(keyword) ⇒ Object



15
16
17
18
19
20
# 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) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# 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