Class: AutotaskApi::Client

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

Constant Summary collapse

NAMESPACE =
'http://autotask.net/ATWS/v1_5/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|@config| ... } ⇒ Client

Returns a new instance of Client.

Yields:



17
18
19
20
# File 'lib/autotask_api/client.rb', line 17

def initialize
  @config = AutotaskApi.config
  yield @config if block_given?
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



15
16
17
# File 'lib/autotask_api/client.rb', line 15

def config
  @config
end

Instance Method Details

#call(operation, message = {}) ⇒ Object



32
33
34
# File 'lib/autotask_api/client.rb', line 32

def call(operation, message = {})
  savon_client.call(operation, message: message, attributes: { xmlns: NAMESPACE })
end

#savon_clientObject



22
23
24
25
26
27
28
29
30
# File 'lib/autotask_api/client.rb', line 22

def savon_client
  @savon_client ||= Savon.client(
      wsdl: config.wsdl,
      logger: Rails.logger,
      log_level: :debug,
      log: config.debug,
      basic_auth: [config.username, config.password]
  )
end