Class: MVM::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mvm/client.rb

Constant Summary collapse

SERVER_SCHEME =
'https'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
# File 'lib/mvm/client.rb', line 9

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

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/mvm/client.rb', line 7

def host
  @host
end

Instance Method Details

#get(path) ⇒ Object



20
21
22
# File 'lib/mvm/client.rb', line 20

def get(path, **)
  @conn.get(path, **).body
end

#post(path) ⇒ Object



24
25
26
# File 'lib/mvm/client.rb', line 24

def post(path, **)
  @conn.post(path, **).body
end