Class: Remitmd::HttpTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/remitmd/http.rb

Overview

HTTP transport layer. Signs each request with EIP-712 auth headers and retries transient failures with exponential backoff.

Constant Summary collapse

MAX_RETRIES =
3
BASE_DELAY =

seconds

0.5
RETRY_CODES =
[429, 500, 502, 503, 504].freeze

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, signer:, chain_id:, router_address: "") ⇒ HttpTransport

Returns a new instance of HttpTransport.



25
26
27
28
29
30
31
# File 'lib/remitmd/http.rb', line 25

def initialize(base_url:, signer:, chain_id:, router_address: "")
  @signer         = signer
  @chain_id       = chain_id
  @router_address = router_address.to_s
  @uri            = URI.parse(base_url)
  @http           = build_http(@uri)
end

Instance Method Details

#delete(path) ⇒ Object



45
46
47
# File 'lib/remitmd/http.rb', line 45

def delete(path)
  request(:delete, path, nil)
end

#get(path) ⇒ Object



33
34
35
# File 'lib/remitmd/http.rb', line 33

def get(path)
  request(:get, path, nil)
end

#patch(path, body = nil) ⇒ Object



41
42
43
# File 'lib/remitmd/http.rb', line 41

def patch(path, body = nil)
  request(:patch, path, body)
end

#post(path, body = nil) ⇒ Object



37
38
39
# File 'lib/remitmd/http.rb', line 37

def post(path, body = nil)
  request(:post, path, body)
end