Class: Openbd::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/openbd/client.rb

Overview

The Client class provides a wrapper to the openBD service

Examples:

require 'openbd'

client = Openbd::Client.new

# get
client.get('978-4-7808-0204-7')

See Also:

Instance Method Summary collapse

Instance Method Details

#coverageArray<String>

call /coverage

Returns:

  • (Array<String>)

    List of ISBN



40
41
42
43
44
# File 'lib/openbd/client.rb', line 40

def coverage
  url = "#{END_POINT}/coverage"
  resp = httpclient.get(url)
  body(resp)
end

#get(isbn) ⇒ Hash

call /get

Parameters:

  • isbn (String|Array)

    ISBN

Returns:

  • (Hash)

    Biblio infomation

Raises:



28
29
30
31
32
33
34
35
# File 'lib/openbd/client.rb', line 28

def get(isbn)
  url = "#{END_POINT}/get"
  isbns = isbn_param(isbn)
  method = get_method(isbns)
  q = { isbn: isbns.join(',') }
  resp = httpclient.send(method, url, q)
  body(resp)
end

#httpclientHTTPClient

get HTTPClient

Returns:

  • (HTTPClient)

    HTTPClient



57
58
59
# File 'lib/openbd/client.rb', line 57

def httpclient
  @httpclient ||= HTTPClient.new
end

#schemaObject

call /schema



48
49
50
51
52
# File 'lib/openbd/client.rb', line 48

def schema
  url ="#{END_POINT}/schema"
  resp = httpclient.get(url)
  body(resp)
end