Class: Sherpa::ApiClient
- Inherits:
-
Object
- Object
- Sherpa::ApiClient
- Includes:
- HTTParty
- Defined in:
- lib/sherpa/api_client.rb
Class Method Summary collapse
- .api_uri ⇒ Object
- .default_headers ⇒ Object
- .get(path) ⇒ Object
- .handle_response(response) ⇒ Object
- .post(path, body:) ⇒ Object
- .token ⇒ Object
Class Method Details
.api_uri ⇒ Object
24 25 26 |
# File 'lib/sherpa/api_client.rb', line 24 def api_uri Sherpa::Config.api_uri end |
.default_headers ⇒ Object
28 29 30 31 32 |
# File 'lib/sherpa/api_client.rb', line 28 def default_headers { "Authorization" => "Token token=#{token}" } end |
.get(path) ⇒ Object
8 9 10 |
# File 'lib/sherpa/api_client.rb', line 8 def get(path) handle_response(super(path)) end |
.handle_response(response) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/sherpa/api_client.rb', line 16 def handle_response(response) if response.success? response else raise FailedRequest, response end end |
.post(path, body:) ⇒ Object
12 13 14 |
# File 'lib/sherpa/api_client.rb', line 12 def post(path, body:) handle_response(super(path, body: body)) end |