Class: Shikimori::API::REST
- Inherits:
-
Object
- Object
- Shikimori::API::REST
- Defined in:
- lib/shikimori/api/rest.rb
Overview
Helpers to make requests
Instance Method Summary collapse
- #delete(uri, **options) ⇒ Object
- #get(uri, **options) ⇒ Object
-
#initialize(app_name: nil, access_token: nil, refresh_token: nil) ⇒ REST
constructor
A new instance of REST.
- #post(uri, data, **options) ⇒ Object
- #put(uri, data, **options) ⇒ Object
Constructor Details
#initialize(app_name: nil, access_token: nil, refresh_token: nil) ⇒ REST
Returns a new instance of REST.
7 8 9 10 11 |
# File 'lib/shikimori/api/rest.rb', line 7 def initialize(app_name: nil, access_token: nil, refresh_token: nil) @app_name = app_name @access_token = access_token @refresh_token = refresh_token end |
Instance Method Details
#delete(uri, **options) ⇒ Object
28 29 30 31 |
# File 'lib/shikimori/api/rest.rb', line 28 def delete(uri, **) response, _json = request(:delete, uri, **) [Net::HTTPNoContent, Net::HTTPSuccess].any? { response.is_a?(_1) } end |
#get(uri, **options) ⇒ Object
13 14 15 16 |
# File 'lib/shikimori/api/rest.rb', line 13 def get(uri, **) _response, json = request(:get, uri, **) json end |
#post(uri, data, **options) ⇒ Object
18 19 20 21 |
# File 'lib/shikimori/api/rest.rb', line 18 def post(uri, data, **) _response, json = request(:post, uri, data, **) json end |
#put(uri, data, **options) ⇒ Object
23 24 25 26 |
# File 'lib/shikimori/api/rest.rb', line 23 def put(uri, data, **) _response, json = request(:put, uri, data, **) json end |