class MagentoClient

Constants

VERSION

Public Class Methods

new(config = {}) click to toggle source
# File lib/magento_client.rb, line 13
def initialize(config = {})
  @config = OpenStruct.new(config)
end

Public Instance Methods

access_token() click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# File lib/magento_client.rb, line 17
def get(params)
  MultiJson.load(access_token.get(params).body)
end
request_token() click to toggle source
# File lib/magento_client.rb, line 28
def request_token
  @request_token ||= consumer.get_request_token
end
reset() click to toggle source
# File lib/magento_client.rb, line 42
def reset
  @consumer = @request_token = nil
end