Class: Passfort::Http
- Inherits:
-
Object
- Object
- Passfort::Http
- Defined in:
- lib/passfort/http.rb
Constant Summary collapse
- DOMAIN =
"https://api.passfort.com"
- ROOT_PATH =
"/4.0"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(api_key, excon_opts = {}) ⇒ Http
constructor
A new instance of Http.
- #post(path, body:) ⇒ Object
Constructor Details
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/passfort/http.rb', line 12 def api_key @api_key end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
12 13 14 |
# File 'lib/passfort/http.rb', line 12 def connection @connection end |
Instance Method Details
#get(path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/passfort/http.rb', line 20 def get(path) execute( -> { @connection.get( path: ROOT_PATH + path, headers: { apikey: @api_key }, ) }, :get, path: path, ) end |
#post(path, body:) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/passfort/http.rb', line 33 def post(path, body:) execute( -> { @connection.post( path: ROOT_PATH + path, body: body.to_json, headers: { apikey: @api_key, "Content-Type" => "application/json" }, ) }, :post, path: path, body: body, ) end |