ebay 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +27 -8
- data/contrib/get_and_store_ebay_categories.rb +240 -0
- data/examples/add_item.rb +12 -12
- data/examples/get_categories.rb +2 -2
- data/examples/get_categories2.rb +2 -2
- data/examples/get_feedback.rb +2 -1
- data/examples/get_notification_preferences.rb +52 -0
- data/examples/get_notifications_usage.rb +52 -0
- data/examples/get_suggested_categories.rb +31 -0
- data/examples/set_notification_preferences.rb +28 -0
- data/examples/verify_add_item.rb +12 -12
- data/lib/eBay.rb +6403 -3128
- data/lib/eBayAPI.rb +4 -4
- data/lib/eBayDriver.rb +49 -0
- data/test/tc_hello_world.rb +1 -0
- data/test/tc_items.rb +1 -0
- data/test/tc_routing.rb +51 -0
- metadata +8 -2
data/README
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
2
|
== Welcome to eBay4R
|
3
3
|
|
4
|
-
eBay4R is a Ruby wrapper for eBay's Web Services SOAP API (
|
4
|
+
eBay4R is a Ruby wrapper for eBay's Web Services SOAP API (v449). Emphasis is
|
5
5
|
on ease of use and small footprint.
|
6
6
|
|
7
|
-
<b>This code is currently
|
7
|
+
<b>This code is currently beta</b>.
|
8
8
|
|
9
9
|
Please report bugs and other problems, see "Author" section at the bottom.
|
10
10
|
|
@@ -117,7 +117,28 @@ This is a more complex example that performs a real (useful) function:
|
|
117
117
|
|
118
118
|
eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
|
119
119
|
|
120
|
-
#
|
120
|
+
# Notice how we nest hashes to mimic the XML structure of an AddItem request
|
121
|
+
resp = eBay.AddItem(:Item => { :PrimaryCategory => { :CategoryID => 57882 },
|
122
|
+
:Title => 'Mouse Pad',
|
123
|
+
:Description => 'A really cool mouse pad, you know you want it...',
|
124
|
+
:Location => 'On Earth',
|
125
|
+
:StartPrice => 12.0,
|
126
|
+
:Quantity => 1,
|
127
|
+
:ListingDuration => "Days_7",
|
128
|
+
:Country => "US",
|
129
|
+
:Currency => "USD",
|
130
|
+
:PaymentMethods => ["VisaMC", "PersonalCheck"] })
|
131
|
+
|
132
|
+
puts "New Item #" + resp.itemID + " added."
|
133
|
+
|
134
|
+
The way we nest hashes in the above AddItem() call may be confusing at first.
|
135
|
+
It is just a short-hand way of creating the complex types we need for the
|
136
|
+
call.
|
137
|
+
|
138
|
+
You may instead explicitly create the complex types (see "Creating Complex
|
139
|
+
Data Types" below) needed for the call (it makes the code longer, but a bit
|
140
|
+
more readable):
|
141
|
+
|
121
142
|
resp = eBay.AddItem(:Item => EBay.Item(:PrimaryCategory => EBay.Category(:CategoryID => 57882),
|
122
143
|
:Title => 'Mouse Pad',
|
123
144
|
:Description => 'A really cool mouse pad, you know you want it...',
|
@@ -129,8 +150,6 @@ This is a more complex example that performs a real (useful) function:
|
|
129
150
|
:Currency => "USD",
|
130
151
|
:PaymentMethods => ["VisaMC", "PersonalCheck"]))
|
131
152
|
|
132
|
-
puts "New Item #" + resp.itemID + " added."
|
133
|
-
|
134
153
|
|
135
154
|
=== Format of Requests
|
136
155
|
|
@@ -152,7 +171,7 @@ See the "eBay Web Services SOAP API Guide" for acceptable parameters and values
|
|
152
171
|
for each API call. This guide can be downloaded at eBay's
|
153
172
|
{SOAP Development Center}[http://developer.ebay.com/soap/].
|
154
173
|
|
155
|
-
====
|
174
|
+
==== Creating Complex Data Types
|
156
175
|
|
157
176
|
A number of elements in eBay's schema are XML Schema simple types. For
|
158
177
|
example, CategoryID, Title, and Description are all strings. But many
|
@@ -340,7 +359,7 @@ AIM: garry97531
|
|
340
359
|
|
341
360
|
== Copyright
|
342
361
|
|
343
|
-
Copyright (c) 2005 Garry C. Dolley
|
362
|
+
Copyright (c) 2005,2006 Garry C. Dolley
|
344
363
|
|
345
364
|
eBay4R is free software; you can redistribute it and/or modify it under the
|
346
365
|
terms of the GNU General Public License as published by the Free Software
|
@@ -356,4 +375,4 @@ You should have received a copy of the GNU General Public License along with
|
|
356
375
|
eBay4R; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
357
376
|
Street, Fifth Floor, Boston, MA 02110-1301, USA
|
358
377
|
|
359
|
-
$Id: README,v 1.
|
378
|
+
$Id: README,v 1.16 2006/04/24 05:51:18 garrydolley Exp $
|
@@ -0,0 +1,240 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# $Id: get_and_store_ebay_categories.rb,v 1.2 2006/01/18 09:42:02 garrydolley Exp $
|
3
|
+
#
|
4
|
+
# == Copyright
|
5
|
+
#
|
6
|
+
# Copyright (c) 2005,2006 Garry C. Dolley
|
7
|
+
#
|
8
|
+
# This file is part of eBay4R.
|
9
|
+
#
|
10
|
+
# eBay4R is free software; you can redistribute it and/or modify it under the
|
11
|
+
# terms of the GNU General Public License as published by the Free Software
|
12
|
+
# Foundation; either version 2 of the License, or (at your option) any later
|
13
|
+
# version.
|
14
|
+
#
|
15
|
+
# eBay4R is distributed in the hope that it will be useful, but WITHOUT ANY
|
16
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
18
|
+
# details.
|
19
|
+
#
|
20
|
+
# You should have received a copy of the GNU General Public License along with
|
21
|
+
# eBay4R; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
22
|
+
# Street, Fifth Floor, Boston, MA 02110-1301, USA
|
23
|
+
#
|
24
|
+
# Created : 01/16/2006
|
25
|
+
#
|
26
|
+
# == Synopsis
|
27
|
+
#
|
28
|
+
# This script will retrieve the entire eBay Category tree for a specified eBay
|
29
|
+
# site (site_id) and store it in a MySQL database.
|
30
|
+
#
|
31
|
+
# == Database
|
32
|
+
#
|
33
|
+
# The schema used is as follows:
|
34
|
+
#
|
35
|
+
# CREATE TABLE ebay_categories (
|
36
|
+
# id int(11) NOT NULL auto_increment,
|
37
|
+
# site_id smallint(6) default NULL,
|
38
|
+
# category_id varchar(10) NOT NULL default '',
|
39
|
+
# category_parent_id varchar(10) default NULL,
|
40
|
+
# category_name varchar(128) NOT NULL default '',
|
41
|
+
# category_level int(11) default NULL,
|
42
|
+
# leaf_category tinyint(1) NOT NULL default '0',
|
43
|
+
# expired tinyint(1) NOT NULL default '0',
|
44
|
+
# virtual tinyint(1) NOT NULL default '0',
|
45
|
+
# auto_pay_enabled tinyint(1) NOT NULL default '0',
|
46
|
+
# b2b_vat_enabled tinyint(1) NOT NULL default '0',
|
47
|
+
# best_offer_enabled tinyint(1) NOT NULL default '0',
|
48
|
+
# intl_autos_fixed_cat tinyint(1) NOT NULL default '0',
|
49
|
+
# lsd tinyint(1) NOT NULL default '0',
|
50
|
+
# orpa tinyint(1) NOT NULL default '0',
|
51
|
+
# orra tinyint(1) NOT NULL default '0',
|
52
|
+
# PRIMARY KEY (id),
|
53
|
+
# UNIQUE KEY site_id (site_id,category_id),
|
54
|
+
# KEY category_id (category_id),
|
55
|
+
# KEY category_parent_id (category_parent_id),
|
56
|
+
# CONSTRAINT ebay_categories_ibfk_1 FOREIGN KEY (category_parent_id)
|
57
|
+
# REFERENCES ebay_categories (category_id)
|
58
|
+
# ) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
59
|
+
#
|
60
|
+
# and
|
61
|
+
#
|
62
|
+
# CREATE TABLE ebay_categories_info (
|
63
|
+
# id int(11) NOT NULL auto_increment,
|
64
|
+
# site_id smallint(6) default NULL,
|
65
|
+
# category_version varchar(16) NOT NULL default '',
|
66
|
+
# minimum_reserve_price double default NULL,
|
67
|
+
# reduce_reserve_allowed tinyint(1) NOT NULL default '0',
|
68
|
+
# reserve_price_allowed tinyint(1) NOT NULL default '0',
|
69
|
+
# update_time datetime default NULL,
|
70
|
+
# PRIMARY KEY (id)
|
71
|
+
# UNIQUE KEY site_id (site_id)
|
72
|
+
# ) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
73
|
+
#
|
74
|
+
# == Usage
|
75
|
+
#
|
76
|
+
# ./get_and_store_ebay_categories.rb -s site_id [ -t | --table TABLE_BASE_NAME ] [ -h | --host HOST ] [ -d | --database DB ] [ -u | --user USER ] [ -p | --password PW ] [ --debug ] [ -c concurrency ]
|
77
|
+
#
|
78
|
+
# Example site IDs: 0 = eBay USA, 2 = eBay Canada, 100 = eBay Motors
|
79
|
+
#
|
80
|
+
# Just like the examples/ directory, you need a file named
|
81
|
+
# "myCredentials.rb" in the current directory or Ruby load path.
|
82
|
+
#
|
83
|
+
# The "-c concurrency" command line option says how many category nodes we
|
84
|
+
# retrieve at a time. Default is 20. All direct children are also
|
85
|
+
# downloaded (grouped BFS).
|
86
|
+
#
|
87
|
+
# If you are getting out of memory errors, reduce this number.
|
88
|
+
# If you have lots of memory, you can increase this number and the import
|
89
|
+
# will be faster.
|
90
|
+
#
|
91
|
+
# Note: The eBay Category tree is very large. This script can run for 20
|
92
|
+
# minutes or longer.
|
93
|
+
|
94
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
95
|
+
|
96
|
+
require 'eBayAPI'
|
97
|
+
|
98
|
+
require 'optparse'
|
99
|
+
require 'rdoc/usage'
|
100
|
+
|
101
|
+
begin
|
102
|
+
require 'rubygems'
|
103
|
+
require_gem 'mysql'
|
104
|
+
rescue LoadError
|
105
|
+
require 'mysql'
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Set defaults and parse command line args
|
110
|
+
#
|
111
|
+
|
112
|
+
mysql_hostname = 'localhost'
|
113
|
+
mysql_database = 'test'
|
114
|
+
mysql_username = 'test'
|
115
|
+
mysql_password = ''
|
116
|
+
|
117
|
+
site_id = 0
|
118
|
+
table_name = "ebay_categories"
|
119
|
+
concurrency = 20
|
120
|
+
|
121
|
+
debug = false
|
122
|
+
|
123
|
+
opts = OptionParser.new
|
124
|
+
opts.on("-h", "--help") { RDoc::usage('usage') }
|
125
|
+
opts.on("-s SITE_ID") { |sid| site_id = sid }
|
126
|
+
opts.on("-c concurrency") { |c| concurrency = c.to_i }
|
127
|
+
|
128
|
+
opts.on("-h", "--host HOST") { |h| mysql_hostname = h }
|
129
|
+
opts.on("-d", "--database DB") { |d| mysql_database = d }
|
130
|
+
opts.on("-u", "--user USER") { |u| mysql_username = u }
|
131
|
+
opts.on("-p", "--password PW") { |p| mysql_password = p }
|
132
|
+
opts.on("--debug") { debug = true }
|
133
|
+
|
134
|
+
opts.on("-t", "--table TABLE_NAME") { |t| table_name = t }
|
135
|
+
|
136
|
+
opts.parse(ARGV) rescue RDoc::usage('usage')
|
137
|
+
|
138
|
+
if ARGV.size < 1
|
139
|
+
RDoc::usage('usage')
|
140
|
+
exit
|
141
|
+
end
|
142
|
+
|
143
|
+
#
|
144
|
+
# Open MySQL database
|
145
|
+
#
|
146
|
+
|
147
|
+
mysql = Mysql.new(mysql_hostname, mysql_username, mysql_password)
|
148
|
+
mysql.select_db(mysql_database)
|
149
|
+
|
150
|
+
# Put your credentials in this file
|
151
|
+
load('myCredentials.rb')
|
152
|
+
|
153
|
+
# Create new eBay caller object. Omit last argument to use live platform.
|
154
|
+
eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
|
155
|
+
eBay.debug = true if debug
|
156
|
+
|
157
|
+
parents_to_process = [ :id => '', :depth => 0 ]
|
158
|
+
|
159
|
+
#
|
160
|
+
# Traverse entire category tree and import into our database
|
161
|
+
#
|
162
|
+
|
163
|
+
puts "Starting import... Go get some coffee, this is going to take a while..."
|
164
|
+
|
165
|
+
imported_site_wide_info = false
|
166
|
+
i = 0
|
167
|
+
while (some_parents = parents_to_process.first(concurrency)).length > 0
|
168
|
+
seek_depth = some_parents.max { |a,b| a[:depth] <=> b[:depth] }
|
169
|
+
seek_depth = seek_depth[:depth] + 1
|
170
|
+
|
171
|
+
if debug
|
172
|
+
puts "Current process queue:"
|
173
|
+
p parents_to_process
|
174
|
+
puts "Up next:"
|
175
|
+
p some_parents
|
176
|
+
end
|
177
|
+
|
178
|
+
resp = eBay.GetCategories(:DetailLevel => 'ReturnAll', # Return all available info
|
179
|
+
:CategorySideID => site_id,
|
180
|
+
:CategoryParent => (some_parents[0][:id] == '' && some_parents.length == 1) ? '' : some_parents.collect { |a| a[:id] },
|
181
|
+
:ViewAllNotes => true,
|
182
|
+
:LevelLimit => seek_depth)
|
183
|
+
|
184
|
+
parents_to_process -= some_parents
|
185
|
+
|
186
|
+
if !imported_site_wide_info
|
187
|
+
mysql.query("DELETE FROM #{table_name}_info WHERE site_id = #{site_id}")
|
188
|
+
|
189
|
+
mysql.query("INSERT INTO #{table_name}_info VALUES (null, '#{site_id}', '#{resp.categoryVersion}', '#{resp.minimumReservePrice}', #{resp.reduceReserveAllowed},
|
190
|
+
#{resp.reservePriceAllowed}, '#{resp.updateTime}')")
|
191
|
+
|
192
|
+
imported_site_wide_info = true
|
193
|
+
end
|
194
|
+
|
195
|
+
if resp.categoryCount.to_i > 0
|
196
|
+
[resp.categoryArray.category].flatten.each do |cat|
|
197
|
+
if cat.categoryLevel.to_i == seek_depth
|
198
|
+
if cat.leafCategory == "false"
|
199
|
+
parents_to_process << { :id => cat.categoryID, :depth => cat.categoryLevel.to_i }
|
200
|
+
puts "Added Category ##{cat.categoryID} to process queue..." if debug
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Make sure we don't try to INSERT a category we already have
|
205
|
+
r = mysql.query("SELECT category_id FROM #{table_name} WHERE category_id = #{cat.categoryID} AND site_id = #{site_id}")
|
206
|
+
|
207
|
+
if r.num_rows < 1
|
208
|
+
if cat.categoryID == cat.categoryParentID
|
209
|
+
cat.categoryParentID = "null"
|
210
|
+
else
|
211
|
+
cat.categoryParentID = "'#{cat.categoryParentID}'"
|
212
|
+
end
|
213
|
+
|
214
|
+
cat.categoryName = mysql.escape_string(cat.categoryName)
|
215
|
+
|
216
|
+
# Determine values of conditional fields
|
217
|
+
auto_pay = cat.respond_to?(:autoPayEnabled) ? cat.autoPayEnabled : false
|
218
|
+
b2b_vat = cat.respond_to?(:b2BVATEnabled) ? cat.b2BVATEnabled : false
|
219
|
+
best_offer = cat.respond_to?(:bestOfferEnabled) ? cat.bestOfferEnabled : false
|
220
|
+
orra = cat.respond_to?(:oRRA) ? cat.oRRA : false
|
221
|
+
sge = cat.respond_to?(:sellerGuaranteeEligible) ? cat.sellerGuaranteeEligible : false
|
222
|
+
|
223
|
+
puts "Inserting Category ##{cat.categoryID}: #{cat.categoryName}..." if debug
|
224
|
+
|
225
|
+
#
|
226
|
+
# Do the actual writing to the database
|
227
|
+
#
|
228
|
+
mysql.query("INSERT INTO #{table_name}
|
229
|
+
VALUES (null, '#{site_id}', '#{cat.categoryID}', #{cat.categoryParentID}, '#{cat.categoryName}', '#{cat.categoryLevel}', #{cat.leafCategory},
|
230
|
+
#{cat.expired}, #{cat.virtual}, #{auto_pay}, #{b2b_vat}, #{best_offer}, #{cat.intlAutosFixedCat}, #{cat.lSD}, #{cat.oRPA}, #{orra},
|
231
|
+
#{sge})")
|
232
|
+
|
233
|
+
i += 1
|
234
|
+
puts "Imported #{i} categories so far..." if i % 100 == 0
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
mysql.close
|
data/examples/add_item.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# $Id: add_item.rb,v 1.
|
2
|
+
# $Id: add_item.rb,v 1.11 2006/01/13 09:56:29 garrydolley Exp $
|
3
3
|
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
5
|
require 'eBayAPI'
|
@@ -12,17 +12,17 @@ load('myCredentials.rb')
|
|
12
12
|
|
13
13
|
eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
|
14
14
|
|
15
|
-
#
|
16
|
-
resp = eBay.AddItem(:Item =>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
# Shorter way of passing complex types (implied by hashing) than when we did in v0.5.2 and prior
|
16
|
+
resp = eBay.AddItem(:Item => { :PrimaryCategory => { :CategoryID => 57882 },
|
17
|
+
:Title => 'Mouse Pad',
|
18
|
+
:Description => 'A really cool mouse pad, you know you want it...',
|
19
|
+
:Location => 'On Earth',
|
20
|
+
:StartPrice => 12.0,
|
21
|
+
:Quantity => 1,
|
22
|
+
:ListingDuration => "Days_7",
|
23
|
+
:Country => "US",
|
24
|
+
:Currency => "USD",
|
25
|
+
:PaymentMethods => ["VisaMC", "PersonalCheck"] })
|
26
26
|
|
27
27
|
puts "New Item #" + resp.itemID + " added."
|
28
28
|
puts "You spent:\n"
|
data/examples/get_categories.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# $Id: get_categories.rb,v 1.
|
2
|
+
# $Id: get_categories.rb,v 1.2 2006/01/16 09:52:56 garrydolley Exp $
|
3
3
|
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
5
|
|
@@ -17,7 +17,7 @@ eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
|
|
17
17
|
|
18
18
|
# Call "GetCategories"
|
19
19
|
resp = eBay.GetCategories(:DetailLevel => 'ReturnAll', # Return all available info
|
20
|
-
:CategorySideID =>
|
20
|
+
:CategorySideID => 0, # US site
|
21
21
|
:LevelLimit => 1) # Only 1 level deep
|
22
22
|
|
23
23
|
# Report results
|
data/examples/get_categories2.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# $Id: get_categories2.rb,v 1.
|
2
|
+
# $Id: get_categories2.rb,v 1.3 2006/01/16 09:54:08 garrydolley Exp $
|
3
3
|
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
5
|
|
@@ -17,7 +17,7 @@ eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true, :sit
|
|
17
17
|
|
18
18
|
# Call "GetCategories"
|
19
19
|
resp = eBay.GetCategories(:DetailLevel => 'ReturnAll', # Return all available info
|
20
|
-
:CategorySideID => 100, # US eBay Motors Site
|
20
|
+
:CategorySideID => 100, # US eBay Motors Site
|
21
21
|
:LevelLimit => 2) # 2 Levels Deep
|
22
22
|
|
23
23
|
# Report results
|
data/examples/get_feedback.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# $Id: get_feedback.rb,v 1.
|
2
|
+
# $Id: get_feedback.rb,v 1.3 2006/01/25 08:38:42 garrydolley Exp $
|
3
3
|
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
5
|
require 'eBayAPI'
|
@@ -45,3 +45,4 @@ puts "Total Feedback:"
|
|
45
45
|
resp.feedbackSummary.totalFeedbackPeriodArray.feedbackPeriod.each do |fb|
|
46
46
|
puts " Last #{fb.periodInDays} Days: #{fb.count}"
|
47
47
|
end
|
48
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# $Id: get_notification_preferences.rb,v 1.2 2006/03/10 03:52:37 garrydolley Exp $
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
|
+
require 'eBayAPI'
|
6
|
+
|
7
|
+
#
|
8
|
+
# Example of GetNotificationPreferences call
|
9
|
+
#
|
10
|
+
|
11
|
+
# Put your credentials in this file
|
12
|
+
load('myCredentials.rb')
|
13
|
+
|
14
|
+
# Create new eBay caller object. Omit last argument to use live platform.
|
15
|
+
eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
|
16
|
+
|
17
|
+
resp = eBay.GetNotificationPreferences(:PreferenceLevel => 'User')
|
18
|
+
|
19
|
+
if resp.respond_to? 'userDeliveryPreferenceArray'
|
20
|
+
[resp.userDeliveryPreferenceArray.notificationEnable].flatten.each do |pref|
|
21
|
+
puts "Event Enable: " + pref.eventEnable
|
22
|
+
puts "Event Type: " + pref.eventType
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
resp = eBay.GetNotificationPreferences(:PreferenceLevel => 'Application')
|
27
|
+
|
28
|
+
if resp.respond_to? 'applicationDeliveryPreferences'
|
29
|
+
[resp.applicationDeliveryPreferences].flatten.each do |pref|
|
30
|
+
puts "Alert Email: " + pref.alertEmail if pref.respond_to? 'alertEmail'
|
31
|
+
puts "Alert Enable: " + pref.alertEnable if pref.respond_to? 'alertEnable'
|
32
|
+
puts "Application Enable: " + pref.applicationEnable if pref.respond_to? 'applicationEnable'
|
33
|
+
puts "Application URL: " + pref.applicationURL if pref.respond_to? 'applicationURL'
|
34
|
+
puts "Device Type: " + pref.deviceType if pref.respond_to? 'deviceType'
|
35
|
+
puts "Notification Payload: " + pref.notificationPayloadType if pref.respond_to? 'notificationPayloadType'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
resp = eBay.GetNotificationPreferences(:PreferenceLevel => 'Event')
|
40
|
+
|
41
|
+
if resp.respond_to? 'eventProperty'
|
42
|
+
[resp.eventProperty].flatten.each do |e|
|
43
|
+
puts "Event Type: " + e.eventType
|
44
|
+
puts "Name: " + e.name
|
45
|
+
puts "Value: " + e.value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# More fields are present, see eBay's SOAP API Guide
|
50
|
+
#
|
51
|
+
# If you add on to this example with more fields, please send it to
|
52
|
+
# gdolley@ucla.edu so I can include it with the next release :)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# $Id: get_notifications_usage.rb,v 1.4 2006/03/16 09:37:51 garrydolley Exp $
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
|
+
require 'eBayAPI'
|
6
|
+
|
7
|
+
#
|
8
|
+
# Example of GetNotificationsUsage call
|
9
|
+
#
|
10
|
+
|
11
|
+
# Put your credentials in this file
|
12
|
+
load('myCredentials.rb')
|
13
|
+
|
14
|
+
# Create new eBay caller object. Omit last argument to use live platform.
|
15
|
+
eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
|
16
|
+
eBay.debug = true
|
17
|
+
|
18
|
+
# Fill this in with a real item number to get more info about notifications
|
19
|
+
item_no = ''
|
20
|
+
|
21
|
+
if !item_no.empty?
|
22
|
+
resp = eBay.GetNotificationsUsage(:ItemID => item_no)
|
23
|
+
|
24
|
+
[resp.notificationDetailsArray.notificationDetails].flatten.each do |notif|
|
25
|
+
puts "Delivery Status: " + notif.deliveryStatus
|
26
|
+
puts "Delivery Time: " + notif.deliveryTime if notif.respond_to? 'deliveryTime'
|
27
|
+
puts "Delivery URL: " + notif.deliveryURL
|
28
|
+
puts "Error Message: " + notif.errorMessage
|
29
|
+
puts "Expiration Time: " + notif.expirationTime
|
30
|
+
puts "Next Retry Time: " + notif.nextRetryTime
|
31
|
+
puts "Retries: " + notif.retries if notif.respond_to? 'retries'
|
32
|
+
# puts "Type: " + notif.type # Mmmm... "type" is already a method of Object
|
33
|
+
end if resp.notificationDetailsArray.respond_to? 'notificationDetails'
|
34
|
+
end
|
35
|
+
|
36
|
+
resp = eBay.GetNotificationsUsage
|
37
|
+
|
38
|
+
ns = resp.notificationStatistics
|
39
|
+
|
40
|
+
puts "Current Counters: "
|
41
|
+
puts " Delivered: " + ns.deliveredCount
|
42
|
+
puts " Errors: " + ns.errorCount
|
43
|
+
puts " Expired: " + ns.expiredCount
|
44
|
+
puts " Queued New: " + ns.queuedNewCount
|
45
|
+
puts " Queued Pending: " + ns.queuedPendingCount
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
# More fields are present, see eBay's SOAP API Guide
|
50
|
+
#
|
51
|
+
# If you add on to this example with more fields, please send it to
|
52
|
+
# gdolley@ucla.edu so I can include it with the next release :)
|