Module: Credentialias::Helper::Server

Defined in:
lib/credentialias/helper/server.rb

Class Method Summary collapse

Class Method Details

.backendObject



17
18
19
# File 'lib/credentialias/helper/server.rb', line 17

def backend
  @backend ||= Boutons.send Credentialias::Helper::Config::ENDPOINT
end

.connectObject



9
10
11
12
13
14
15
16
# File 'lib/credentialias/helper/server.rb', line 9

def connect
  Config.configure
  Boutons.send Credentialias::Helper::Config::ENDPOINT
  10.times{ get("/health").code == 200 and break rescue sleep 0.1 }
  Unirest.default_header('X-Credentialias-API',Credentialias::Helper::Config::API_VERSION)
  Unirest.default_header('Accept','application/json')
  Unirest.default_header('Content-Type','application/json')
end

.delete(path) ⇒ Object



23
24
25
# File 'lib/credentialias/helper/server.rb', line 23

def delete path
  Unirest.delete url(path)
end

.get(path) ⇒ Object



20
21
22
# File 'lib/credentialias/helper/server.rb', line 20

def get path
  Unirest.get url path
end

.post(path, parameters) ⇒ Object



26
27
28
# File 'lib/credentialias/helper/server.rb', line 26

def post path, parameters
  Unirest.post url(path), parameters: parameters
end

.put(path, parameters) ⇒ Object



29
30
31
# File 'lib/credentialias/helper/server.rb', line 29

def put path, parameters
  Unirest.put url(path), parameters: parameters
end

.url(path) ⇒ Object



32
33
34
# File 'lib/credentialias/helper/server.rb', line 32

def url path
  backend.s("%P://%h:%p#{path}")
end