Module: Checkerberry
- Extended by:
- Configuration
- Defined in:
- lib/checkerberry.rb,
lib/checkerberry/error.rb,
lib/checkerberry/utils.rb,
lib/checkerberry/request.rb,
lib/checkerberry/version.rb
Defined Under Namespace
Modules: Utils Classes: BadGateway, Error, InternalServerError, NotFound, Request, RequestError, ServiceUnavailable, Unauthorized
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.data_source(source_id, verbose: false) ⇒ Hash
Get a single data source by ID.
-
.data_sources(verbose: false) ⇒ Array
Get list of data sources.
-
.ping(verbose: false) ⇒ Object
Ping the API (check if the service is alive).
-
.search(query: nil, data_sources: nil, parent_taxon: nil, name_string: nil, genus: nil, species: nil, species_any: nil, infraspecies: nil, author: nil, year: nil, year_start: nil, year_end: nil, with_all_results: nil, verbose: false) ⇒ Object
Search for scientific names.
-
.verify(names, data_sources: nil, vernacular_languages: nil, with_all_matches: nil, with_capitalization: nil, with_species_group: nil, with_uninomial_fuzzy_match: nil, with_stats: nil, min_taxon_threshold: nil, verbose: false) ⇒ Hash
Verify scientific names.
-
.version(verbose: false) ⇒ Hash
Get version information.
Methods included from Configuration
Class Method Details
.data_source(source_id, verbose: false) ⇒ Hash
Get a single data source by ID
105 106 107 108 |
# File 'lib/checkerberry.rb', line 105 def self.data_source(source_id, verbose: false) endpoint = "data_sources/#{source_id}" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.data_sources(verbose: false) ⇒ Array
Get list of data sources
94 95 96 97 |
# File 'lib/checkerberry.rb', line 94 def self.data_sources(verbose: false) endpoint = "data_sources" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.ping(verbose: false) ⇒ Object
Ping the API (check if the service is alive)
113 114 115 116 |
# File 'lib/checkerberry.rb', line 113 def self.ping(verbose: false) endpoint = "ping" Request.new(endpoint: endpoint, verbose: verbose).perform end |
.search(query: nil, data_sources: nil, parent_taxon: nil, name_string: nil, genus: nil, species: nil, species_any: nil, infraspecies: nil, author: nil, year: nil, year_start: nil, year_end: nil, with_all_results: nil, verbose: false) ⇒ Object
Search for scientific names
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/checkerberry.rb', line 59 def self.search(query: nil, data_sources: nil, parent_taxon: nil, name_string: nil, genus: nil, species: nil, species_any: nil, infraspecies: nil, author: nil, year: nil, year_start: nil, year_end: nil, with_all_results: nil, verbose: false) endpoint = "search" # require year_start and year_end together if year_start && !year_end raise ArgumentError, "year_end is required when year_start is provided" end if year_end && !year_start raise ArgumentError, "year_start is required when year_end is provided" end # require no year if year_start and year_end are provided if (year_start || year_end) && year raise ArgumentError, "year cannot be provided when year_start and year_end are provided" end data_sources_array = data_sources.is_a?(Array) ? data_sources : (data_sources.nil? ? nil : [data_sources]) Request.new(endpoint: endpoint, method: :post, query: query, data_sources: data_sources_array, parent_taxon: parent_taxon, name_string: name_string, genus: genus, species: species, species_any: species_any, infraspecies: infraspecies, author: , year: year, year_start: year_start, year_end: year_end, with_all_results: with_all_results, verbose: verbose).perform end |
.verify(names, data_sources: nil, vernacular_languages: nil, with_all_matches: nil, with_capitalization: nil, with_species_group: nil, with_uninomial_fuzzy_match: nil, with_stats: nil, min_taxon_threshold: nil, verbose: false) ⇒ Hash
Verify scientific names
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/checkerberry.rb', line 29 def self.verify(names, data_sources: nil, vernacular_languages: nil, with_all_matches: nil, with_capitalization: nil, with_species_group: nil, with_uninomial_fuzzy_match: nil, with_stats: nil, min_taxon_threshold: nil, verbose: false) endpoint = "verifications" names_array = names.is_a?(Array) ? names : [names] data_sources_array = data_sources.is_a?(Array) ? data_sources : (data_sources.nil? ? nil : [data_sources]) Request.new(endpoint: endpoint, method: :post, names: names_array, data_sources: data_sources_array, vernacular_languages: vernacular_languages, with_all_matches: with_all_matches, with_capitalization: with_capitalization, with_species_group: with_species_group, with_uninomial_fuzzy_match: with_uninomial_fuzzy_match, with_stats: with_stats, min_taxon_threshold: min_taxon_threshold, verbose: verbose).perform end |