Class: Minfraud::HTTPService::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/minfraud/http_service/request.rb

Overview

Request performs HTTP requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Request

Returns a new instance of Request.

Parameters:

  • params (Hash) (defaults to: {})

    Hash of parameters. Each key/value should correspond to one of the available attributes.



21
22
23
24
# File 'lib/minfraud/http_service/request.rb', line 21

def initialize(params = {})
  @middleware = params[:middleware]
  @server     = params[:server]
end

Instance Attribute Details

#middlewareProc? (readonly)

A proc containing Faraday configuration.

Returns:

  • (Proc, nil)


12
13
14
# File 'lib/minfraud/http_service/request.rb', line 12

def middleware
  @middleware
end

#serverString? (readonly)

The API endpoint.

Returns:

  • (String, nil)


17
18
19
# File 'lib/minfraud/http_service/request.rb', line 17

def server
  @server
end

Instance Method Details

#perform(params) ⇒ Farday::Response

Perform an HTTP request to the specified endpoint with given body.

Parameters:

  • params (Hash)

    Hash of parameters, including :verb, :endpoint, and :body.

Returns:

  • (Farday::Response)


32
33
34
35
# File 'lib/minfraud/http_service/request.rb', line 32

def perform(params)
  connection = Minfraud.connection
  connection.send(*params.values_at(:verb, :endpoint, :body))
end