Class: VertexClient::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/vertex_client/connection.rb

Constant Summary collapse

VERTEX_NAMESPACE =
'urn:vertexinc:o-series:tps:7:0'.freeze
ERROR_MESSAGE =
'The Vertex API returned an error or is unavailable'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, resource_key = nil) ⇒ Connection

Returns a new instance of Connection.



7
8
9
10
# File 'lib/vertex_client/connection.rb', line 7

def initialize(endpoint, resource_key=nil)
  @endpoint = endpoint
  @resource_key = resource_key
end

Instance Method Details

#clientObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vertex_client/connection.rb', line 21

def client
  @client ||= Savon.client do |globals|
    globals.endpoint clean_endpoint
    globals.namespace VERTEX_NAMESPACE
    globals.convert_request_keys_to :camelcase
    globals.env_namespace :soapenv
    globals.namespace_identifier :urn
    globals.open_timeout open_timeout if open_timeout.present?
    globals.read_timeout read_timeout if read_timeout.present?
  end
end

#request(payload) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/vertex_client/connection.rb', line 12

def request(payload)
  call_with_circuit_if_available do
    client.call(
      :vertex_envelope,
      message: shell_with_auth.merge(payload)
    )
  end
end