Class: Dialers::Caller

Inherits:
Object
  • Object
show all
Defined in:
lib/dialers/caller.rb

Constant Summary collapse

IDEMPOTENT_AND_SAFE_METHODS =
[:get, :head, :options]
MAX_RETRIES =
5

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.setup_api(*args) { ... } ⇒ Faraday::Connection

Setups a connection using Faraday.

Parameters:

  • Arguments (Array)

    to pass to the faraday connection.

Yields:

  • A block to pass to the faraday connection

Returns:

  • (Faraday::Connection)

    a connection


13
14
15
16
# File 'lib/dialers/caller.rb', line 13

def setup_api(*args, &block)
  api = Faraday.new(*args) { |faraday| block.call(faraday) }
  const_set "API", api
end

.short_circuitsShortCircuitsCollection

Returns a collection of short circuits that can stop the process.

Returns:


19
20
21
# File 'lib/dialers/caller.rb', line 19

def short_circuits
  @short_circuits ||= Dialers::ShortCircuitsCollection.new
end

Instance Method Details

#deleteTransformable

Make a delete request.

Parameters:

  • url (String)

    The path for the request.

  • params (Hash)

    The query params to attach to the url.

  • headers (Hash)

    The headers.

Returns:


72
# File 'lib/dialers/caller.rb', line 72

query_holder_request_method :delete

#getTransformable

Make a get request.

Parameters:

  • url (String)

    The path for the request.

  • params (Hash)

    The query params to attach to the url.

  • headers (Hash)

    The headers.

Returns:


70
# File 'lib/dialers/caller.rb', line 70

query_holder_request_method :get

#headTransformable

Make a head request.

Parameters:

  • url (String)

    The path for the request.

  • params (Hash)

    The query params to attach to the url.

  • headers (Hash)

    The headers.

Returns:


71
# File 'lib/dialers/caller.rb', line 71

query_holder_request_method :head

#optionsTransformable

Make a options request.

Parameters:

  • url (String)

    The path for the request.

  • params (Hash)

    The query params to attach to the url.

  • headers (Hash)

    The headers.

Returns:


73
# File 'lib/dialers/caller.rb', line 73

query_holder_request_method :options

#patchTransformable

Make a patch request.

Parameters:

  • url (String)

    The path for the request.

  • payload (Hash)

    The request body.

  • headers (Hash)

    The headers.

Returns:


76
# File 'lib/dialers/caller.rb', line 76

body_holder_request_method :patch

#postTransformable

Make a post request.

Parameters:

  • url (String)

    The path for the request.

  • payload (Hash)

    The request body.

  • headers (Hash)

    The headers.

Returns:


74
# File 'lib/dialers/caller.rb', line 74

body_holder_request_method :post

#putTransformable

Make a put request.

Parameters:

  • url (String)

    The path for the request.

  • payload (Hash)

    The request body.

  • headers (Hash)

    The headers.

Returns:


75
# File 'lib/dialers/caller.rb', line 75

body_holder_request_method :put