Class: Comgate::ApiCaller

Inherits:
BaseService show all
Defined in:
lib/comgate/api_caller.rb

Defined Under Namespace

Classes: HttpResponseStubStruct

Constant Summary collapse

KNOWN_CONNECTION_ERRORS =
[
  Timeout::Error,
  Errno::EINVAL,
  Errno::ECONNRESET,
  EOFError,
  SocketError,
  Net::ReadTimeout,
  Net::HTTPBadResponse,
  Net::HTTPHeaderSyntaxError,
  Net::ProtocolError
].freeze

Instance Attribute Summary collapse

Attributes inherited from BaseService

#errors, #result

Instance Method Summary collapse

Methods inherited from BaseService

call, #call, #failure?, #success?

Constructor Details

#initialize(url:, payload:, test_call: false, proxy_uri: nil) ⇒ ApiCaller

Returns a new instance of ApiCaller.



23
24
25
26
27
28
29
# File 'lib/comgate/api_caller.rb', line 23

def initialize(url:, payload:, test_call: false, proxy_uri: nil)
  super()
  @url = url
  @payload = payload
  @payload.merge!(test: "true") if test_call
  @proxy_uri = proxy_uri
end

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload.



21
22
23
# File 'lib/comgate/api_caller.rb', line 21

def payload
  @payload
end

#urlObject (readonly)

Returns the value of attribute url.



21
22
23
# File 'lib/comgate/api_caller.rb', line 21

def url
  @url
end

Instance Method Details

#build_resultObject



31
32
33
34
# File 'lib/comgate/api_caller.rb', line 31

def build_result
  call_api
  process_response
end