Class: MagentoClient
- Inherits:
-
Object
- Object
- MagentoClient
- Includes:
- Handshake
- Defined in:
- lib/magento_client.rb,
lib/magento_client/version.rb,
lib/magento_client/handshake.rb
Defined Under Namespace
Modules: Handshake
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #access_token ⇒ Object
- #consumer ⇒ Object
- #get(params) ⇒ Object
-
#initialize(config = {}) ⇒ MagentoClient
constructor
A new instance of MagentoClient.
- #request_token ⇒ Object
- #reset ⇒ Object
Methods included from Handshake
Constructor Details
#initialize(config = {}) ⇒ MagentoClient
Returns a new instance of MagentoClient.
13 14 15 |
# File 'lib/magento_client.rb', line 13 def initialize(config = {}) @config = OpenStruct.new(config) end |
Instance Method Details
#access_token ⇒ Object
21 22 23 24 25 26 |
# File 'lib/magento_client.rb', line 21 def access_token return @access_token if @access_token code = get_verifier_code @access_token = request_token.get_access_token(:oauth_verifier => code) end |
#consumer ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/magento_client.rb', line 32 def consumer @consumer ||= OAuth::Consumer.new(@config.key, @config.secret, :site => @config.url, :request_token_path => "/index.php/oauth/initiate", :authorize_path => "/index.php/admin/oauth_authorize", :access_token_path => "/index.php/oauth/token", :http_method => :get ) end |
#get(params) ⇒ Object
17 18 19 |
# File 'lib/magento_client.rb', line 17 def get(params) MultiJson.load(access_token.get(params).body) end |
#request_token ⇒ Object
28 29 30 |
# File 'lib/magento_client.rb', line 28 def request_token @request_token ||= consumer.get_request_token end |
#reset ⇒ Object
42 43 44 |
# File 'lib/magento_client.rb', line 42 def reset @consumer = @request_token = nil end |