Class: YSM::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ysm4r/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version = nil, options = {}) ⇒ Client

Returns a new instance of Client.



50
51
52
53
54
55
# File 'lib/ysm4r/client.rb', line 50

def initialize(version=nil, options={})
    @config = Config.new(options)
    @headers = @config.makeHeaders
    @version = (version || Service.getVersions.sort.last)
    prepareDrivers
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ysm4r/client.rb', line 57

def method_missing(m, *args)
    methodName = m.id2name
    requestName = YSM::fix_case_up(methodName) # upper first character

    if driver = @methodMap[methodName]
        servicename = driver.class.name.split("::").last
        #args.map! {|a| a.to_s}
        req = eval("YSM::#{servicename}::#{requestName}").new(*args)
        return driver.method(methodName).call(req).out
    else
        raise(SOAP::MultiService::UnknownAPICall,
          "Unknown API Call: #{requestName}", caller)
    end

    # Handle YSM Application-level error
    rescue SOAP::FaultError => fault
        raise(SOAP::MultiService::ApiError.new(fault),
          "#{methodName} Call Failed: #{fault.faultstring.to_s}", caller)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



47
48
49
# File 'lib/ysm4r/client.rb', line 47

def config
  @config
end

#driversObject (readonly)

Returns the value of attribute drivers.



47
48
49
# File 'lib/ysm4r/client.rb', line 47

def drivers
  @drivers
end

#versionObject (readonly)

Returns the value of attribute version.



47
48
49
# File 'lib/ysm4r/client.rb', line 47

def version
  @version
end