Class: Rebay2::Merchandising

Inherits:
Api
  • Object
show all
Defined in:
lib/rebay2/merchandising.rb

Constant Summary collapse

VERSION =
'1.5.0'

Constants inherited from Api

Api::EBAY_US

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api

base_url, base_url_prefix, configure

Class Method Details

.base_url_suffixObject



3
4
5
# File 'lib/rebay2/merchandising.rb', line 3

def self.base_url_suffix
  "ebay.com/MerchandisingService"
end

Instance Method Details

#get_most_watched_items(*params) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/rebay2/merchandising.rb', line 8

def get_most_watched_items(*params)
  #raise ArgumentError unless params[:categoryId]
  response = get_json_response(build_request_url('getMostWatchedItems', params||=nil))
  response.trim(:getMostWatchedItemsResponse)
  if response.response.has_key?('itemRecommendations') && response.response['itemRecommendations'].has_key?('item')
    response.results = response.response['itemRecommendations']['item']
  end
  return response
end

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
# File 'lib/rebay2/merchandising.rb', line 18

def get_related_category_items(params)
  raise ArgumentError unless params[:categoryId] or params[:itemId]
  response = get_json_response(build_request_url('getRelatedCategoryItems', params))
  response.trim(:getRelatedCategoryItemsResponse)
  if response.response.has_key?('itemRecommendations') && response.response['itemRecommendations'].has_key?('item')
    response.results = response.response['itemRecommendations']['item']
  end
  return response
end

#get_similar_items(params) ⇒ Object

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
# File 'lib/rebay2/merchandising.rb', line 28

def get_similar_items(params)
  raise ArgumentError unless params[:itemId]
  response = get_json_response(build_request_url('getSimilarItems', params))
  response.trim(:getSimilarItemsResponse)
  if response.response.has_key?('itemRecommendations') && response.response['itemRecommendations'].has_key?('item')
    response.results = response.response['itemRecommendations']['item']
  end
  return response
end

#get_top_selling_products(*params) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/rebay2/merchandising.rb', line 38

def get_top_selling_products(*params)
  response = get_json_response(build_request_url('getTopSellingProducts', params||= nil))
  response.trim(:getTopSellingProductsResponse)
  if response.response.has_key?('productRecommendations') && response.response['productRecommendations'].has_key?('product')
    response.results = response.response['productRecommendations']['product']
  end
  return response
end

#get_version(*params) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/rebay2/merchandising.rb', line 47

def get_version(*params)
  response = get_json_response(build_request_url('getVersion', params))
  response.trim(:getVersionResponse)
  if response.response.has_key?('version')
    response.results = response.response['version']
  end
  return response
end