Class: Veryfi::Request

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

Overview

Low-level HTTP layer used by every API class. You typically don't need to interact with this directly — go through Client instead.

Custom Faraday configuration (adapter, retries, logging, persistent connections, …) can be supplied via the faraday: block when constructing the client. The block receives the Faraday::Connection before it's frozen, so you can attach any middleware you want.

Constant Summary collapse

VERBS_WITH_BODIES =
%i[post put].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, username, api_key, base_url, api_version, timeout, faraday_block = nil) ⇒ Request

Returns a new instance of Request.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/veryfi/request.rb', line 21

def initialize(
  client_id,
  client_secret,
  username,
  api_key,
  base_url,
  api_version,
  timeout,
  faraday_block = nil
)
  @client_id = client_id
  @client_secret = client_secret
  @username = username
  @api_key = api_key
  @base_url = base_url
  @api_version = api_version
  @timeout = timeout
  @faraday_block = faraday_block
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def api_key
  @api_key
end

#api_versionObject (readonly)

Returns the value of attribute api_version.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def api_version
  @api_version
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def base_url
  @base_url
end

#client_idObject (readonly)

Returns the value of attribute client_id.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def client_secret
  @client_secret
end

#faraday_blockObject (readonly)

Returns the value of attribute faraday_block.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def faraday_block
  @faraday_block
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def timeout
  @timeout
end

#usernameObject (readonly)

Returns the value of attribute username.



16
17
18
# File 'lib/veryfi/request.rb', line 16

def username
  @username
end

Instance Method Details

#api_urlObject



57
58
59
# File 'lib/veryfi/request.rb', line 57

def api_url
  @_api_url ||= [base_url, api_version].join
end

#delete(path) ⇒ Object



53
54
55
# File 'lib/veryfi/request.rb', line 53

def delete(path)
  make_request(:delete, path)
end

#get(path, params = {}) ⇒ Object



41
42
43
# File 'lib/veryfi/request.rb', line 41

def get(path, params = {})
  make_request(:get, path, params)
end

#post(path, params) ⇒ Object



49
50
51
# File 'lib/veryfi/request.rb', line 49

def post(path, params)
  make_request(:post, path, params)
end

#put(path, params) ⇒ Object



45
46
47
# File 'lib/veryfi/request.rb', line 45

def put(path, params)
  make_request(:put, path, params)
end