connection.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. class Sequencer
  2. class Unit
  3. module Exchange
  4. class Connection < Sequencer::Unit::Base
  5. uses :ews_config
  6. provides :ews_connection
  7. def process
  8. # check if EWS connection is already given (sub sequence)
  9. return if state.provided?(:ews_connection)
  10. state.provide(:ews_connection) do
  11. Viewpoint::EWSClient.new(
  12. config[:endpoint],
  13. config[:user],
  14. config[:password],
  15. additional_opts
  16. )
  17. end
  18. end
  19. private
  20. def config
  21. @config ||= begin
  22. ews_config || ::Import::Exchange.config
  23. end
  24. end
  25. def additional_opts
  26. @additional_opts ||= begin
  27. http_opts
  28. end
  29. end
  30. def http_opts
  31. return {} if config[:disable_ssl_verify].blank?
  32. {
  33. http_opts: {
  34. ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
  35. }
  36. }
  37. end
  38. end
  39. end
  40. end
  41. end