Class: Ebay::Api

Inherits:
Object
  • Object
show all
Includes:
ApiMethods, Inflections
Defined in:
lib/ebay/api.rb

Overview

Overview

Api is the main proxy class responsible for instantiating and invoking the correct Ebay::Requests object for the method called. All of the available method calls are included from the module Ebay::ApiMethods

ebay = Ebay::Api.new
response = ebay.get_ebay_official_time
puts response.timestamp # => 2006-08-13T21:28:39.515Z

All Ebay API calls have a corresponding request and response object. In the example above the request objects is Ebay::Requests::GeteBayOfficialTime and the response object is Ebay::Responses::GeteBayOfficialTime

Official Input / Output Reference

The official input / output reference provided by eBay is a good way to get familiar with the API calls.

developer.ebay.com/DevZone/XML/docs/Reference/eBay/index.html

Constant Summary collapse

XmlNs =
'urn:ebay:apis:eBLBaseComponents'

Constants included from Inflections

Inflections::DOWNCASE_TOKENS, Inflections::NAME_MAPPINGS, Inflections::UPCASE_TOKENS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApiMethods

#add_dispute, #add_dispute_response, #add_item, #add_live_auction_item, #add_member_message_aaq_to_partner, #add_member_message_rtq, #add_member_messages_aaq_to_bidder, #add_order, #add_second_chance_item, #add_to_item_description, #add_to_watch_list, #add_transaction_confirmation_item, #approve_live_auction_bidders, #complete_sale, #delete_my_messages, #end_item, #fetch_token, #get_account, #get_ad_format_leads, #get_all_bidders, #get_api_access_rules, #get_attributes_cs, #get_attributes_xsl, #get_best_offers, #get_bidder_list, #get_cart, #get_categories, #get_category2_cs, #get_category2_finance_offer, #get_category_features, #get_category_listings, #get_category_mappings, #get_challenge_token, #get_charities, #get_contextual_keywords, #get_cross_promotions, #get_description_templates, #get_dispute, #get_ebay_details, #get_ebay_official_time, #get_feedback, #get_finance_offers, #get_high_bidders, #get_item, #get_item_recommendations, #get_item_shipping, #get_item_transactions, #get_items_awaiting_feedback, #get_live_auction_bidders, #get_live_auction_catalog_details, #get_member_messages, #get_message_preferences, #get_my_ebay_buying, #get_my_ebay_reminders, #get_my_ebay_selling, #get_my_messages, #get_notification_preferences, #get_notifications_usage, #get_order_transactions, #get_orders, #get_picture_manager_details, #get_picture_manager_options, #get_popular_keywords, #get_product_family_members, #get_product_finder, #get_product_finder_xsl, #get_product_search_page, #get_product_search_results, #get_product_selling_pages, #get_products, #get_promotion_rules, #get_promotional_sale_details, #get_return_url, #get_ru_name, #get_search_results, #get_search_results_express, #get_seller_events, #get_seller_list, #get_seller_payments, #get_seller_transactions, #get_shipping_discount_profiles, #get_store, #get_store_category_update_status, #get_store_custom_page, #get_store_options, #get_store_preferences, #get_suggested_categories, #get_tax_table, #get_user, #get_user_contact_details, #get_user_disputes, #get_user_preferences, #get_vero_reason_code_details, #get_vero_report_status, #get_want_it_now_post, #get_want_it_now_search_results, #issue_refund, #leave_feedback, #place_offer, #relist_item, #remove_from_watch_list, #respond_to_best_offer, #respond_to_feedback, #respond_to_want_it_now_post, #revise_checkout_status, #revise_item, #revise_live_auction_item, #revise_my_messages, #revise_my_messages_folders, #seller_reverse_dispute, #send_invoice, #set_cart, #set_message_preferences, #set_notification_preferences, #set_picture_manager_details, #set_promotion_rules, #set_promotional_sale, #set_promotional_sale_listings, #set_return_url, #set_shipping_discount_profiles, #set_store, #set_store_categories, #set_store_custom_page, #set_store_preferences, #set_tax_table, #set_user_notes, #set_user_preferences, #validate_challenge_input, #validate_test_user_registration, #verify_add_item, #verify_add_second_chance_item, #vero_report_items

Methods included from Inflections

#downcase_first_character, #ebay_camelize, #ebay_underscore, #underscore, #upcase_first_character

Constructor Details

#initialize(options = {}) ⇒ Api

With no options, the default is to use the default site_id and the default auth_token configured on the Api class.

ebay = 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(Site 2) with another user’s auth token.

ebay = Ebay::Api.new(:site_id => 2, :auth_token => 'TEST')


108
109
110
111
112
# File 'lib/ebay/api.rb', line 108

def initialize(options = {})
  @format = options[:format] || :object
  @auth_token = options[:auth_token] || self.class.auth_token
  @site_id = options[:site_id] || self.class.site_id
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



43
44
45
# File 'lib/ebay/api.rb', line 43

def auth_token
  @auth_token
end

#site_idObject (readonly)

Returns the value of attribute site_id.



43
44
45
# File 'lib/ebay/api.rb', line 43

def site_id
  @site_id
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Simply yields the Ebay::Api class itself. This makes configuration a bit nicer looking:

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

Yields:

  • (_self)

Yield Parameters:

  • _self (Ebay::Api)

    the object that the method was called on



80
81
82
# File 'lib/ebay/api.rb', line 80

def self.configure
  yield self if block_given?
end

.service_uriObject

The URI that all requests are sent to. This depends on the current environment the Api is configured to use and will either be the Api#sandbox_url or the Api#production_url



54
55
56
# File 'lib/ebay/api.rb', line 54

def self.service_uri
  URI.parse(using_sandbox? ? sandbox_url : production_url)
end

.using_production?Boolean

Are we currently routing requests to the eBay production URL?

Returns:

  • (Boolean)


64
65
66
# File 'lib/ebay/api.rb', line 64

def self.using_production?
  !using_sandbox?
end

.using_sandbox?Boolean

Are we currently routing requests to the eBay sandbox URL?

Returns:

  • (Boolean)


59
60
61
# File 'lib/ebay/api.rb', line 59

def self.using_sandbox?
  use_sandbox
end

Instance Method Details

#app_idObject



93
94
95
# File 'lib/ebay/api.rb', line 93

def app_id
  self.class.app_id
end

#certObject



97
98
99
# File 'lib/ebay/api.rb', line 97

def cert
  self.class.cert
end

#schema_versionObject

The schema version the API client is currently using



85
86
87
# File 'lib/ebay/api.rb', line 85

def schema_version
  Ebay::Schema::VERSION.to_s
end

#service_uriObject



89
90
91
# File 'lib/ebay/api.rb', line 89

def service_uri
  self.class.service_uri
end