Class: MVM::Client
- Inherits:
-
Object
- Object
- MVM::Client
- Defined in:
- lib/mvm/client.rb
Overview
HTTP client for MVM services.
Handles HTTP communication with MVM services including:
-
Bridge service
-
NFT service
-
Registry service
-
Scan service
Features
-
Automatic JSON encoding/decoding
-
Request retry on failures
-
Error handling with exceptions
-
Debug logging
Usage
client = MVM::Client.new('bridge.mvm.dev')
response = client.get('/info')
response = client.post('/users', public_key: '0x...')
Constant Summary collapse
- SERVER_SCHEME =
The HTTPS scheme for all MVM requests.
'https'
Instance Attribute Summary collapse
-
#host ⇒ String
readonly
The service host.
Instance Method Summary collapse
-
#get(path) ⇒ Hash
Performs a GET request.
-
#initialize(host) ⇒ Client
constructor
Initializes a new MVM Client.
-
#post(path) ⇒ Hash
Performs a POST request.
Constructor Details
#initialize(host) ⇒ Client
Initializes a new MVM Client.
Sets up HTTP connection with:
-
JSON request/response handling
-
Automatic retry on failures
-
Error raising on HTTP errors
-
Debug logging
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/mvm/client.rb', line 49 def initialize(host) @host = host @conn = Faraday.new(url: "#{SERVER_SCHEME}://#{host}") do |f| f.request :json f.request :retry f.response :raise_error f.response :logger f.response :json end end |
Instance Attribute Details
#host ⇒ String (readonly)
Returns the service host.
33 34 35 |
# File 'lib/mvm/client.rb', line 33 def host @host end |
Instance Method Details
#get(path) ⇒ Hash
Performs a GET request.
70 71 72 |
# File 'lib/mvm/client.rb', line 70 def get(path, **) @conn.get(path, **).body end |
#post(path) ⇒ Hash
Performs a POST request.
84 85 86 |
# File 'lib/mvm/client.rb', line 84 def post(path, **) @conn.post(path, **).body end |