Class: Hypothesis::API
- Inherits:
-
Object
- Object
- Hypothesis::API
- Defined in:
- lib/hypothesis/api.rb
Constant Summary collapse
- BASE_ENDPOINT =
'https://hypothes.is/api/'.freeze
- SEARCH_ENDPOINT =
'search'.freeze
- ANNOTATIONS_ENDPOINT =
'annotations/'.freeze
Instance Method Summary collapse
-
#initialize(api_key) ⇒ API
constructor
A new instance of API.
- #read(id) ⇒ Object
- #root ⇒ Object
- #search(params = {}) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ API
Returns a new instance of API.
10 11 12 |
# File 'lib/hypothesis/api.rb', line 10 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#read(id) ⇒ Object
26 27 28 29 30 |
# File 'lib/hypothesis/api.rb', line 26 def read(id) get(BASE_ENDPOINT + ANNOTATIONS_ENDPOINT + id) rescue => e { error: e } end |
#root ⇒ Object
14 15 16 17 18 |
# File 'lib/hypothesis/api.rb', line 14 def root get(BASE_ENDPOINT) rescue => e { error: e } end |
#search(params = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/hypothesis/api.rb', line 20 def search(params = {}) get(BASE_ENDPOINT + SEARCH_ENDPOINT, params) rescue => e { error: e } end |