Module: IdigbioClient

Extended by:
Helper
Defined in:
lib/idigbio_client.rb,
lib/idigbio_client/search.rb,
lib/idigbio_client/helper.rb,
lib/idigbio_client/version.rb

Overview

Ruby wrapper for iDigBio API

Defined Under Namespace

Modules: Helper, Search

Constant Summary

URL =
"https://beta-search.idigbio.org/v2/"
MAX_LIMIT =
100_000
DEFAULT_LIMIT =
100
HEADERS =
{ content_type: :json, accept: :json }
VERSION =
"0.1.2"

Class Method Summary collapse

Methods included from Helper

get, normalize_type, post, post?, query, request, symbolize, url_params

Class Method Details

.count(opts = {}) ⇒ Object



33
34
35
36
37
38
# File 'lib/idigbio_client.rb', line 33

def count(opts = {})
  opts = { type: "records", params: {} }.merge(opts)
  type = normalize_type(opts[:type])
  res = query(path: "summary/count/#{type}/", params: opts[:params])
  res ? res[:itemCount] : nil
end

.fields(type = nil) ⇒ Object



40
41
42
43
44
45
# File 'lib/idigbio_client.rb', line 40

def fields(type = nil)
  types = type ? [normalize_type(type)] : IdigbioClient.types
  types.each_with_object({}) do |t, res|
    res[t.to_sym] = query(path: "meta/fields/#{t}", method: :get)
  end
end

.loggerObject



21
22
23
# File 'lib/idigbio_client.rb', line 21

def logger
  @logger ||= Logger.new($stdout)
end

.search(opts) ⇒ Object



17
18
19
# File 'lib/idigbio_client.rb', line 17

def search(opts)
  Search.search(opts)
end

.show(uuid) ⇒ Object



25
26
27
# File 'lib/idigbio_client.rb', line 25

def show(uuid)
  query(path: "view/#{uuid}", method: :get)
end

.typesObject



29
30
31
# File 'lib/idigbio_client.rb', line 29

def types
  %w(records mediarecords recordsets publishers)
end

.versionObject



5
6
7
# File 'lib/idigbio_client/version.rb', line 5

def self.version
  VERSION
end