Class: Zm::Client::SoapBaseConnector
- Inherits:
-
Object
- Object
- Zm::Client::SoapBaseConnector
- Includes:
- ZmLogger
- 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
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Attributes included from ZmLogger
#logger, #logger_file_path, #logger_level
Instance Method Summary collapse
- #http_client! ⇒ Object
-
#initialize(scheme, host, port, 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
Methods included from ZmLogger
Constructor Details
#initialize(scheme, host, port, soap_path) ⇒ SoapBaseConnector
Returns a new instance of SoapBaseConnector.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zm/client/connector/soap_base.rb', line 22 def initialize(scheme, host, port, soap_path) @verbose = false @timeout = 300 @ssl_options = { verify: false, verify_hostname: false, verify_mode: OpenSSL::SSL::VERIFY_NONE } @soap_path = soap_path @uri = URI::HTTP.new(scheme, nil, host, port, nil, nil, nil, nil, nil) @context = SoapContext.new end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
20 21 22 |
# File 'lib/zm/client/connector/soap_base.rb', line 20 def context @context end |
Instance Method Details
#http_client! ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/zm/client/connector/soap_base.rb', line 52 def http_client! @http_client = Faraday.new( url: @uri.to_s, 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
41 42 43 |
# File 'lib/zm/client/connector/soap_base.rb', line 41 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
45 46 47 48 49 50 |
# File 'lib/zm/client/connector/soap_base.rb', line 45 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
37 38 39 |
# File 'lib/zm/client/connector/soap_base.rb', line 37 def verbose! @verbose = true end |