Class: Magento::XmlApi
- Inherits:
-
Object
- Object
- Magento::XmlApi
- Defined in:
- lib/magento/xml_api.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_user ⇒ Object
Returns the value of attribute api_user.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #call(method, *arguments) ⇒ Object
-
#initialize(base_url, api_user, api_key, options = {}) ⇒ XmlApi
constructor
A new instance of XmlApi.
Constructor Details
#initialize(base_url, api_user, api_key, options = {}) ⇒ XmlApi
Returns a new instance of XmlApi.
25 26 27 28 29 30 31 32 |
# File 'lib/magento/xml_api.rb', line 25 def initialize(base_url, api_user, api_key, ={}) @url = "#{base_url}/api/xmlrpc/" @api_user = api_user @api_key = api_key @timeout = [:timeout] || 60 @proxy = [:proxy] || nil @debug = [:debug] || false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/magento/xml_api.rb', line 82 def method_missing(method, *args, &block) # convert the method name to an XMLRPC action name e.g. "sales_order.list" parts = method.to_s.snakecase.split('_') action = "#{parts[0..-2].join('_')}.#{parts.last}" if parts.size > 1 if action call action, *args, &block else super end end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
23 24 25 |
# File 'lib/magento/xml_api.rb', line 23 def api_key @api_key end |
#api_user ⇒ Object
Returns the value of attribute api_user.
23 24 25 |
# File 'lib/magento/xml_api.rb', line 23 def api_user @api_user end |
#url ⇒ Object
Returns the value of attribute url.
23 24 25 |
# File 'lib/magento/xml_api.rb', line 23 def url @url end |
Instance Method Details
#call(method, *arguments) ⇒ Object
34 35 36 |
# File 'lib/magento/xml_api.rb', line 34 def call(method, *arguments) request('call', session_id, method, arguments) end |