Class: Rebay::Shopping

Inherits:
Api
  • Object
show all
Defined in:
lib/rebay/shopping.rb

Constant Summary collapse

VERSION =
'793'

Constants inherited from Api

Api::EBAY_US

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api

base_url, configure

Class Method Details

.base_url_prefixObject



6
7
8
# File 'lib/rebay/shopping.rb', line 6

def base_url_prefix
  "http://open.api"
end

.base_url_suffixObject



10
11
12
# File 'lib/rebay/shopping.rb', line 10

def base_url_suffix
  "ebay.com/shopping"
end

Instance Method Details

#find_half_products(params) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
# File 'lib/rebay/shopping.rb', line 27

def find_half_products(params)
  raise ArgumentError unless params[:ProductID] or params[:QueryKeywords] or
    (params[:'ProductID.Value'] && params[:'ProductID.type'])
  response = get_json_response(build_request_url('FindHalfProducts', params))
  if response.response.has_key?('Products') && response.response['Products'].has_key?('Product')
    response.results = response.response['Products']['Product']
  end
  return response
end

Raises:

  • (ArgumentError)


95
96
97
98
99
100
101
102
# File 'lib/rebay/shopping.rb', line 95

def find_popular_items(params={})
  raise ArgumentError unless params[:CategoryID] or params[:QueryKeywords]
  response = get_json_response(build_request_url('FindPopularItems', params))
  if response.response.has_key?('ItemArray') && response.response['ItemArray'].has_key?('Item')
    response.results = response.response['ItemArray']['Item']
  end
  return response
end

Raises:

  • (ArgumentError)


85
86
87
88
89
90
91
92
# File 'lib/rebay/shopping.rb', line 85

def find_popular_searches(params)
  raise ArgumentError unless params[:CategoryID]
  response = get_json_response(build_request_url('FindPopularSearches', params))
  if response.response.has_key?('PopularSearchResult')
    response.results = response.response['PopularSearchResult']
  end
  return response
end

#find_products(params) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
# File 'lib/rebay/shopping.rb', line 16

def find_products(params)
  raise ArgumentError unless params[:CategoryID] or params[:ProductID] or params[:QueryKeywords] or
    (params[:'ProductID.Value'] && params[:'ProductID.type'])
  response = get_json_response(build_request_url('FindProducts', params))
  if response.response.has_key?('Product')
    response.results = response.response['Product']
  end
  return response
end

#find_reviews_and_guides(params = {}) ⇒ Object



105
106
107
108
109
110
111
# File 'lib/rebay/shopping.rb', line 105

def find_reviews_and_guides(params={})
  response = get_json_response(build_request_url('FindReviewsAndGuides', params))
  if response.response.has_key?('BuyingGuideDetails') && response.response['BuyingGuideDetails'].has_key?('BuyingGuide')
    response.results = response.response['BuyingGuideDetails']['BuyingGuide']
  end
  return response
end

#get_category_info(params) ⇒ Object

Raises:

  • (ArgumentError)


114
115
116
117
118
119
120
121
# File 'lib/rebay/shopping.rb', line 114

def get_category_info(params)
  raise ArgumentError unless params[:CategoryID]
  response = get_json_response(build_request_url('GetCategoryInfo', params))
  if response.response.has_key?('CategoryArray') && response.response['CategoryArray'].has_key?('Category')
    response.results = response.response['CategoryArray']['Category']
  end
  return response
end

#get_category_info_with_children(params) ⇒ Object



123
124
125
126
127
# File 'lib/rebay/shopping.rb', line 123

def get_category_info_with_children(params)
  params[:IncludeSelector] = 'ChildCategories'
  response = get_category_info(params)
  return response
end

#get_item_status(params) ⇒ Object

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
55
# File 'lib/rebay/shopping.rb', line 48

def get_item_status(params)
  raise ArgumentError unless params[:ItemID]
  response = get_json_response(build_request_url('GetItemStatus', params))
  if response.response.has_key?('Item')
    response.results = response.response['Item']
  end
  return response
end

#get_multiple_items(params) ⇒ Object

Raises:

  • (ArgumentError)


65
66
67
68
69
70
71
72
# File 'lib/rebay/shopping.rb', line 65

def get_multiple_items(params)
  raise ArgumentError unless params[:ItemID]
  response = get_json_response(build_request_url('GetMultipleItems', params))
  if response.response.has_key?('Item')
    response.results = response.response['Item']
  end
  return response
end

#get_shipping_costs(params) ⇒ Object

Raises:

  • (ArgumentError)


58
59
60
61
62
# File 'lib/rebay/shopping.rb', line 58

def get_shipping_costs(params)
  raise ArgumentError unless params[:ItemID]
  response = get_json_response(build_request_url('GetShippingCosts', params))
  return response
end

#get_single_item(params) ⇒ Object

Raises:

  • (ArgumentError)


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

def get_single_item(params)
  raise ArgumentError unless params[:ItemID]
  response = get_json_response(build_request_url('GetSingleItem', params))
  if response.response.has_key?('Item')
    response.results = response.response['Item']
  end
  return response
end

#get_user_profile(params) ⇒ Object

Raises:

  • (ArgumentError)


75
76
77
78
79
80
81
82
# File 'lib/rebay/shopping.rb', line 75

def (params)
  raise ArgumentError unless params[:UserID]
  response = get_json_response(build_request_url('GetUserProfile', params))
  if response.response.has_key?('User')
    response.results = response.response['User']
  end
  return response
end