colrapi 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d96f3b1aeaf8a629d768a2c7ed41bd77fb9df97c73282d149a679c97161b249f
4
- data.tar.gz: 28f0950d39f06e58346fc3a84ab0db4675dbc7c3b19d4c05e538999133b72d88
3
+ metadata.gz: 07aa378c2254f300d7086a0a2679e36a594a99a939d4487adb8745f96abe50b6
4
+ data.tar.gz: ada0fe3d028b8a20be01c229165fdff97ee67fd0684d078989891e067d68a862
5
5
  SHA512:
6
- metadata.gz: f268ff2f3862eff6e3e9366ad145a3a58f393c53a4088e334c6cf9fba27431735b2e6d4ad98d40f99a6c995108e0ae9eaa1cfde347bd6e35beb7b43f3e8bb717
7
- data.tar.gz: 00d408991f607b6bd044b20d295a9ba40e625e23a17c40388f79d1ce09162ca4a3220e5ed482e4742ed26816a5a366f302468512d6bc091f6ea54bb3d79c3903
6
+ metadata.gz: 12513f5a616691d81568970d0f5e65c9198990c8a167327c0e9d36b856f562f2cbb56004a7a78a01e6e6a2d7be5c3d3cfbd51c51f67f561c63ff2b480ebe0b20
7
+ data.tar.gz: 9245c8a61aa5f716467cf64d8bafb00a6d0987d88a2055411c3baa8ee9a62b8b04f14a882987f65b4b6e9003bd228004cae950e1ff5cadb21ae69fb5c03c82b2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.6] - 2025-03-25
4
+ - Added more nameusage_search parameters:
5
+ - authorship
6
+ - authorship_year
7
+ - extinct
8
+ - field
9
+ - name_type
10
+ - nomenclatural_code
11
+ - nomenclatural_status
12
+ - origin
13
+ - secondary_source
14
+ - sector_dataset_id
15
+ - sector_mode
16
+ - status
17
+ - taxonomic_group
18
+
19
+ ## [0.1.5] - 2025-03-25
20
+ - Added usage_id to nameusage_search
21
+
3
22
  ## [0.1.4] - 2025-03-05
4
23
  - Fixed authentication
5
24
  - Kept depreciated ChecklistBank preview endpoint functionality by using /dataset/{dataset_id}LRC.json instead (now requires a token)
@@ -20,7 +20,7 @@ module Faraday
20
20
  when 502
21
21
  raise Colrapi::BadGateway, error_message_500(response, "The server returned an invalid or incomplete response.")
22
22
  when 503
23
- raise Colrapi::ServiceUnavailable, error_message_500(response, "Crossref is rate limiting your requests.")
23
+ raise Colrapi::ServiceUnavailable, error_message_500(response, "The service is unavailable.")
24
24
  when 504
25
25
  raise Colrapi::GatewayTimeout, error_message_500(response, "504 Gateway Time-out")
26
26
  end
@@ -1,15 +1,11 @@
1
- require_relative "faraday" # !! Potential ruby 3.0 difference in module loading? relative differs from Serrano
1
+ require_relative "faraday"
2
2
  require "faraday/follow_redirects"
3
3
  require_relative "utils"
4
4
  require "colrapi/error"
5
5
 
6
6
  module Colrapi
7
7
  class Request
8
- attr_accessor :endpoint
9
- attr_accessor :q
10
- attr_accessor :verbose
11
-
12
- attr_accessor :options
8
+ attr_accessor :endpoint, :q, :verbose, :options
13
9
 
14
10
  def initialize(**args)
15
11
  @endpoint = args[:endpoint]
@@ -22,15 +18,20 @@ module Colrapi
22
18
  @regexp = args[:regexp]
23
19
  @content = Array(args[:content]) if args[:content]
24
20
  @name = args[:name]
25
- @authorship = args[:authorship]
26
- @code = args[:code]
21
+ @authorship = Array(args[:authorship]) if args[:authorship]
22
+ @authorship_year = Array(args[:authorship_year]) if args[:authorship_year]
23
+ @code = Array(args[:code]) if args[:code]
24
+ @nomenclatural_code = Array(args[:nomenclatural_code]) if args[:nomenclatural_code] # unfortunately code and nom_code get used on different endpoints
25
+ @field = Array(args[:field]) if args[:field]
27
26
  @type = Array(args[:type]) if args[:type]
28
27
  @rank = Array(args[:rank]) if args[:rank]
29
28
  @facet = Array(args[:facet]) if args[:facet]
29
+ @extinct = Array(args[:extinct]) if args[:extinct]
30
30
  @min_rank = args[:min_rank]
31
31
  @max_rank = args[:max_rank]
32
- @environment = args[:environment]
32
+ @environment = Array(args[:environment]) if args[:environment]
33
33
  @highest_taxon_id = args[:highest_taxon_id]
34
+ @usage_id = args[:usage_id]
34
35
  @parent_rank = args[:parent_rank]
35
36
  @root_id = Array(args[:root_id]) if args[:root_id]
36
37
  @root2_id = Array(args[:root2_id]) if args[:root2_id]
@@ -46,6 +47,7 @@ module Colrapi
46
47
  @has_gbif_id = args[:has_gbif_id]
47
48
  @gbif_id = args[:gbif_id]
48
49
  @gbif_publisher_id = args[:gbif_publisher_id]
50
+ @taxonomic_group = Array(args[:taxonomic_group]) if args[:taxonomic_group]
49
51
  @editor = args[:editor]
50
52
  @reviewer = args[:reviewer]
51
53
  @modified_by = args[:modified_by]
@@ -61,12 +63,18 @@ module Colrapi
61
63
  @term_operator = args[:term_operator]
62
64
  @issued = args[:issued]
63
65
  @issued_before = args[:issued]
64
- @modified_after = args[:modified_after]
66
+ @modified_after = args[:modified_after]
65
67
  @modified_before = args[:modified_before]
66
68
  @last_synced_before = args[:last_synced_before]
67
69
  @min = args[:min]
68
70
  @max = args[:max]
69
71
  @min_size = args[:min_size]
72
+ @name_type = Array(args[:name_type]) if args[:name_type]
73
+ @nomenclatural_status = Array(args[:nomenclatural_status]) if args[:nomenclatural_status]
74
+ @status = Array(args[:status]) if args[:status]
75
+ @sector_mode = Array(args[:sector_mode]) if args[:sector_mode]
76
+ @sector_dataset_id = Array(args[:sector_dataset_id]) if args[:sector_dataset_id]
77
+ @secondary_source = Array(args[:secondary_source]) if args[:secondary_source]
70
78
  @size = args[:size]
71
79
  @within_superkingdom = args[:within_superkingdom]
72
80
  @within_kingdom = args[:within_kingdom]
@@ -111,16 +119,19 @@ module Colrapi
111
119
 
112
120
  def perform
113
121
 
114
- args = { q: @q, regex: @regexp, attempt: @attempt, content: @content, name: @name, authorship: @authorship, code: @code, type: @type,
122
+ args = { q: @q, regex: @regexp, attempt: @attempt, content: @content, name: @name, authorship: @authorship,
123
+ authorshipYear: @authorship_year, code: @code, nomCode: @nomenclatural_code, field: @field, extinct: @extinct, type: @type,
115
124
  rank: @rank, minRank: @min_rank, maxRank: @max_rank, parentRank: @parent_rank, projectKey: @project_id,
116
125
  term: @term, termOp: @term_operator, status: @status, decisionMode: @decision_mode,
117
126
  alias: @short_title, private: @private, releasedFrom: @released_from, contributesTo: @contributes_to,
118
- hasSourceDataset: @has_source_dataset, hasGbifKey: @has_gbif_id, gbifKey: @gbif_id,
127
+ hasSourceDataset: @has_source_dataset, hasGbifKey: @has_gbif_id, group: @taxonomic_group, gbifKey: @gbif_id,
119
128
  gbifPublisherKey: @gbif_publisher_id, editor: @editor, reviewer: @reviewer, modifiedBy: @modified_by,
120
129
  id: @id, format: @format, root: @root_id, root2: @root2_id, synonyms: @include_synonyms,
121
130
  showParent: @include_parent, origin: @origin, original: @original, license: @license, rowType: @row_type,
122
131
  created: @created_after, createdBefore: @created_before, issued: @issued, issuedBefore: @issued_before,
123
132
  modified: @modified_after, modifiedBefore: @modified_before, lastSync: @last_synced_before,
133
+ status: @status, nomStatus: @nomenclatural_status, nameType: @name_type,
134
+ sectorMode: @sector_mode, sectorDatasetKey: @sector_dataset_id, secondarySourceGroup: @secondary_source,
124
135
  minSize: @min_size, size: @size, issue: @issue, min: @min, max: @max, datasetKey: @dataset_id_filter,
125
136
  withoutData: @without_data, superkingdom: @within_superkingdom, kingdom: @within_kingdom,
126
137
  subkingdom: @within_subkingdom, superphylum: @within_superphylum, phylum: @within_phylum,
@@ -132,30 +143,18 @@ module Colrapi
132
143
  subgenus: @within_subgenus, section: @within_section, species: @within_species,
133
144
  nidx: @nidx_id, state: @state, running: @running, notCurrentOnly: @not_current_only,
134
145
  broken: @broken, subjectDatasetKey: @subject_dataset_id, mode: @mode, subject: @subject,
135
- TAXON_ID: @highest_taxon_id, environment: @environment,
136
- sortBy: @sort_by, reverse: @reverse, url: @url, offset: @offset, limit: @limit}
146
+ TAXON_ID: @highest_taxon_id, USAGE_ID: @usage_id, environment: @environment,
147
+ sortBy: @sort_by, reverse: @reverse, url: @url, body: @body, offset: @offset, limit: @limit }
137
148
  opts = args.delete_if { |_k, v| v.nil? }
138
149
 
139
- conn = if verbose
140
- Faraday.new(url: Colrapi.base_url, request: { params_encoder: Faraday::FlatParamsEncoder }) do |f|
141
- if !@user.nil? and !@password.nil?
142
- f.request :authorization, :basic, @user, @password
143
- end
144
- f.response :logger
145
- f.use Faraday::ColrapiErrors::Middleware
146
- f.adapter Faraday.default_adapter
147
- end
148
- else
149
- Faraday.new(url: Colrapi.base_url, request: { params_encoder: Faraday::FlatParamsEncoder }) do |f|
150
- if !@user.nil? and !@password.nil?
151
- f.request :authorization, :basic, @user, @password
152
- end
153
- f.use Faraday::ColrapiErrors::Middleware
154
- f.adapter Faraday.default_adapter
155
- end
156
- end
150
+ conn = Faraday.new(url: Colrapi.base_url, request: { params_encoder: Faraday::FlatParamsEncoder }) do |f|
151
+ f.request :authorization, :basic, @user, @password if @user && @password
152
+ f.response :logger if @verbose
153
+ f.use Faraday::ColrapiErrors::Middleware
154
+ f.adapter Faraday.default_adapter
155
+ end
157
156
 
158
- conn.headers['Authorization'] = "Bearer #{@token}" unless @token.nil?
157
+ conn.headers['Authorization'] = "Bearer #{@token}" if @token
159
158
  conn.headers['Accept'] = 'application/json,*/*'
160
159
  conn.headers[:user_agent] = make_user_agent
161
160
  conn.headers["X-USER-AGENT"] = make_user_agent
@@ -168,7 +167,6 @@ module Colrapi
168
167
  rescue MultiJson::ParseError
169
168
  res.body
170
169
  end
171
-
172
170
  end
173
171
  end
174
172
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Colrapi
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/colrapi.rb CHANGED
@@ -42,6 +42,7 @@ module Colrapi
42
42
  # Search datasets:
43
43
  # @param q [String] A search query for datasets
44
44
  # @param short_title [String] A dataset alias
45
+ # @param title [String] A dataset title
45
46
  # @param code [String] The nomenclatural code (bacterial, botanical, cultivars, phytosociological, virus, zoological)
46
47
  # @param private [Boolean] Whether the dataset is private or not
47
48
  # @param released_from [Integer] Filter by a project id that a dataset was released from
@@ -64,6 +65,7 @@ module Colrapi
64
65
  # @param modified_after [Date] Filter by modified after date
65
66
  # @param modified_before [Date] Filter by modified before date
66
67
  # @param min_size [Integer] Filter by minimum record size
68
+ # @param token [String, nil] An authentication token from Colrapi.user_login()
67
69
  #
68
70
  # @param sort_by [String] Sort by (key, alias, title, creator, relevance, created, modified, imported, size)
69
71
  # @param reverse [Boolean] Sort in reverse
@@ -76,7 +78,7 @@ module Colrapi
76
78
  contributes_to: nil, has_source_dataset: nil, has_gbif_id: nil, gbif_id: nil, gbif_publisher_id: nil,
77
79
  editor: nil, reviewer: nil, modified_by: nil, origin: nil, type: nil, license: nil, row_type: nil,
78
80
  created_after: nil, created_before: nil, issued_after: nil, issued_before: nil, modified_after: nil,
79
- modified_before: nil, min_size: nil, sort_by: nil, reverse: nil, offset: nil, limit: nil,
81
+ modified_before: nil, min_size: nil, sort_by: nil, token: nil, reverse: nil, offset: nil, limit: nil,
80
82
  verbose: false)
81
83
  endpoint = "dataset"
82
84
  unless dataset_id.nil?
@@ -94,7 +96,7 @@ module Colrapi
94
96
  row_type: row_type, created_after: created_after, created_before: created_before,
95
97
  issued_after: issued_after, issued_before: issued_before, modified_after: modified_after,
96
98
  modified_before: modified_before, min_size: min_size, sort_by: sort_by, reverse: reverse,
97
- offset: offset, limit: limit, verbose: verbose).perform
99
+ offset: offset, limit: limit, token: token, verbose: verbose).perform
98
100
  end
99
101
  end
100
102
 
@@ -541,19 +543,33 @@ module Colrapi
541
543
 
542
544
  # Search the nameusage route, which uses Elastic Search
543
545
  #
544
- # @param q [String] A query string
546
+ # @param authorship [Array, String, nil] filters by authorship
547
+ # @param authorship_year [Array, String, nil] filters by authorship year
548
+ # @param content [Array, String, nil] restrict search to SCIENTIFIC_NAME, or AUTHORSHIP
545
549
  # @param dataset_id [String, nil] restricts name usage search within a dataset
546
550
  # @param endpoint [String, nil] some endpoints have nested options
547
- # @param content [Array, String, nil] restrict search to SCIENTIFIC_NAME, or AUTHORSHIP
548
- # @param issue [Array, String, nil] the data quality issue
549
- # @param type [String, nil] sets the type of search to PREFIX, WHOLE_WORDS, or EXACT
550
- # @param rank [String, nil] taxonomic rank of name usages
551
- # @param min_rank [String, nil] minimum taxonomic rank of name usages
552
- # @param max_rank [String, nil] maximum taxonomic rank of name usages
553
- # @param facet [Array, String, nil] the search facet
554
551
  # @param environment [Array, String, nil] filter by environment (MARINE, TERRESTRIAL, FRESHWATER, BRACKISH)
552
+ # @param extinct [Array, int, nil] filter by extinct status (0, 1)
553
+ # @param facet [Array, String, nil] the search facet
554
+ # @param field [Array, String, nil] filter by name field (see: http://api.checklistbank.org/vocab/namefield)
555
555
  # @param highest_taxon_id [String, nil] Filter by highest taxon ID
556
- #
556
+ # @param issue [Array, String, nil] the data quality issue
557
+ # @param max_rank [String, nil] maximum taxonomic rank of name usages
558
+ # @param min_rank [String, nil] minimum taxonomic rank of name usages
559
+ # @param name_type [Array, String, nil] filter by name type (hybrid formula, informal, no name, otu, placeholder, scientific, virus)
560
+ # @param nomenclatural_code [Array, String, nil] filter by nomenclatural code (botanical, zoological, bacterial, viral, phytosociological, cultivars)
561
+ # @param nomenclatural_status [Array, String, nil] filter by nomenclatural status (acceptable, conserved, doubtful, established, manuscript, not established, rejected, unacceptable)
562
+ # @param origin [Array, String, nil] filter by origin of the name usage (see: http://api.checklistbank.org/vocab/origin)
563
+ # @param q [String] A query string
564
+ # @param rank [Array, String, nil] taxonomic rank of name usages
565
+ # @param secondary_source [Array, String, nil] filter by secondary source (authorship, basionym, extinct, holotype, parent, published in, rank, temporal range)
566
+ # @param sector_dataset_id [Array, String, nil] filter by the sector source dataset ID
567
+ # @param sector_mode [Array, String, nil] filter by the sector mode (attach, merge, union)
568
+ # @param status [Array, String, nil] filter by taxonomic status (accepted, ambiguous synonym, misapplied, provisionally accepted, synonym)
569
+ # @param taxonomic_group [Array, String, nil] filter by taxonomic group (see: http://api.checklistbank.org/vocab/taxgroup)
570
+ # @param type [String, nil] sets the type of search to PREFIX, WHOLE_WORDS, or EXACT
571
+ # @param usage_id [String, nil] Filter by usage ID
572
+ #
557
573
  # @param sort_by [String, nil] sort results by NAME, TAXONOMIC, INDEX_NAME_ID, NATIVE, or RELEVANCE
558
574
  # @param reverse [Boolean] sort in reverse order
559
575
  # @param offset [Integer] Offset for pagination
@@ -561,20 +577,29 @@ module Colrapi
561
577
  # @param verbose [Boolean] Print headers to STDOUT
562
578
  #
563
579
  # @return [Array, Boolean] An array of hashes
564
- def self.nameusage_search(q: nil, dataset_id: nil, endpoint: 'nameusage/search', content: nil, issue: nil,
580
+ def self.nameusage_search(q: nil, authorship: nil, authorship_year: nil, dataset_id: nil,
581
+ endpoint: 'nameusage/search', extinct: nil, field: nil, content: nil, issue: nil,
565
582
  type: nil, rank: nil, min_rank: nil, max_rank: nil, environment: nil, facet: nil,
566
- highest_taxon_id: nil, sort_by: nil, reverse: nil, offset: nil, limit: nil,
567
- verbose: false)
583
+ nomenclatural_code: nil, highest_taxon_id: nil, usage_id: nil, nomenclatural_status: nil,
584
+ name_type: nil, origin: nil, secondary_source: nil,
585
+ sector_mode: nil, sector_dataset_id: nil, status: nil, taxonomic_group: nil,
586
+ sort_by: nil, reverse: nil, offset: nil, limit: nil, verbose: false)
568
587
 
569
588
  # a nil dataset_id will search name usages from all datasets in ChecklistBank
570
589
  unless dataset_id.nil?
571
590
  endpoint = "dataset/#{dataset_id}/nameusage/search"
572
591
  end
573
592
 
574
- Request.new(endpoint: endpoint, q: q, content: content, issue: issue, type: type,
575
- rank: rank, min_rank: min_rank, max_rank: max_rank, facet: facet, environment: environment,
576
- highest_taxon_id: highest_taxon_id, sort_by: sort_by, reverse: reverse,
577
- offset: offset, limit: limit, verbose: verbose).perform
593
+ Request.new(endpoint: endpoint, q: q, authorship: authorship, authorship_year: authorship_year,
594
+ extinct: extinct, field: field, content: content, issue: issue, type: type,
595
+ rank: rank, min_rank: min_rank, max_rank: max_rank, facet: facet,
596
+ nomenclatural_code: nomenclatural_code,environment: environment,
597
+ highest_taxon_id: highest_taxon_id, usage_id: usage_id,
598
+ name_type: name_type, nomenclatural_status: nomenclatural_status, origin: origin,
599
+ secondary_source: secondary_source, sector_mode: sector_mode,
600
+ sector_dataset_id: sector_dataset_id, status: status, taxonomic_group: taxonomic_group,
601
+ sort_by: sort_by, reverse: reverse, offset: offset, limit: limit,
602
+ verbose: verbose).perform
578
603
  end
579
604
 
580
605
  # Get a name usage suggestion
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colrapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Yoder, Geoff Ower
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-05 00:00:00.000000000 Z
11
+ date: 2025-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,7 +198,7 @@ licenses:
198
198
  metadata:
199
199
  homepage_uri: https://github.com/SpeciesFileGroup/colrapi
200
200
  source_code_uri: https://github.com/SpeciesFileGroup/colrapi
201
- changelog_uri: https://github.com/SpeciesFileGroup/colrapi/releases/tag/v0.1.4
201
+ changelog_uri: https://github.com/SpeciesFileGroup/colrapi/releases/tag/v0.1.6
202
202
  post_install_message:
203
203
  rdoc_options: []
204
204
  require_paths: