ebayapi 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. data/CHANGELOG +6 -0
  2. data/Rakefile +2 -2
  3. data/examples/add_item.rb +50 -0
  4. data/examples/add_member_message_aaq_to_partner.rb +33 -0
  5. data/examples/config.rb +10 -0
  6. data/examples/end_item.rb +18 -0
  7. data/examples/get_api_usage.rb +21 -0
  8. data/examples/get_attributes_xsl.rb +26 -0
  9. data/examples/get_ebay_details.rb +22 -0
  10. data/examples/get_ebay_time.rb +33 -0
  11. data/examples/get_ebay_time_raw.rb +31 -0
  12. data/examples/get_item.rb +25 -0
  13. data/examples/get_item_transactions.rb +36 -0
  14. data/examples/get_items_selling.rb +26 -0
  15. data/examples/get_my_messages.rb +21 -0
  16. data/examples/get_my_messages_folders.rb +20 -0
  17. data/examples/get_notification_preferences.rb +36 -0
  18. data/examples/get_notifications_usage.rb +23 -0
  19. data/examples/get_product_finder_xsl.rb +27 -0
  20. data/examples/get_search_results.rb +51 -0
  21. data/examples/get_user.rb +26 -0
  22. data/examples/mark_my_messages_message_as_read.rb +22 -0
  23. data/examples/revise_item.rb +34 -0
  24. data/examples/set_notification_preferences.rb +27 -0
  25. data/examples/verify_add_item.rb +37 -0
  26. data/lib/ebay/api.rb +5 -5
  27. data/lib/ebay/api_methods.rb +8 -0
  28. data/lib/ebay/requests.rb +1 -0
  29. data/lib/ebay/requests/get_category_listings.rb +3 -0
  30. data/lib/ebay/requests/get_my_ebay_buying.rb +3 -0
  31. data/lib/ebay/requests/get_search_results.rb +11 -0
  32. data/lib/ebay/requests/set_shipping_discount_profiles.rb +3 -3
  33. data/lib/ebay/requests/upload_site_hosted_pictures.rb +22 -0
  34. data/lib/ebay/responses.rb +1 -0
  35. data/lib/ebay/responses/get_my_ebay_buying.rb +3 -0
  36. data/lib/ebay/responses/get_shipping_discount_profiles.rb +3 -3
  37. data/lib/ebay/responses/upload_site_hosted_pictures.rb +18 -0
  38. data/lib/ebay/schema/mapper/ebay_schema_importer.rb +1 -1
  39. data/lib/ebay/schema/mapper/ruby_class_generator.rb +1 -1
  40. data/lib/ebay/schema/mapper/templates/xsl_file.erb +2 -1
  41. data/lib/ebay/schema/version.rb +1 -1
  42. data/lib/ebay/types.rb +8 -0
  43. data/lib/ebay/types/ad_format_lead.rb +2 -0
  44. data/lib/ebay/types/base64_binary.rb +17 -0
  45. data/lib/ebay/types/bid_assistant_list.rb +17 -0
  46. data/lib/ebay/types/bid_group.rb +22 -0
  47. data/lib/ebay/types/bid_group_array.rb +16 -0
  48. data/lib/ebay/types/bid_group_item.rb +20 -0
  49. data/lib/ebay/types/bid_group_item_status_code.rb +16 -0
  50. data/lib/ebay/types/bid_group_status_code.rb +11 -0
  51. data/lib/ebay/types/bid_range.rb +17 -0
  52. data/lib/ebay/types/bidding_details.rb +2 -0
  53. data/lib/ebay/types/buyer_protection_details.rb +17 -0
  54. data/lib/ebay/types/buyer_protection_source_code.rb +11 -0
  55. data/lib/ebay/types/category_feature.rb +2 -0
  56. data/lib/ebay/types/category_listings_order_code.rb +1 -0
  57. data/lib/ebay/types/classified_ad_pay_per_lead_enabled_definition.rb +13 -0
  58. data/lib/ebay/types/date.rb +19 -0
  59. data/lib/ebay/types/extended_contact_details.rb +4 -0
  60. data/lib/ebay/types/feature_definitions.rb +3 -0
  61. data/lib/ebay/types/feature_id_code.rb +4 -0
  62. data/lib/ebay/types/group.rb +17 -0
  63. data/lib/ebay/types/item.rb +9 -0
  64. data/lib/ebay/types/item_condition_code.rb +11 -0
  65. data/lib/ebay/types/item_sort_type_code.rb +2 -0
  66. data/lib/ebay/types/listing_details.rb +2 -0
  67. data/lib/ebay/types/picture_format_code.rb +11 -0
  68. data/lib/ebay/types/picture_set_code.rb +12 -0
  69. data/lib/ebay/types/picture_set_member.rb +19 -0
  70. data/lib/ebay/types/request_categories.rb +2 -0
  71. data/lib/ebay/types/search_sort_order_code.rb +1 -0
  72. data/lib/ebay/types/shipping_details.rb +2 -0
  73. data/lib/ebay/types/shipping_service_code.rb +3 -0
  74. data/lib/ebay/types/site_defaults.rb +2 -0
  75. data/lib/ebay/types/site_hosted_picture_details.rb +26 -0
  76. data/lib/ebay/types/store_custom_listing_header.rb +0 -2
  77. data/lib/ebay/types/ticket_details.rb +24 -0
  78. data/lib/ebay/types/ticket_event_type_code.rb +31 -0
  79. data/lib/ebay/types/transaction.rb +4 -0
  80. data/lib/ebay/types/transaction_platform_code.rb +13 -0
  81. data/lib/ebay/types/xsl_file.rb +2 -1
  82. data/rakefile +2 -2
  83. metadata +49 -4
  84. data/lib/ebay/types/promotional_shipping_discount.rb +0 -21
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ # * Update the Rakefile to include the examples, set version 0.10.2
2
+ # * Update to eBay XML Schema Version 513
3
+ # * Ensure that nil values aren't used as headers in the HTTP request
4
+ # * Update to eBay XML Schema Version 511
5
+ # * Tweak modification to xsl stylesheets
6
+ # * Add an example for get_search_results with pagination
1
7
  # * Release 0.10.0
2
8
  # * Update the documentation for better navigation. Provide links to official documentation. Don't use method_missing anymore
3
9
  # * Add eBay documentation from the schema into the RDoc. Generate method calls for all API calls so they are documented
data/Rakefile CHANGED
@@ -6,12 +6,12 @@ require 'rake/rdoctask'
6
6
  require 'rake/gempackagetask'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
8
 
9
- PKG_VERSION = "0.10.1"
9
+ PKG_VERSION = "0.10.2"
10
10
  PKG_NAME = "ebayapi"
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
 
13
13
  PKG_FILES = FileList[
14
- "lib/**/*", "test/**/*", "example/**/*", "[A-Z]*", "rakefile", "init.rb"
14
+ "lib/**/*", "test/**/*", "examples/**/*", "[A-Z]*", "rakefile", "init.rb"
15
15
  ].exclude(/~$|\.svn/)
16
16
 
17
17
  response_dir = File.join(File.dirname(__FILE__), 'test', 'fixtures', 'responses')
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ include Ebay
9
+ include Ebay::Types
10
+
11
+ # With no options, the default is to use the default site_id and the default
12
+ # auth_token configured on the Api class.
13
+ ebay = Api.new
14
+
15
+ # However, another user's auth_token can be used and the site can be selected
16
+ # at the time of creation. Ex: Canada with another user's auth token.
17
+ # ebay = Api.new(:site_id => 2, :auth_token => 'TEST')
18
+
19
+ # In this example I am simple passing in the strings 'Days_7', 'USD' and others.
20
+ # However, there are constants defined for these code types, which can be enumerated
21
+ # For example, CurrencyCode::CAD
22
+ # For enumerating through the available types: CurrencyCode.each{|code| puts code}
23
+
24
+ item = Item.new( :primary_category => Category.new(:category_id => 57882),
25
+ :title => 'Ruby eBay API Test Listing',
26
+ :description => 'Welcome!',
27
+ :location => 'Ottawa, On',
28
+ :start_price => Money.new(1200, 'USD'),
29
+ :quantity => 1,
30
+ :listing_duration => 'Days_7',
31
+ :country => 'US',
32
+ :currency => 'USD',
33
+ :payment_methods => ['VisaMC', 'PersonalCheck']
34
+ )
35
+
36
+ begin
37
+ response = ebay.add_item(:item => item)
38
+ puts "Adding item"
39
+ puts "eBay time is: #{response.timestamp}"
40
+
41
+ puts "Item ID: #{response.item_id}"
42
+ puts "Fee summary: "
43
+ response.fees.select{|f| !f.fee.zero? }.each do |f|
44
+ puts " #{f.name}: #{f.fee.format(:with_currency)}"
45
+ end
46
+ rescue Ebay::RequestError => e
47
+ e.errors.each do |error|
48
+ puts error.long_message
49
+ end
50
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ # The buyer and seller must be in a transactional relationship
9
+ # Use this example as follows:
10
+ # > ruby add_member_message_aaq_to_partner.rb RECIPIENT_EBAY_ID ITEM_ID
11
+ #
12
+ # A new message will be delivered to the recipients My Messages inbox
13
+ #
14
+ ebay = Ebay::Api.new
15
+ begin
16
+
17
+ message = Ebay::Types::MemberMessage.new(
18
+ :body => 'This is a test question',
19
+ :question_type => 'General',
20
+ :recipient_id => ARGV.first
21
+ )
22
+
23
+ ebay.add_member_message_aaq_to_partner(
24
+ :item_id => ARGV.last,
25
+ :member_message => message
26
+ )
27
+
28
+ puts "Successfully sent the message"
29
+ rescue Ebay::RequestError => e
30
+ e.errors.each do |error|
31
+ puts error.long_message
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ Ebay::Api.configure do |ebay|
2
+ ebay.auth_token = 'YOUR AUTH TOKEN HERE'
3
+ ebay.dev_id = 'YOUR DEVELOPER ID HERE'
4
+ ebay.app_id = 'YOUR APPLICATION ID HERE'
5
+ ebay.cert = 'YOUR CERTIFICATE HERE'
6
+
7
+ # The default environment is the production environment
8
+ # Override by setting use_sandbox to true
9
+ ebay.use_sandbox = true
10
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ ebay = Ebay::Api.new
9
+
10
+ begin
11
+ # End the item as passed in as the first argument
12
+ response = ebay.end_item(:item_id => ARGV.first)
13
+ puts "Successfully ended item #{ARGV.first}"
14
+ rescue Ebay::RequestError => e
15
+ e.errors.each do |error|
16
+ puts error.long_message
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ ebay = Ebay::Api.new
9
+
10
+ begin
11
+ # Get the eBay API usage
12
+ response = ebay.get_api_access_rules
13
+
14
+ response.api_access_rules.each do |rule|
15
+ puts "#{rule.call_name}: Hourly: #{rule.hourly_usage}; Daily: #{rule.daily_usage}"
16
+ end
17
+ rescue Ebay::RequestError => e
18
+ e.errors.each do |error|
19
+ puts error.long_message
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'ebay'
5
+ require 'config'
6
+
7
+ ebay = Ebay::Api.new
8
+
9
+ begin
10
+ response = ebay.get_attributes_xsl(:detail_level => 'ReturnAll')
11
+
12
+ # There is currently only one stylesheet, but eBay may add more in the future
13
+ file = response.xsl_files.first
14
+ puts "Downloaded version #{file.file_version}"
15
+
16
+ # Save the downloaded file
17
+ puts "Saving file to: #{file.file_name}"
18
+ File.open(file.file_name, 'w') do |f|
19
+ f.puts file.file_content
20
+ end
21
+ rescue Ebay::RequestError => e
22
+ e.errors.each do |error|
23
+ puts error.long_message
24
+ end
25
+ end
26
+
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ ebay = Ebay::Api.new
9
+
10
+ begin
11
+ # Get the eBay site details. This time we only want the SiteDetails, so
12
+ # specify that that is what we want with the option :detail_names
13
+ response = ebay.get_ebay_details(:detail_names => [ 'SiteDetails' ])
14
+ puts "eBay has #{response.site_details.size} total sites\n"
15
+ response.site_details.each do |site|
16
+ puts "#{site.site} (#{site.site_id})"
17
+ end
18
+ rescue Ebay::RequestError => e
19
+ e.errors.each do |error|
20
+ puts error.long_message
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+
7
+ # config.rb contains the authentication configuration for the user account
8
+ # config.rb also tells eBay to use the Sandbox for this call
9
+ require 'config'
10
+
11
+ # Getting the official eBay time is the Hello World application of
12
+ # the eBay API. Get the official eBay time and display it.
13
+ # The request class is the camelized method call name and can be found in
14
+ # lib/ebay/requests/get_ebay_official_time.rb
15
+ # The class returned is the camelized method call name.
16
+ # In this case the returned class is Ebay::Responses::GeteBayOfficialTime
17
+ # This file can be found at lib/ebay/responses/get_ebay_official_time.rb
18
+ ebay = Ebay::Api.new
19
+
20
+ begin
21
+ response = ebay.get_ebay_official_time
22
+ puts "The returned class is: #{response.class}"
23
+ puts "The current eBay time is: #{response.timestamp}"
24
+ # Display any request errors to the user. A RequestError is only raised when
25
+ # the request has a Failure or PartialFailure status.
26
+ rescue Ebay::RequestError => e
27
+ # Display any request errors to the user. A RequestError is only raised when
28
+ # the request has a Failure or PartialFailure status.
29
+ e.errors.each do |error|
30
+ puts error.long_message
31
+ end
32
+ end
33
+
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ # Sometimes it is better to receive the raw XML response from eBay.
9
+ # This is beneficial for calls like get_categories(:detail_level => 'ReturnAll'),
10
+ # which can return 27,000+ categories. It is usefull in a case like that
11
+ # to use an event based XML listener and process the tags as you go.
12
+ ebay = Ebay::Api.new(:format => :raw)
13
+
14
+ begin
15
+ # Get the raw XML response. This can also be done by passing in :format => :raw
16
+ # to the call you're currently making, such as:
17
+ # ebay.get_ebay_official_time(:format => :raw)
18
+ response = ebay.get_ebay_official_time
19
+
20
+ # Create a new XML document and display the XML formatted on standard output
21
+ xml = REXML::Document.new(response)
22
+ xml.write(STDOUT, 0)
23
+
24
+ rescue Ebay::RequestError => e
25
+ # Display any request errors to the user. A RequestError is only raised when
26
+ # the request has a Failure or PartialFailure status.
27
+ e.errors.each do |error|
28
+ puts error.long_message
29
+ end
30
+ end
31
+
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ ebay = Ebay::Api.new
9
+
10
+ begin
11
+ # Get the item as passed in as the first argument
12
+ response = ebay.get_item(:item_id => ARGV.first)
13
+
14
+ # Get the item, which is of the type Ebay::Types::Item
15
+ item = response.item
16
+ puts "The item number is: #{item.item_id}"
17
+ puts "The item was listed at: #{item.listing_details.start_time}"
18
+ puts "The item can be viewed at: #{item.listing_details.view_item_url}"
19
+ puts "The starting price is: #{item.listing_details.converted_start_price.format(:with_currency)}"
20
+ rescue Ebay::RequestError => e
21
+ e.errors.each do |error|
22
+ puts error.long_message
23
+ end
24
+ end
25
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ ebay = Ebay::Api.new
9
+
10
+ begin
11
+ # First get the item in question so that we can determine the
12
+ # modified times
13
+ response = ebay.get_item(:item_id => ARGV.first)
14
+ listing_end_time = response.item.listing_details.end_time
15
+
16
+ # Use a 29 day window, which is about the max allowable by eBay
17
+ time_to = listing_end_time + 29.days
18
+
19
+ response = ebay.get_item_transactions(
20
+ :item_id => ARGV.first,
21
+ :mod_time_from => listing_end_time,
22
+ :mod_time_to => time_to,
23
+ :detail_level => 'ItemReturnDescription'
24
+ )
25
+
26
+ puts "Total transactions: #{response.transactions.size}"
27
+ response.transactions.each do |t|
28
+ puts "Item Won On: #{listing_end_time}"
29
+ puts "Item Paid On: #{t.paid_time}"
30
+ puts "Item Shipped On: #{t.shipped_time}"
31
+ end
32
+ rescue Ebay::RequestError => e
33
+ e.errors.each do |error|
34
+ puts error.long_message
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ # Get the actively listed items from My eBay and sort them by TimeLeft
9
+ ebay = Ebay::Api.new
10
+
11
+ begin
12
+ response = ebay.get_my_ebay_selling(
13
+ :detail_level => 'ReturnAll',
14
+ :active_list => Ebay::Types::ItemListCustomization.new(:sort => 'TimeLeft')
15
+ )
16
+
17
+ puts "You have #{response.active_list.items.size} active listings:"
18
+ response.active_list.items.each do |item|
19
+ puts "#{item.item_id}: #{item.title}"
20
+ end
21
+ rescue Ebay::RequestError => e
22
+ e.errors.each do |error|
23
+ puts error.long_message
24
+ end
25
+ end
26
+
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ ebay = Ebay::Api.new
9
+
10
+ # Get the messages from MyMessages
11
+ begin
12
+ response = ebay.get_my_messages(:detail_level => 'ReturnHeaders')
13
+ response.messages.each do |message|
14
+ puts "Sender: #{message.sender} Subject: #{message.subject}"
15
+ end
16
+ rescue Ebay::RequestError => e
17
+ e.errors.each do |error|
18
+ puts error.long_message
19
+ end
20
+ end
21
+
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ ebay = Ebay::Api.new
9
+
10
+ begin
11
+ response = ebay.get_my_messages(:detail_level => 'ReturnSummary')
12
+
13
+ response.summary.folder_summaries.each do |folder|
14
+ puts "#{folder.folder_id}: #{folder.folder_name}"
15
+ end
16
+ rescue Ebay::RequestError => e
17
+ e.errors.each do |error|
18
+ puts error.long_message
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ $:.unshift File.dirname(__FILE__)
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'ebay'
6
+ require 'config'
7
+
8
+ scope = ARGV.first
9
+
10
+ ebay = Ebay::Api.new
11
+
12
+ begin
13
+ # Get the notificiation preferences for either the Application or User scope
14
+ response = ebay.get_notification_preferences(:preference_level => scope)
15
+
16
+ case scope
17
+ when 'Application'
18
+ prefs = response.application_delivery_preferences
19
+ puts "Url: #{prefs.application_url}"
20
+ puts "Alert enable: #{prefs.alert_enable}"
21
+ puts "App enable: #{prefs.application_enable}"
22
+ puts "Type: #{prefs.notification_payload_type}"
23
+ when 'User'
24
+ response.user_delivery_preferences.each do |pref|
25
+ puts "#{pref.event_type}: #{pref.event_enable}"
26
+ end
27
+ else
28
+ puts "Please specify 'Application' or 'User'"
29
+ end
30
+ rescue Ebay::RequestError => e
31
+ e.errors.each do |error|
32
+ puts error.long_message
33
+ end
34
+ end
35
+
36
+