Class: Hypothesis::API

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(api_key) ⇒ API

Returns a new instance of API.



12
13
14
# File 'lib/hypothesis/api.rb', line 12

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#read(id) ⇒ Object



28
29
30
31
32
# File 'lib/hypothesis/api.rb', line 28

def read(id)
  get(BASE_ENDPOINT + ANNOTATIONS_ENDPOINT + id)
rescue => e
  { error: e }
end

#rootObject



16
17
18
19
20
# File 'lib/hypothesis/api.rb', line 16

def root
  get(BASE_ENDPOINT)
rescue => e
  { error: e }
end

#search(params = {}) ⇒ Object



22
23
24
25
26
# File 'lib/hypothesis/api.rb', line 22

def search(params = {})
  get(BASE_ENDPOINT + SEARCH_ENDPOINT, params)
rescue => e
  { error: e }
end