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_item_from_selling_manager_template, #add_items, #add_member_message_aaq_to_partner, #add_member_message_rtq, #add_member_messages_aaq_to_bidder, #add_order, #add_second_chance_item, #add_selling_manager_inventory_folder, #add_selling_manager_product, #add_selling_manager_template, #add_to_item_description, #add_to_watch_list, #add_transaction_confirmation_item, #complete_sale, #confirm_identity, #delete_my_messages, #delete_selling_manager_inventory_folder, #delete_selling_manager_item_automation_rule, #delete_selling_manager_product, #delete_selling_manager_template, #delete_selling_manager_template_automation_rule, #end_item, #end_items, #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_categories, #get_category2_cs, #get_category_features, #get_category_listings, #get_category_mappings, #get_category_specifics, #get_challenge_token, #get_charities, #get_client_alerts_auth_token, #get_contextual_keywords, #get_cross_promotions, #get_description_templates, #get_dispute, #get_ebay_details, #get_ebay_official_time, #get_feedback, #get_high_bidders, #get_item, #get_item_recommendations, #get_item_shipping, #get_item_transactions, #get_items_awaiting_feedback, #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_search_results, #get_seller_dashboard, #get_seller_events, #get_seller_list, #get_seller_payments, #get_seller_transactions, #get_selling_manager_alerts, #get_selling_manager_email_log, #get_selling_manager_inventory, #get_selling_manager_inventory_folder, #get_selling_manager_item_automation_rule, #get_selling_manager_sale_record, #get_selling_manager_sold_listings, #get_selling_manager_template_automation_rule, #get_selling_manager_templates, #get_session_id, #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_token_status, #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, #move_selling_manager_inventory_folder, #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_inventory_status, #revise_item, #revise_my_messages, #revise_my_messages_folders, #revise_selling_manager_inventory_folder, #revise_selling_manager_product, #revise_selling_manager_sale_record, #revise_selling_manager_template, #revoke_token, #save_item_to_selling_manager_template, #seller_reverse_dispute, #send_invoice, #set_message_preferences, #set_notification_preferences, #set_picture_manager_details, #set_promotional_sale, #set_promotional_sale_listings, #set_selling_manager_feedback_options, #set_selling_manager_item_automation_rule, #set_selling_manager_template_automation_rule, #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, #upload_site_hosted_pictures, #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')


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

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.



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

def auth_token
  @auth_token
end

#site_idObject (readonly)

Returns the value of attribute site_id.



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

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



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

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



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

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)


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

def self.using_production?
  !using_sandbox?
end

.using_sandbox?Boolean

Are we currently routing requests to the eBay sandbox URL?

Returns:

  • (Boolean)


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

def self.using_sandbox?
  use_sandbox
end

Instance Method Details

#app_idObject



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

def app_id
  self.class.app_id
end

#certObject



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

def cert
  self.class.cert
end

#schema_versionObject

The schema version the API client is currently using



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

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

#service_uriObject



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

def service_uri
  self.class.service_uri
end