Permalink
Browse files

Add existing code from local repo

  • Loading branch information...
1 parent d6e9326 commit bcd959331da7c24983db2acf183c3fac31970469 Cody Fauser committed Nov 19, 2006
Showing 855 changed files with 115,169 additions and 0 deletions.
View
No changes.
View
@@ -0,0 +1,20 @@
+Copyright (c) 2006 Cody Fauser
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND
+NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
0 README
No changes.
View
@@ -0,0 +1,50 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+require 'config'
+
+include Ebay
+include Ebay::Types
+
+# With no options, the default is to use the default site_id and the default
+# auth_token configured on the Api class.
+ebay = Api.new
+
+# However, another user's auth_token can be used and the site can be selected
+# at the time of creation. Ex: Canada with another user's auth token.
+# ebay = Api.new(:site_id => 2, :auth_token => 'TEST')
+
+# In this example I am simple passing in the strings 'Days_7', 'USD' and others.
+# However, there are constants defined for these code types, which can be enumerated
+# For example, CurrencyCode::CAD
+# For enumerating through the available types: CurrencyCode.each{|code| puts code}
+
+item = Item.new( :primary_category => Category.new(:category_id => 57882),
+ :title => 'Ruby eBay API Test Listing',
+ :description => 'Welcome!',
+ :location => 'Ottawa, On',
+ :start_price => Money.new(1200, 'USD'),
+ :quantity => 1,
+ :listing_duration => 'Days_7',
+ :country => 'US',
+ :currency => 'USD',
+ :payment_methods => ['VisaMC', 'PersonalCheck']
+ )
+
+begin
+ response = ebay.add_item(:item => item)
+ puts "Adding item"
+ puts "eBay time is: #{response.timestamp}"
+
+ puts "Item ID: #{response.item_id}"
+ puts "Fee summary: "
+ response.fees.select{|f| !f.fee.zero? }.each do |f|
+ puts " #{f.name}: #{f.fee.format(:with_currency)}"
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
View
@@ -0,0 +1,10 @@
+Ebay::Api.configure do |ebay|
+ ebay.auth_token = 'YOUR AUTH TOKEN HERE'
+ ebay.dev_id = 'YOUR DEVELOPER ID HERE'
+ ebay.app_id = 'YOUR APPLICATION ID HERE'
+ ebay.cert = 'YOUR CERTIFICATE HERE'
+
+ # The default environment is the production environment
+ # Override by setting use_sandbox to true
+ ebay.use_sandbox = true
+end
View
@@ -0,0 +1,18 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+begin
+ # End the item as passed in as the first argument
+ response = ebay.end_item(:item_id => ARGV.first)
+ puts "Successfully ended item #{ARGV.first}"
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
View
@@ -0,0 +1,21 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+begin
+ # Get the eBay API usage
+ response = ebay.get_api_access_rules
+
+ response.api_access_rules.each do |rule|
+ puts "#{rule.call_name}: Hourly: #{rule.hourly_usage}; Daily: #{rule.daily_usage}"
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
@@ -0,0 +1,26 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+begin
+ response = ebay.get_attributes_xsl(:detail_level => 'ReturnAll')
+
+ # There is currently only one stylesheet, but eBay may add more in the future
+ file = response.xsl_files.first
+ puts "Downloaded version #{file.file_version}"
+
+ # Save the downloaded file
+ puts "Saving file to: #{file.file_name}"
+ File.open(file.file_name, 'w') do |f|
+ f.puts file.file_content
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
+
@@ -0,0 +1,22 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+begin
+ # Get the eBay site details. This time we only want the SiteDetails, so
+ # specify that that is what we want with the option :detail_names
+ response = ebay.get_ebay_details(:detail_names => [ 'SiteDetails' ])
+ puts "eBay has #{response.site_details.size} total sites\n"
+ response.site_details.each do |site|
+ puts "#{site.site} (#{site.site_id})"
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
View
@@ -0,0 +1,33 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+
+# config.rb contains the authentication configuration for the user account
+# config.rb also tells eBay to use the Sandbox for this call
+require 'config'
+
+# Getting the official eBay time is the Hello World application of
+# the eBay API. Get the official eBay time and display it.
+# The request class is the camelized method call name and can be found in
+# lib/ebay/requests/get_ebay_official_time.rb
+# The class returned is the camelized method call name.
+# In this case the returned class is Ebay::Responses::GeteBayOfficialTime
+# This file can be found at lib/ebay/responses/get_ebay_official_time.rb
+ebay = Ebay::Api.new
+
+begin
+ response = ebay.get_ebay_official_time
+ puts "The returned class is: #{response.class}"
+ puts "The current eBay time is: #{response.timestamp}"
+ # Display any request errors to the user. A RequestError is only raised when
+ # the request has a Failure or PartialFailure status.
+rescue Ebay::RequestError => e
+ # Display any request errors to the user. A RequestError is only raised when
+ # the request has a Failure or PartialFailure status.
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
+
@@ -0,0 +1,31 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+require 'config'
+
+# Sometimes it is better to receive the raw XML response from eBay.
+# This is beneficial for calls like get_categories(:detail_level => 'ReturnAll'),
+# which can return 27,000+ categories. It is usefull in a case like that
+# to use an event based XML listener and process the tags as you go.
+ebay = Ebay::Api.new(:format => :raw)
+
+begin
+ # Get the raw XML response. This can also be done by passing in :format => :raw
+ # to the call you're currently making, such as:
+ # ebay.get_ebay_official_time(:format => :raw)
+ response = ebay.get_ebay_official_time
+
+ # Create a new XML document and display the XML formatted on standard output
+ xml = REXML::Document.new(response)
+ xml.write(STDOUT, 0)
+
+rescue Ebay::RequestError => e
+ # Display any request errors to the user. A RequestError is only raised when
+ # the request has a Failure or PartialFailure status.
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
+
View
@@ -0,0 +1,25 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+begin
+ # Get the item as passed in as the first argument
+ response = ebay.get_item(:item_id => ARGV.first)
+
+ # Get the item, which is of the type Ebay::Types::Item
+ item = response.item
+ puts "The item number is: #{item.item_id}"
+ puts "The item was listed at: #{item.listing_details.start_time}"
+ puts "The item can be viewed at: #{item.listing_details.view_item_url}"
+ puts "The starting price is: #{item.listing_details.converted_start_price.format(:with_currency)}"
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
+
@@ -0,0 +1,36 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+begin
+ # First get the item in question so that we can determine the
+ # modified times
+ response = ebay.get_item(:item_id => ARGV.first)
+ listing_end_time = response.item.listing_details.end_time
+
+ # Use a 29 day window, which is about the max allowable by eBay
+ time_to = listing_end_time + 29.days
+
+ response = ebay.get_item_transactions(
+ :item_id => ARGV.first,
+ :mod_time_from => listing_end_time,
+ :mod_time_to => time_to,
+ :detail_level => 'ItemReturnDescription'
+ )
+
+ puts "Total transactions: #{response.transactions.size}"
+ response.transactions.each do |t|
+ puts "Item Won On: #{listing_end_time}"
+ puts "Item Paid On: #{t.paid_time}"
+ puts "Item Shipped On: #{t.shipped_time}"
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
@@ -0,0 +1,26 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+require 'config'
+
+# Get the actively listed items from My eBay and sort them by TimeLeft
+ebay = Ebay::Api.new
+
+begin
+ response = ebay.get_my_ebay_selling(
+ :detail_level => 'ReturnAll',
+ :active_list => Ebay::Types::ItemListCustomization.new(:sort => 'TimeLeft')
+ )
+
+ puts "You have #{response.active_list.items.size} active listings:"
+ response.active_list.items.each do |item|
+ puts "#{item.item_id}: #{item.title}"
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
+
@@ -0,0 +1,21 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__),'..', 'lib')
+
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+# Get the messages from MyMessages
+begin
+ response = ebay.get_my_messages(:detail_level => 'ReturnHeaders')
+ response.messages.each do |message|
+ puts "Sender: #{message.sender} Subject: #{message.subject}"
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
+
@@ -0,0 +1,20 @@
+#!/usr/bin/ruby
+$:.unshift File.dirname(__FILE__)
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+
+require 'ebay'
+require 'config'
+
+ebay = Ebay::Api.new
+
+begin
+ response = ebay.get_my_messages(:detail_level => 'ReturnSummary')
+
+ response.summary.folder_summaries.each do |folder|
+ puts "#{folder.folder_id}: #{folder.folder_name}"
+ end
+rescue Ebay::RequestError => e
+ e.errors.each do |error|
+ puts error.long_message
+ end
+end
Oops, something went wrong.

0 comments on commit bcd9593

Please sign in to comment.