Sha256: 6d6e74d171b04f4a4c2aa10072e8a142de56c831e1e138d49746120382d29ce0

Contents?: true

Size: 717 Bytes

Versions: 3

Compression:

Stored size: 717 Bytes

Contents

module Magento
  class Connection 
    attr_accessor :client, :config, :logger
    def initialize(config = {})
      @logger ||= Logger.new(STDOUT)
      @config = config
      self
    end
    
    def connect
      @client = XMLRPC::Client.new(config[:host], config[:path], config[:port])
      @session = @client.call("login", config[:username], config[:api_key])
    end
    
    def call(method = nil, *args)
      @logger.debug "call: #{method}, #{args.inspect}"
      connect
      @client.call("call", @session, method, args)
    rescue XMLRPC::FaultException => e
      @logger.debug "exception: #{e.faultCode} -> #{e.faultString}"
      raise ApiError, "#{e.faultCode} -> #{e.faultString}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
magentor-0.2.14 lib/magento/connection.rb
magentor-0.2.13 lib/magento/connection.rb
magentor-0.2.12 lib/magento/connection.rb