Class: AutotaskApi::Client
- Inherits:
-
Object
- Object
- AutotaskApi::Client
- Defined in:
- lib/autotask_api/client.rb
Constant Summary collapse
- NAMESPACE =
'http://autotask.net/ATWS/v1_6/'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(operation, message = {}) ⇒ Object
-
#initialize {|@config| ... } ⇒ Client
constructor
A new instance of Client.
- #savon_client ⇒ Object
- #soap_header ⇒ Object
Constructor Details
#initialize {|@config| ... } ⇒ Client
Returns a new instance of Client.
16 17 18 19 |
# File 'lib/autotask_api/client.rb', line 16 def initialize @config = AutotaskApi.config yield @config if block_given? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/autotask_api/client.rb', line 14 def config @config end |
Instance Method Details
#call(operation, message = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/autotask_api/client.rb', line 32 def call(operation, = {}) savon_client.call( operation, message: , attributes: { xmlns: NAMESPACE } ) end |
#savon_client ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/autotask_api/client.rb', line 21 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], soap_header: soap_header ) end |
#soap_header ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/autotask_api/client.rb', line 40 def soap_header return nil unless config.integration_code xml = Nokogiri::XML::Builder.new do |xml| xml.AutotaskIntegrations xmlns: NAMESPACE do xml.IntegrationCode config.integration_code end end xml.doc.root.to_s end |