Class: QuizApiClient::HttpClient
- Inherits:
-
Object
- Object
- QuizApiClient::HttpClient
- Includes:
- HTTParty
- Defined in:
- lib/quiz_api_client/http_client.rb
Defined Under Namespace
Classes: RequestFailed
Instance Attribute Summary collapse
-
#jwt ⇒ Object
readonly
Returns the value of attribute jwt.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path, all: false, query: {}) ⇒ Object
-
#initialize(uri:, jwt:) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #patch(path, body = {}) ⇒ Object
- #post(path, body = {}) ⇒ Object
- #put(path, body = {}) ⇒ Object
Constructor Details
#initialize(uri:, jwt:) ⇒ HttpClient
Returns a new instance of HttpClient.
9 10 11 12 |
# File 'lib/quiz_api_client/http_client.rb', line 9 def initialize(uri:, jwt:) @uri = uri @jwt = jwt end |
Instance Attribute Details
#jwt ⇒ Object (readonly)
Returns the value of attribute jwt.
7 8 9 |
# File 'lib/quiz_api_client/http_client.rb', line 7 def jwt @jwt end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
7 8 9 |
# File 'lib/quiz_api_client/http_client.rb', line 7 def uri @uri end |
Instance Method Details
#delete(path) ⇒ Object
31 32 33 |
# File 'lib/quiz_api_client/http_client.rb', line 31 def delete(path) make_request :delete, path end |
#get(path, all: false, query: {}) ⇒ Object
14 15 16 17 |
# File 'lib/quiz_api_client/http_client.rb', line 14 def get(path, all: false, query: {}) return make_request :get, path, query: query unless all make_paginated_request :get, path, query: query end |
#patch(path, body = {}) ⇒ Object
23 24 25 |
# File 'lib/quiz_api_client/http_client.rb', line 23 def patch(path, body = {}) make_request :patch, path, body: body.to_json end |
#post(path, body = {}) ⇒ Object
19 20 21 |
# File 'lib/quiz_api_client/http_client.rb', line 19 def post(path, body = {}) make_request :post, path, body: body.to_json end |
#put(path, body = {}) ⇒ Object
27 28 29 |
# File 'lib/quiz_api_client/http_client.rb', line 27 def put(path, body = {}) make_request :put, path, body: body.to_json end |