Class: Zm::Client::SoapBaseConnector
- Inherits:
-
Object
- Object
- Zm::Client::SoapBaseConnector
- Defined in:
- lib/zm/client/connector/soap_base.rb
Direct Known Subclasses
Constant Summary collapse
- BASESPACE =
'urn:zimbra'- HTTP_HEADERS =
{ 'Content-Type' => 'application/json; charset=utf-8', 'User-Agent' => 'ZmRubyClient' }.freeze
Instance Attribute Summary collapse
-
#cache ⇒ Object
writeonly
Sets the attribute cache.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#logger ⇒ Object
writeonly
Sets the attribute logger.
-
#timeout ⇒ Object
writeonly
Sets the attribute timeout.
Instance Method Summary collapse
- #http_client! ⇒ Object
-
#initialize(url, soap_path) ⇒ SoapBaseConnector
constructor
A new instance of SoapBaseConnector.
- #invoke(soap_element, error_handler = SoapError) ⇒ Object
- #target_invoke(soap_element, target_id, error_handler = SoapError) ⇒ Object
- #verbose! ⇒ Object
Constructor Details
#initialize(url, soap_path) ⇒ SoapBaseConnector
Returns a new instance of SoapBaseConnector.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zm/client/connector/soap_base.rb', line 20 def initialize(url, soap_path) @verbose = false @timeout = 300 @ssl_options = { verify: false, verify_hostname: false, verify_mode: OpenSSL::SSL::VERIFY_NONE } @url = url @soap_path = soap_path @context = SoapContext.new end |
Instance Attribute Details
#cache=(value) ⇒ Object (writeonly)
Sets the attribute cache
18 19 20 |
# File 'lib/zm/client/connector/soap_base.rb', line 18 def cache=(value) @cache = value end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
17 18 19 |
# File 'lib/zm/client/connector/soap_base.rb', line 17 def context @context end |
#logger=(value) ⇒ Object (writeonly)
Sets the attribute logger
18 19 20 |
# File 'lib/zm/client/connector/soap_base.rb', line 18 def logger=(value) @logger = value end |
#timeout=(value) ⇒ Object (writeonly)
Sets the attribute timeout
18 19 20 |
# File 'lib/zm/client/connector/soap_base.rb', line 18 def timeout=(value) @timeout = value end |
Instance Method Details
#http_client! ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zm/client/connector/soap_base.rb', line 51 def http_client! @http_client = Faraday.new( url: @url, headers: HTTP_HEADERS, request: { timeout: @timeout }, ssl: @ssl_options ) do |faraday| faraday.request :json faraday.response :logger, nil, { headers: true, bodies: true, errors: true } if @verbose end end |
#invoke(soap_element, error_handler = SoapError) ⇒ Object
40 41 42 |
# File 'lib/zm/client/connector/soap_base.rb', line 40 def invoke(soap_element, error_handler = SoapError) do_request(envelope(soap_element), error_handler)[:Body] end |
#target_invoke(soap_element, target_id, error_handler = SoapError) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/zm/client/connector/soap_base.rb', line 44 def target_invoke(soap_element, target_id, error_handler = SoapError) @context.target_server(target_id) resp = invoke(soap_element, error_handler) @context.target_server(nil) resp end |
#verbose! ⇒ Object
36 37 38 |
# File 'lib/zm/client/connector/soap_base.rb', line 36 def verbose! @verbose = true end |