Class: Magenthor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/magenthor/base.rb

Direct Known Subclasses

Catalog, Customer, Product

Constant Summary collapse

@@client =
nil
@@session_id =
nil
@@api_user =
nil
@@api_key =
nil

Class Method Summary collapse

Class Method Details

.setup(params) ⇒ Magenthor::Base

Initialize the constants that will be used to make the connection to Magento

Parameters:

  • params (Hash)

    contains the paramters needed for connection

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/magenthor/base.rb', line 15

def self.setup params
    if params.class != Hash
        puts "Parameters must be in an Hash."
        return false
    end

    if !params.key? :host or !params.key? :api_user or !params.key? :api_key
        puts "Mandatory parameter missing. Check if :host, :api_user and :api_key are there."
        return false
    end
    
    @@api_user = params[:api_user]
    @@api_key = params[:api_key]
    url = "http://#{params[:host]}:#{params[:port]}/api/xmlrpc"
    
    @@client = XMLRPC::Client.new2(url)
    @@client.http_header_extra = { "accept-encoding" => "identity" }

    return true
end