nasturtium 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nasturtium.rb ADDED
@@ -0,0 +1,843 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+ #require 'nokogiri'
5
+ require 'open-uri'
6
+ require_relative "nasturtium/error"
7
+ require_relative "nasturtium/version"
8
+ require_relative "nasturtium/request"
9
+ require "nasturtium/helpers/configuration"
10
+ require 'cgi'
11
+
12
+ module Nasturtium
13
+ extend Configuration
14
+
15
+ define_setting :base_url, "https://api.inaturalist.org/v1/"
16
+ define_setting :mailto, ENV["NASTURTIUM_API_EMAIL"]
17
+
18
+ # Get API token
19
+ # @param user [String]
20
+ # @param password [String]
21
+ # def self.api_token(user, password, verbose: false)
22
+ # doc = Nokogiri::HTML(URI.open('https://www.inaturalist.org/users/api_token'))
23
+ # csrf_token = CGI.escape(doc.at('meta[name="csrf-token"]')['content'])
24
+
25
+ # puts csrf_token
26
+ # # https://www.inaturalist.org/users/api_token
27
+ # body = "utf8=%E2%9C%93&authenticity_token=#{csrf_token}&user%5Bemail%5D=#{user}&user%5Bpassword%5D=#{password}&user%5Bremember_me%5D=0"
28
+ # endpoint = 'users/api_token'
29
+ # res = Request.new(method: 'POST', base_url: 'https://www.inaturalist.org/', endpoint: endpoint, body: body, verbose: verbose).perform
30
+ # puts res
31
+ # end
32
+
33
+ # Get controlled vocabulary terms
34
+ # @param taxon_id [String, nil] If set returns controlled terms for the taxon
35
+ #
36
+ # @param page [Integer, nil] The results page number
37
+ # @param per_page [Integer, nil] The results limit
38
+ # @param verbose [Boolean] Print headers to STDOUT
39
+ #
40
+ # @return [Hash, Boolean] A hash of controlled terms results
41
+ def self.controlled_terms(taxon_id: nil, page: nil, per_page: nil, verbose: false)
42
+ if taxon_id.nil?
43
+ endpoint = 'controlled_terms'
44
+ else
45
+ endpoint = 'controlled_terms/for_taxon'
46
+ end
47
+ Request.new(endpoint: endpoint, taxon_id: taxon_id, page: page, per_page: per_page, verbose: verbose).perform
48
+ end
49
+
50
+ # Get identifications
51
+ # @param id [String, Integer, nil] An array of identification IDs
52
+ # @param current_taxon [Boolean, nil] The identification taxon is the same as its observation's taxon
53
+ # @param own_observation [Boolean, nil] The identification was added by th observer
54
+ # @param is_change [Boolean, nil] The identification was created as a result of a taxon change
55
+ # @param taxon_active [Boolean nil] The identification's taxon is currently an active taxon
56
+ # @param observation_taxon_active [Boolean, nil] The observation's taxon is currently an active taxon
57
+ # @param rank [String, nil] Filter by a comma-separated list of taxonomic ranks on the identification
58
+ # @param observation_rank [String, nil] Filter by a comma-separated list of taxonomic ranks on the observation
59
+ # @param user_id [String, Integer, nil] Filter by a comma-separated list of user IDs
60
+ # @param user_login [String, nil] Filter by a comma-separated list of user logins
61
+ # @param current [Boolean, nil] The most recent identification on an observation by a user
62
+ # @param category [String, nil] The type of identification (improving, supporting, leading)
63
+ # @param place_id [String, Integer, nil] Filter by a comma-separated list of place IDs
64
+ # @param quality_grade [String, nil] Filter by a comma-separated list of quality grades (casual, needs_id, research)
65
+ # @param taxon_id [String, Integer, nil] Filter by a comma-separated list of taxon IDs on the identification
66
+ # @param observation_taxon_id [String, Integer, nil] Filter by a comma-separated list of taxon IDs on the observation
67
+ # @param iconic_taxon_id [String, Integer, nil] Filter by a comma-separated list of iconic taxon IDs on the identification
68
+ # @param observation_iconic_taxon_id [String, Integer, nil] Filter by a comma-separated list of iconic taxon IDs on the observation
69
+ # @param rank_lowest [String, nil] The identification's taxon must have this rank or higher
70
+ # @param rank_highest [String, nil] The identification's taxon must have this rank or lower
71
+ # @param observation_rank_lowest [String, nil] The observation's taxon must have this rank or higher
72
+ # @param observation_rank_highest [String, nil] The observation's taxon must have this rank or lower
73
+ # @param without_taxon_id [String, Integer, nil] Exclude this comma-separated list of identification taxon IDs and their descendants
74
+ # @param without_observation_taxon_id [String, Integer, nil] Exclude this comma-separated list of observation taxon IDs and their descendants
75
+ # @param before [String, nil] Identified before this time (d2)
76
+ # @param after [String, nil] Identified after this time (d1)
77
+ # @param observation_created_before [String, nil] Observation record was created before this time (observation_created_d2)
78
+ # @param observation_created_after [String, nil] Observation record was created after this time (observation_created_d1)
79
+ # @param observed_before [String, nil] Observed before this time (observed_d2)
80
+ # @param observed_after [String, nil] Observed after this time (observed_d1)
81
+ # @param id_below [String, Integer, nil] The identification ID must be below the provided value
82
+ # @param id_above [String, Integer, nil] The identification ID must be above the provided value
83
+ # @param only_id [Boolean, nil] Only return record IDs
84
+ #
85
+ # @param order [String, nil] Ascending or descending sort order (asc, desc)
86
+ # @param order_by [String, nil] The parameter to sort by (created_at, id)
87
+ # @param page [Integer, nil] The results page number
88
+ # @param per_page [Integer, nil] The results limit
89
+ # @param verbose [Boolean] Print headers to STDOUT
90
+ #
91
+ # @return [Hash, Boolean] A hash of identification results
92
+ def self.identifications(id: nil, current_taxon: nil, own_observation: nil, is_change: nil,
93
+ taxon_active: nil, observation_taxon_active: nil, rank: nil, observation_rank: nil,
94
+ user_id: nil, user_login: nil, current: nil, category: nil, place_id: nil,
95
+ quality_grade: nil, taxon_id: nil, observation_taxon_id: nil, iconic_taxon_id: nil,
96
+ observation_iconic_taxon_id: nil, rank_lowest: nil, rank_highest: nil,
97
+ observation_rank_lowest: nil, observation_rank_highest: nil, without_taxon_id: nil,
98
+ without_observation_taxon_id: nil, before: nil, after: nil,
99
+ observation_created_before: nil, observation_created_after: nil, observed_before: nil,
100
+ observed_after: nil, id_below: nil, id_above: nil, only_id: nil, order: nil, order_by: nil,
101
+ page: nil, per_page: nil, verbose: false)
102
+ endpoint = 'identifications'
103
+ Request.new(endpoint: endpoint,
104
+ id: id,
105
+ current_taxon: current_taxon,
106
+ own_observation: own_observation,
107
+ is_change: is_change,
108
+ taxon_active: taxon_active,
109
+ observation_taxon_active: observation_taxon_active,
110
+ rank: rank,
111
+ observation_rank: observation_rank,
112
+ user_id: user_id,
113
+ user_login: user_login,
114
+ current: current,
115
+ category: category,
116
+ place_id: place_id,
117
+ quality_grade: quality_grade,
118
+ taxon_id: taxon_id,
119
+ observation_taxon_id: observation_taxon_id,
120
+ iconic_taxon_id: iconic_taxon_id,
121
+ observation_iconic_taxon_id: observation_iconic_taxon_id,
122
+ rank_lowest: rank_lowest,
123
+ rank_highest: rank_highest,
124
+ observation_rank_lowest: observation_rank_lowest,
125
+ observation_rank_highest: observation_rank_highest,
126
+ without_taxon_id: without_taxon_id,
127
+ without_observation_taxon_id: without_observation_taxon_id,
128
+ before: before,
129
+ after: after,
130
+ observation_created_before: observation_created_before,
131
+ observation_created_after: observation_created_after,
132
+ observed_before: observed_before,
133
+ observed_after: observed_after,
134
+ id_below: id_below,
135
+ id_above: id_above,
136
+ only_id: only_id,
137
+ order: order,
138
+ order_by: order_by,
139
+ page: page,
140
+ per_page: per_page,
141
+ verbose: verbose).perform
142
+ end
143
+
144
+ # Get map tiling assets for observations
145
+ #
146
+ # Mapping-specific parameters:
147
+ # @param asset_type [String] The type of asset to return [colored_heatmap, grid, heatmap, points, places, taxon_places, taxon_ranges]
148
+ # @param return_json [Boolean] Whether to return UTFGRid (only use with asset_types: colored_heatmap, grid, heatmap, points)
149
+ # @param color [String, nil] A color to use in map creation (e.g., blue, #0000ff)
150
+ # @param style [String, nil] The map tile style (geotilegrid, possibly others)
151
+ # @param tile_size [Integer, nil] The map tile size in pixels
152
+ #
153
+ # All of the parameters for filtering observations are also available:
154
+ # @param q [String, nil] An observation properties search query
155
+ # @param search_on [String, nil] Observation properties to search on (names, tags, description, place)
156
+ # @param id [String, Integer, nil] A comma-separated list of observation IDs
157
+ # @param not_id [String, Integer, nil] A comma-separated list of observation IDs that must not be included
158
+ # @param acc [Boolean, nil] Filter by whether the positional accuracy/coordinate uncertainty was specified
159
+ # @param captive [Boolean, nil] Filter on whether it was captive/cultivated observations
160
+ # @param endemic [Boolean, nil] Filter on whether observations were of taxa endemic to their location
161
+ # @param geo [Boolean, nil] Filter to only georeferenced observations
162
+ # @param identified [Boolean, nil] Filter to only observations with community identifications
163
+ # @param introduced [Boolean, nil] Filter to observations of taxa that were introduced to their location
164
+ # @param mappable [Boolean, nil] Filter to only observations that show on map tiles
165
+ # @param native [Boolean, nil] Filter to only observations of taxa native tot heir location
166
+ # @param out_of_range [Boolean, nil] Filter to only observations made in locations outside the taxon's known ranges
167
+ # @param pcid [Boolean, nil] Filter to observations identified by a curator of a project
168
+ # @param photos [Boolean, nil] Filter to observations with photos
169
+ # @param popular [Boolean, nil] Filter to only observations that have been favorited by at least 1 user
170
+ # @param sounds [Boolean, nil] Filter to observations with sounds
171
+ # @param taxon_is_active [Boolean, nil] Filter to observations of active taxon concepts
172
+ # @param threatened [Boolean, nil] Filter to observations of taxa that are threatened at their location
173
+ # @param verifiable [Boolean, nil] Filter by observations with a quality_grade=needs_id,research
174
+ # @param licensed [Boolean, nil] Filter by observations with a license
175
+ # @param photo_licensed [Boolean, nil] License attribute of at least one photo in an observation must not be nil
176
+ # @param license [String, nil] Filter by a comma-separated list of licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)
177
+ # @param photo_license [String, nil] Filter by a comma-separated list of photo licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)
178
+ # @param sound_license [String, nil] Filter by a comma-separated list of sound licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)
179
+ # @param ofv_datatype [String, nil] Filter by a comma-separated list of datatypes that the observation must include # TODO: does it take arrays?
180
+ # @param place_id [String, Integer, nil] Filter by a comma-separated list of place_ids
181
+ # @param project_id [String, Integer, nil] Filter by a comma-separated list of project_ids
182
+ # @param rank [String, nil] Filter by an array of taxon ranks
183
+ # @param site_id [String, Integer, nil] Filter by a comma-separated list of site_ids
184
+ # @param taxon_id [String, Integer, nil] Filter by a comma-separated list of taxon_ids and their descendants
185
+ # @param without_taxon_id [String, Integer, nil] Exclude a comma-separated list of taxon_ids and their descendants
186
+ # @param taxon_name [String, Integer, nil] Filter by a comma-separated list of scientific or common names
187
+ # @param user_id [String, Integer nil] Filter by observations made by a comma-separated list of user_ids
188
+ # @param user_login [String, nil] Filter by a comma-separated list of user_logins
189
+ # @param ident_user_id [String, Integer, nil] Filter by observations identified by a particular user_id
190
+ # @param day [String, Integer, nil] Filter on a comma-separated list of days
191
+ # @param month [String, Integer, nil] Filter on a comma-separated list of months
192
+ # @param year [String, Integer, nil] Filter on a comma-separated list of years
193
+ # @param term_id [String, Integer, nil] Filter on a comma-separated list of term_ids
194
+ # @param without_term_id String, Integer, nil] Exclude on a comma-separated list of term_ids
195
+ # @param term_value_id [String, Integer, nil] Filter on annotations made with this controlled value ID; must be used with term_id
196
+ # @param without_term_value_id [String, Integer, nil] Exclude on annotations made with this controlled value ID
197
+ # @param acc_above [String, nil] Positional accuracy must be above value
198
+ # @param acc_below [String, nil] Positional accuracy must be below value
199
+ # @param acc_below_or_unknown [String, nil] Positional accuracy must be below value or unknown
200
+ # @param before [String, nil] Must have been observed on or before this date (d2)
201
+ # @param after [String, nil] Must have been observed on or after this date (d1)
202
+ # @param observed_on [String, nil] Must have been observed on this date
203
+ # @param created_before [String, nil] Must have been created on or before this date (created_d2)
204
+ # @param created_on [String, nil] Must have been created on this date
205
+ # @param created_after [String, nil] Must have been created on or before this date (created_d1)
206
+ # @param unobserved_by_user_id [String, nil] Taxon must be unobserved by the provided user_id
207
+ # @param apply_project_rules_for [String, nil] Must match rules of the provided project_id
208
+ # @param conservation_status [String, nil] Taxon must have this conservation status (cs) code, use with place_id to make location-specific
209
+ # @param conservation_status_authority [String, nil] Taxon must have the conservation status from the provided authority (csa), use with place_id to make location-specific
210
+ # @param conservation_status_iucn [String, nil] Taxon must have the provided conservation status from the IUCN, use with place_id to make location-specific
211
+ # @param geoprivacy [String, nil] Filter by a comma-separated list of geoprivacy settings (obscured, obscured_private, open)
212
+ # @param taxon_geoprivacy [String, nil] Filter by a comma-separated list of geoprivacy settings (obscured, obscured_private, open) of the most conservative geoprivacy associated with one of the taxa proposed in the current identifications
213
+ # @param rank_lowest [String, nil] Taxon rank must be less than or equal to provided rank
214
+ # @param rank_highest [String, nil] Taxon rank must be greater than or equal to provided rank
215
+ # @param iconic_taxa [String, nil] Filter by taxa with the provided iconic taxon (Actinopterygii, Animalia, Amphibia, Arachnida, Aves, Chromista, Fungi, Insecta, Mammalia, Mollusca, Repitilia, Plantae, Protozoa, unknown)
216
+ # @param id_below [String, Integer, nil] Most have an observation ID below the provided value
217
+ # @param id_above [String, Integer, nil] Most have an observation ID above the provided value
218
+ # @param identifications [String, nil] Filter by identifications status (most_agree, some_agree, most_disagree)
219
+ # @param latitude [Double, nil] Filter by observations within a {radius} kilometer circle around the provided latitude coordinate (lat)
220
+ # @param longitude [Double, nil] Filter by observations within a {radius} kilometer circle around the provided longitude coordinate (lng)
221
+ # @param radius [String, Integer, Double] Filter by observations within the provided radius in kilometers
222
+ # @param ne_latitude [Double, nil] Filter by observations within provided (nelat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
223
+ # @param ne_longitude [Double, nil] Filter by observations within provided (nelng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
224
+ # @param sw_latitude [Double, nil] Filter by observations within provided (swlat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
225
+ # @param sw_longitude [Double, nil] Filter by observations within provided (swlng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
226
+ # @param list_id [Integer, nil] Taxon must bin the list with the provided ID
227
+ # @param not_in_project [String, nil] Observation must not be in the provided project_id or slug
228
+ # @param not_matching_project_rules_for [String, nil] Must not match the rules of the provided project_id or slug
229
+ # @param quality_grade [String, nil] Filter by observation quality grade (casual, needs_id, research)
230
+ # @param updated_since [String, nil] Filter by observations updated since the provided time
231
+ # @param reviewed [Boolean, nil] Observations have been reviewed by viewer_id
232
+ # @param viewer_id [String, nil] Use with reviewed boolean to filter by observations reviewed by the provided viewer_id
233
+ # @param locale [String, nil] Locale preference for taxon common names (e.g., en-US)
234
+ # @param preferred_place_id [Integer, nil] Place of preference for regional taxon common names
235
+ # @param ttl [String, Integer, nil] Set the Cache-Control HTTP header with a max-age value to cache the request on iNaturalist serers and within the client
236
+ # @param only_id [Boolean, nil] Only return record IDs
237
+ #
238
+ # @return [Binary, Hash] Returns binary png images of map tiles unless return_json is true
239
+ def self.mapping(asset_type, zoom_level, x, y, return_json: false, color: nil, style: nil, tile_size: nil,
240
+ q: nil, search_on: nil, id: nil, not_id: nil, acc: nil, captive: nil,
241
+ endemic: nil, geo: nil, identified: nil, introduced: nil, mappable: nil, native: nil,
242
+ out_of_range: nil, pcid: nil, photos: nil, popular: nil, sounds: nil, taxon_is_active: nil,
243
+ threatened: nil, verifiable: nil, licensed: nil, photo_licensed: nil,
244
+ photo_license: nil, sound_license: nil, ofv_datatype: nil, place_id: nil, project_id: nil,
245
+ rank: nil, site_id: nil, taxon_id: nil, without_taxon_id: nil, taxon_name: nil, user_id: nil,
246
+ user_login: nil, ident_user_id: nil, day: nil, month: nil, year: nil, term_id: nil,
247
+ without_term_id: nil, term_value_id: nil, without_term_value_id: nil, acc_below: nil,
248
+ acc_below_or_unknown: nil, acc_above: nil, before: nil, observed_on: nil,
249
+ after: nil, created_before: nil, created_on: nil, created_after: nil,
250
+ unobserved_by_user_id: nil, apply_project_rules_for: nil, conservation_status: nil,
251
+ conservation_status_authority: nil, conservation_status_iucn: nil, geoprivacy: nil,
252
+ taxon_geoprivacy: nil, rank_lowest: nil, rank_highest: nil, iconic_taxa: nil,
253
+ id_below: nil, id_above: nil, identifications: nil, latitude: nil, longitude: nil,
254
+ radius: nil, ne_latitude: nil, ne_longitude: nil, sw_latitude: nil, sw_longitude: nil,
255
+ list_id: nil, not_in_project: nil, not_matching_project_rules_for: nil, quality_grade: nil,
256
+ updated_since: nil, viewer_id: nil, reviewed: nil, locale: nil, preferred_place_id: nil,
257
+ only_id: nil, ttl: nil, order: nil, order_by: nil, page: nil, per_page: nil, headers: false,
258
+ verbose: false)
259
+
260
+ if !color.nil? and color.include? '#'
261
+ color = color.gsub('#', '%23')
262
+ end
263
+
264
+ endpoint = ''
265
+ if ['colored_heatmap', 'grid', 'heatmap', 'points'].include? asset_type
266
+ if return_json
267
+ endpoint = "#{asset_type}/#{zoom_level}/#{x}/#{y}.grid.json"
268
+ else
269
+ endpoint = "#{asset_type}/#{zoom_level}/#{x}/#{y}.png"
270
+ end
271
+ elsif asset_type == 'places'
272
+ endpoint = "places/#{place_id}/#{zoom_level}/#{x}/#{y}.png"
273
+ if place_id.nil?
274
+ raise "place_id must be provided"
275
+ end
276
+ elsif asset_type == 'taxon_places'
277
+ endpoint = "taxon_places/#{taxon_id}/#{zoom_level}/#{x}/#{y}.png"
278
+ if taxon_id.nil?
279
+ raise "taxon_id must be provided"
280
+ end
281
+ elsif asset_type == 'taxon_ranges'
282
+ endpoint = "taxon_ranges/#{taxon_id}/#{zoom_level}/#{x}/#{y}.png"
283
+ if taxon_id.nil?
284
+ raise "taxon_id must be provided"
285
+ end
286
+ else
287
+ raise "Invalid asset_type: #{asset_type} (must be one of: colored_heatmap, grid, heatmap, points, places, taxon_places, taxon_ranges)"
288
+ end
289
+
290
+ Request.new(endpoint: endpoint,
291
+ color: color,
292
+ style: style,
293
+ tile_size: tile_size,
294
+ q: q,
295
+ search_on: search_on,
296
+ id: id,
297
+ not_id: not_id,
298
+ acc: acc,
299
+ captive: captive,
300
+ endemic: endemic,
301
+ geo: geo,
302
+ identified: identified,
303
+ introduced: introduced,
304
+ mappable: mappable,
305
+ native: native,
306
+ out_of_range: out_of_range,
307
+ pcid: pcid,
308
+ photos: photos,
309
+ popular: popular,
310
+ sounds: sounds,
311
+ taxon_is_active: taxon_is_active,
312
+ threatened: threatened,
313
+ verifiable: verifiable,
314
+ licensed: licensed,
315
+ photo_licensed: photo_licensed,
316
+ photo_license: photo_license,
317
+ sound_license: sound_license,
318
+ ofv_datatype: ofv_datatype,
319
+ place_id: place_id,
320
+ project_id: project_id,
321
+ rank: rank,
322
+ site_id: site_id,
323
+ taxon_id: taxon_id,
324
+ without_taxon_id: without_taxon_id,
325
+ taxon_name: taxon_name,
326
+ user_id: user_id,
327
+ user_login: user_login,
328
+ ident_user_id: ident_user_id,
329
+ day: day,
330
+ month: month,
331
+ year: year,
332
+ term_id: term_id,
333
+ without_term_id: without_term_id,
334
+ term_value_id: term_value_id,
335
+ without_term_value_id: without_term_value_id,
336
+ acc_below: acc_below,
337
+ acc_below_or_unknown: acc_below_or_unknown,
338
+ acc_above: acc_above,
339
+ before: before,
340
+ observed_on: observed_on,
341
+ after: after,
342
+ created_before: created_before,
343
+ created_on: created_on,
344
+ created_after: created_after,
345
+ unobserved_by_user_id: unobserved_by_user_id,
346
+ apply_project_rules_for: apply_project_rules_for,
347
+ conservation_status: conservation_status,
348
+ conservation_status_authority: conservation_status_authority,
349
+ conservation_status_iucn: conservation_status_iucn,
350
+ geoprivacy: geoprivacy,
351
+ taxon_geoprivacy: taxon_geoprivacy,
352
+ rank_lowest: rank_lowest,
353
+ rank_highest: rank_highest,
354
+ iconic_taxa: iconic_taxa,
355
+ id_below: id_below,
356
+ id_above: id_above,
357
+ identifications: identifications,
358
+ latitude: latitude,
359
+ longitude: longitude,
360
+ radius: radius,
361
+ ne_latitude: ne_latitude,
362
+ ne_longitude: ne_longitude,
363
+ sw_latitude: sw_latitude,
364
+ sw_longitude: sw_longitude,
365
+ list_id: list_id,
366
+ not_in_project: not_in_project,
367
+ not_matching_project_rules_for: not_matching_project_rules_for,
368
+ quality_grade: quality_grade,
369
+ updated_since: updated_since,
370
+ viewer_id: viewer_id,
371
+ reviewed: reviewed,
372
+ locale: locale,
373
+ preferred_place_id: preferred_place_id,
374
+ only_id: only_id,
375
+ ttl: ttl,
376
+ order: order,
377
+ order_by: order_by,
378
+ page: page,
379
+ per_page: per_page,
380
+ headers: headers,
381
+ verbose: verbose).perform
382
+ end
383
+
384
+
385
+ # Get places
386
+ # @param id [String, Integer] A comma-separated list of place IDs
387
+ # @param admin_level [String, Integer, nil] A comma-separated list of admin levels (-10: continent, 0: country, 10: state, 20: county, 30: town, 100: park)
388
+ #
389
+ # @return [Hash, Boolean] A hash with places results
390
+ def self.places_id(id, admin_level: nil, verbose: false)
391
+ endpoint = "places/#{id}"
392
+ Request.new(endpoint: endpoint, admin_level: admin_level, verbose: verbose).perform
393
+ end
394
+
395
+ # Suggest places
396
+ # @param q [String] A place name must start with this query
397
+ #
398
+ # @param order_by [String, nil] The parameter to sort by (area) # TODO: iNaturalist bug? doesn't seem to affect sorting in the API?
399
+ # @param per_page [Integer, nil] The results limit
400
+ # @param verbose [Boolean] Print headers to STDOUT
401
+ #
402
+ # @return [Hash, Boolean] A hash with suggest places results
403
+ def self.places_autocomplete(q, order_by: nil, per_page: nil, verbose: false)
404
+ endpoint = "places/autocomplete"
405
+ Request.new(endpoint: endpoint, q: q, order_by: order_by, per_page: per_page, verbose: verbose).perform
406
+ end
407
+
408
+ # https://api.inaturalist.org/v1/places/nearby?nelat=40.346036&nelng=-87.951568&swlat=39.935393&swlng=-88.628846
409
+ # Get nearby places
410
+ # @param ne_latitude [Double, nil] Get nearby places within provided (nelat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
411
+ # @param ne_longitude [Double, nil] Get nearby places within provided (nelng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
412
+ # @param sw_latitude [Double, nil] Get nearby places within provided (swlat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
413
+ # @param sw_longitude [Double, nil] Get nearby places within provided (swlng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
414
+ # @param name [String, nil] Place name must match this value # TODO: iNaturalist bug? you can't provide the last word of a name (e.g., River Bend Forest works, but River Bend Forest Preserve doesn't work)
415
+ #
416
+ # @param per_page [Integer, nil] The results limit
417
+ # @param verbose [Boolean] Print headers to STDOUT
418
+ #
419
+ # @return [Hash, Boolean] A hash with suggest places results
420
+ def self.places_nearby(ne_latitude, ne_longitude, sw_latitude, sw_longitude, name: nil, verbose: false)
421
+ endpoint = "places/nearby"
422
+ Request.new(endpoint: endpoint, ne_latitude: ne_latitude, ne_longitude: ne_longitude, sw_latitude: sw_latitude, sw_longitude: sw_longitude, name: name, verbose: verbose).perform
423
+ end
424
+
425
+
426
+ # Get journal posts
427
+ # @param login [String, nil] Filter by user login
428
+ # @param project_id [String, Integer, nil] Filter by project ID
429
+ # @param parent_id [String, Integer, nil] Filter by parent ID
430
+ #
431
+ # @param page [String, Integer, nil]
432
+ # @param per_page [String, Integer, nil]
433
+ # @param verbose [Boolean] Print headers to STDOUT
434
+ #
435
+ # @return [Array, Boolean] An array of journal posts
436
+ def self.posts(login: nil, project_id: nil, parent_id: nil, page: nil, per_page: nil, verbose: false)
437
+ endpoint = "posts"
438
+ Request.new(endpoint: endpoint, login: login, project_id: project_id, parent_id: parent_id, page: page, per_page: per_page, verbose: verbose).perform
439
+ end
440
+
441
+ # TODO: Add tests
442
+ # Get projects
443
+ # @param q [String, nil] Project name must begin with query string
444
+ # @param autocomplete [Boolean, nil] Returns projects that start with the search q
445
+ # @param id [String, Integer, nil] Project must have this ID
446
+ # @param not_id [String, Integer, nil] Project must not have this ID
447
+ # @param latitude [Double, nil] Filter by projects within a {radius} kilometer circle around the provided latitude coordinate (lat)
448
+ # @param longitude [Double, nil] Filter by projects within a {radius} kilometer circle around the provided longitude coordinate (lng)
449
+ # @param radius [String, Integer, Double] Filter by projects within the provided radius in kilometers
450
+ # @param place_id [String, Integer, nil] Filter by a comma-separated list of place_ids
451
+ # @param featured [Boolean, nil] Filter by marked featured for the relevant site
452
+ # @param noteworthy [Boolean, nil] Filter by marked noteworthy for the relevant site
453
+ # @param site_id [String, Integer, nil] The site ID that applies to featured and noteworthy, defaults to site of the authenticated user or the main iNaturalist site
454
+ # @param rule_details [Boolean, nil] Return more details about the project rules
455
+ # @param type [String, nil] Filter by project type [collection, umbrella]
456
+ # @param member_id [String, Integer, nil] Filter by projects that include a user ID
457
+ # @param has_params [Boolean, nil] Must have search parameter requirements
458
+ # @param has_posts [Boolean, nil] Project must have posts
459
+ #
460
+ # @param page [Integer, nil] The results page number
461
+ # @param per_page [Integer, nil] The results limit
462
+ # @param order_by [String, nil] The parameter to sort by (observed_on, species_guess, votes, id, created_at)
463
+ # @param verbose [Boolean] Print headers to STDOUT
464
+ #
465
+ # @return [Hash, Boolean] A hash with search results
466
+ def self.projects(q: nil, autocomplete: nil, id: nil, not_id: nil, latitude: nil, longitude: nil, radius: nil, place_id: nil, featured: nil, noteworthy: nil, site_id: nil, rule_details: nil, type: nil, member_id: nil, has_params: nil, has_posts: nil, page: nil, per_page: nil, order_by: nil, verbose: false)
467
+ if autocomplete
468
+ endpoint = "projects/autocomplete"
469
+ else
470
+ endpoint = "projects"
471
+ end
472
+ Request.new(endpoint: endpoint, q: q, id: id, not_id: not_id, latitude: latitude, longitude: longitude, radius: radius, place_id: place_id, featured: featured, noteworthy: noteworthy, site_id: site_id, rule_details: rule_details, type: type, member_id: member_id, has_params: has_params, has_posts: has_posts, page: page, per_page: per_page, order_by: order_by, verbose: verbose).perform
473
+ end
474
+
475
+ # Get project members
476
+ # @param id [String, Integer] The project ID
477
+ #
478
+ # @param page [Integer, nil] The results page number
479
+ # @param per_page [Integer, nil] The results limit
480
+ # @param verbose [Boolean] Print headers to STDOUT
481
+ #
482
+ # @return [Hash, Boolean] A hash with search results
483
+ def self.project_members(id, page: nil, per_page: nil, verbose: false)
484
+ endpoint = "projects/#{id}/members"
485
+ Request.new(endpoint: endpoint, page: page, per_page: per_page, verbose: verbose).perform
486
+ end
487
+
488
+ # Search places, projects, taxa, users
489
+ # @param q [String, nil] A search query
490
+ # @param sources [String, nil] Type of record to search (places, projects, taxa, users)
491
+ # @param place_id [String, nil] Filter to an array of place_ids (TODO: place_id is an array in the documentation but doesn't seem to work even with their example?)
492
+ # @param preferred_place_id [Integer, nil] Place of preference for regional taxon common names
493
+ # @param locale [String, nil] Locale preference for taxon common names (e.g., en-US)
494
+ #
495
+ # @param page [Integer, nil] The results page number
496
+ # @param per_page [Integer, nil] The results limit
497
+ # @param verbose [Boolean] Print headers to STDOUT
498
+ #
499
+ # @return [Hash, Boolean] A hash with search results
500
+ def self.search(q: nil, sources: nil, place_id: nil, preferred_place_id: nil, locale: nil, page: nil, per_page: nil,
501
+ verbose: false)
502
+ endpoint = 'search'
503
+ Request.new(
504
+ endpoint: endpoint,
505
+ q: q,
506
+ sources: sources,
507
+ place_id: place_id,
508
+ preferred_place_id: preferred_place_id,
509
+ locale: locale,
510
+ page: page,
511
+ per_page: per_page,
512
+ verbose: verbose
513
+ ).perform
514
+ end
515
+
516
+ # Get user
517
+ # @param id [Integer] The user ID
518
+ #
519
+ # @param verbose [Boolean] Print headers to STDOUT
520
+ #
521
+ # @return [Hash, Boolean] A hash with user results
522
+ def self.user(id, verbose: false)
523
+ endpoint = "users/#{id}"
524
+ Request.new(endpoint: endpoint, verbose: verbose).perform
525
+ end
526
+
527
+ # Get logged in user
528
+ # @param id [Integer] The user ID
529
+ #
530
+ # @param verbose [Boolean] Print headers to STDOUT
531
+ #
532
+ # @return [Hash, Boolean] A hash with user results
533
+ def self.user_me(verbose: false)
534
+ endpoint = "users/me"
535
+ Request.new(endpoint: endpoint, verbose: verbose).perform
536
+ end
537
+
538
+ # Get user's projects
539
+ # @param id [Integer] The user ID
540
+ # @param rule_details [Boolean, nil] Return more details about project rules
541
+ # @param project_type [String, nil] Filter by project type (collection, contest, traditional, umbrella)
542
+ #
543
+ # @param page [Integer, nil] The results page number
544
+ # @param per_page [Integer, nil] The results limit
545
+ # @param verbose [Boolean] Print headers to STDOUT
546
+ #
547
+ # @return [Hash, Boolean] A hash with user results
548
+ def self.user_projects(id, rule_details: nil, project_type: nil, page: nil, per_page: nil, verbose: false)
549
+ endpoint = "users/#{id}/projects"
550
+ Request.new(endpoint: endpoint, rule_details: rule_details, project_type: project_type,
551
+ page: page, per_page: per_page, verbose: verbose).perform
552
+ end
553
+
554
+ # Get user suggestions
555
+ # @param q [String] The username must begin with this query
556
+ # @param project_id [Integer, nil] Only show members of this project ID
557
+ #
558
+ # @param per_page [Integer, nil] The results limit
559
+ # @param verbose [Boolean] Print headers to STDOUT
560
+ #
561
+ # @return [Hash, Boolean] A hash with user results
562
+ def self.user_autocomplete(q, project_id: nil, per_page: nil, verbose: false)
563
+ endpoint = "users/autocomplete"
564
+ Request.new(endpoint: endpoint, q: q, project_id: project_id, per_page: per_page, verbose: verbose).perform
565
+ end
566
+
567
+ # TODO: iNatualist API documentation does not include sound_license?
568
+
569
+ # Get observations
570
+ #
571
+ # Note: use the subresource parameter to access these subresource endpoints which share the same parameters as /observations:
572
+ # /observations/histogram
573
+ # /observations/identifiers
574
+ # /observations/observers
575
+ # /observations/popular_field_values
576
+ # /observations/species_counts
577
+ #
578
+ # @param subresource [String, nil] Access a subresource endpoint of observations (histogram, identifiers, observers, popular_field_values, species_counts)
579
+ #
580
+ # @param q [String, nil] An observation properties search query
581
+ # @param search_on [String, nil] Observation properties to search on (names, tags, description, place)
582
+ # @param id [String, Integer, nil] A comma-separated list of observation IDs
583
+ # @param not_id [String, Integer, nil] A comma-separated list of observation IDs that must not be included
584
+ # @param acc [Boolean, nil] Filter by whether the positional accuracy/coordinate uncertainty was specified
585
+ # @param captive [Boolean, nil] Filter on whether it was captive/cultivated observations
586
+ # @param endemic [Boolean, nil] Filter on whether observations were of taxa endemic to their location
587
+ # @param geo [Boolean, nil] Filter to only georeferenced observations
588
+ # @param identified [Boolean, nil] Filter to only observations with community identifications
589
+ # @param introduced [Boolean, nil] Filter to observations of taxa that were introduced to their location
590
+ # @param mappable [Boolean, nil] Filter to only observations that show on map tiles
591
+ # @param native [Boolean, nil] Filter to only observations of taxa native tot heir location
592
+ # @param out_of_range [Boolean, nil] Filter to only observations made in locations outside the taxon's known ranges
593
+ # @param pcid [Boolean, nil] Filter to observations identified by a curator of a project
594
+ # @param photos [Boolean, nil] Filter to observations with photos
595
+ # @param popular [Boolean, nil] Filter to only observations that have been favorited by at least 1 user
596
+ # @param sounds [Boolean, nil] Filter to observations with sounds
597
+ # @param taxon_is_active [Boolean, nil] Filter to observations of active taxon concepts
598
+ # @param threatened [Boolean, nil] Filter to observations of taxa that are threatened at their location
599
+ # @param verifiable [Boolean, nil] Filter by observations with a quality_grade=needs_id,research
600
+ # @param licensed [Boolean, nil] Filter by observations with a license
601
+ # @param photo_licensed [Boolean, nil] License attribute of at least one photo in an observation must not be nil
602
+ # @param license [String, nil] Filter by a comma-separated list of licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)
603
+ # @param photo_license [String, nil] Filter by a comma-separated list of photo licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)
604
+ # @param sound_license [String, nil] Filter by a comma-separated list of sound licenses (cc-by,cc-by-nc,cc-by-nd,cc-by-sa,cc-by-nc-nd,cc-by-nc-sa,cc0)
605
+ # @param ofv_datatype [String, nil] Filter by a comma-separated list of datatypes that the observation must include # TODO: does it take arrays?
606
+ # @param place_id [String, Integer, nil] Filter by a comma-separated list of place_ids
607
+ # @param project_id [String, Integer, nil] Filter by a comma-separated list of project_ids
608
+ # @param rank [String, nil] Filter by an array of taxon ranks
609
+ # @param site_id [String, Integer, nil] Filter by a comma-separated list of site_ids
610
+ # @param taxon_id [String, Integer, nil] Filter by a comma-separated list of taxon_ids and their descendants
611
+ # @param without_taxon_id [String, Integer, nil] Exclude a comma-separated list of taxon_ids and their descendants
612
+ # @param taxon_name [String, Integer, nil] Filter by a comma-separated list of scientific or common names
613
+ # @param user_id [String, Integer nil] Filter by observations made by a comma-separated list of user_ids
614
+ # @param user_login [String, nil] Filter by a comma-separated list of user_logins
615
+ # @param ident_user_id [String, Integer, nil] Filter by observations identified by a particular user_id
616
+ # @param day [String, Integer, nil] Filter on a comma-separated list of days
617
+ # @param month [String, Integer, nil] Filter on a comma-separated list of months
618
+ # @param year [String, Integer, nil] Filter on a comma-separated list of years
619
+ # @param term_id [String, Integer, nil] Filter on a comma-separated list of term_ids
620
+ # @param without_term_id String, Integer, nil] Exclude on a comma-separated list of term_ids
621
+ # @param term_value_id [String, Integer, nil] Filter on annotations made with this controlled value ID; must be used with term_id
622
+ # @param without_term_value_id [String, Integer, nil] Exclude on annotations made with this controlled value ID
623
+ # @param acc_above [String, nil] Positional accuracy must be above value
624
+ # @param acc_below [String, nil] Positional accuracy must be below value
625
+ # @param acc_below_or_unknown [String, nil] Positional accuracy must be below value or unknown
626
+ # @param before [String, nil] Must have been observed on or before this date (d2)
627
+ # @param after [String, nil] Must have been observed on or after this date (d1)
628
+ # @param observed_on [String, nil] Must have been observed on this date
629
+ # @param created_before [String, nil] Must have been created on or before this date (created_d2)
630
+ # @param created_on [String, nil] Must have been created on this date
631
+ # @param created_after [String, nil] Must have been created on or before this date (created_d1)
632
+ # @param unobserved_by_user_id [String, nil] Taxon must be unobserved by the provided user_id
633
+ # @param apply_project_rules_for [String, nil] Must match rules of the provided project_id
634
+ # @param conservation_status [String, nil] Taxon must have this conservation status (cs) code, use with place_id to make location-specific
635
+ # @param conservation_status_authority [String, nil] Taxon must have the conservation status from the provided authority (csa), use with place_id to make location-specific
636
+ # @param conservation_status_iucn [String, nil] Taxon must have the provided conservation status from the IUCN, use with place_id to make location-specific
637
+ # @param geoprivacy [String, nil] Filter by a comma-separated list of geoprivacy settings (obscured, obscured_private, open)
638
+ # @param taxon_geoprivacy [String, nil] Filter by a comma-separated list of geoprivacy settings (obscured, obscured_private, open) of the most conservative geoprivacy associated with one of the taxa proposed in the current identifications
639
+ # @param rank_lowest [String, nil] Taxon rank must be less than or equal to provided rank
640
+ # @param rank_highest [String, nil] Taxon rank must be greater than or equal to provided rank
641
+ # @param iconic_taxa [String, nil] Filter by taxa with the provided iconic taxon (Actinopterygii, Animalia, Amphibia, Arachnida, Aves, Chromista, Fungi, Insecta, Mammalia, Mollusca, Repitilia, Plantae, Protozoa, unknown)
642
+ # @param id_below [String, Integer, nil] Most have an observation ID below the provided value
643
+ # @param id_above [String, Integer, nil] Most have an observation ID above the provided value
644
+ # @param identifications [String, nil] Filter by identifications status (most_agree, some_agree, most_disagree)
645
+ # @param latitude [Double, nil] Filter by observations within a {radius} kilometer circle around the provided latitude coordinate (lat)
646
+ # @param longitude [Double, nil] Filter by observations within a {radius} kilometer circle around the provided longitude coordinate (lng)
647
+ # @param radius [String, Integer, Double] Filter by observations within the provided radius in kilometers
648
+ # @param ne_latitude [Double, nil] Filter by observations within provided (nelat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
649
+ # @param ne_longitude [Double, nil] Filter by observations within provided (nelng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
650
+ # @param sw_latitude [Double, nil] Filter by observations within provided (swlat) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
651
+ # @param sw_longitude [Double, nil] Filter by observations within provided (swlng) bounding box (ne_latitude, ne_longitude, sw_latitude, sw_longitude)
652
+ # @param list_id [Integer, nil] Taxon must bin the list with the provided ID
653
+ # @param not_in_project [String, nil] Observation must not be in the provided project_id or slug
654
+ # @param not_matching_project_rules_for [String, nil] Must not match the rules of the provided project_id or slug
655
+ # @param quality_grade [String, nil] Filter by observation quality grade (casual, needs_id, research)
656
+ # @param updated_since [String, nil] Filter by observations updated since the provided time
657
+ # @param reviewed [Boolean, nil] Observations have been reviewed by viewer_id
658
+ # @param viewer_id [String, nil] Use with reviewed boolean to filter by observations reviewed by the provided viewer_id
659
+ # @param locale [String, nil] Locale preference for taxon common names (e.g., en-US)
660
+ # @param preferred_place_id [Integer, nil] Place of preference for regional taxon common names
661
+ # @param ttl [String, Integer, nil] Set the Cache-Control HTTP header with a max-age value to cache the request on iNaturalist serers and within the client
662
+ # @param only_id [Boolean, nil] Only return record IDs
663
+ #
664
+ # @param order [String, nil] Ascending or descending sort order (asc, desc)
665
+ # @param order_by [String, nil] The parameter to sort by (observed_on, species_guess, votes, id, created_at)
666
+ # @param page [Integer, nil] The results page number
667
+ # @param per_page [Integer, nil] The results limit
668
+ # @param headers [Boolean] Return headers instead of body
669
+ # @param verbose [Boolean] Print headers to STDOUT
670
+ #
671
+ # @return [Hash, Boolean] A hash with observation results
672
+ def self.observations(subresource: nil, q: nil, search_on: nil, id: nil, not_id: nil, acc: nil, captive: nil,
673
+ endemic: nil, geo: nil, identified: nil, introduced: nil, mappable: nil, native: nil,
674
+ out_of_range: nil, pcid: nil, photos: nil, popular: nil, sounds: nil, taxon_is_active: nil,
675
+ threatened: nil, verifiable: nil, licensed: nil, photo_licensed: nil,
676
+ photo_license: nil, sound_license: nil, ofv_datatype: nil, place_id: nil, project_id: nil,
677
+ rank: nil, site_id: nil, taxon_id: nil, without_taxon_id: nil, taxon_name: nil, user_id: nil,
678
+ user_login: nil, ident_user_id: nil, day: nil, month: nil, year: nil, term_id: nil,
679
+ without_term_id: nil, term_value_id: nil, without_term_value_id: nil, acc_below: nil,
680
+ acc_below_or_unknown: nil, acc_above: nil, before: nil, observed_on: nil,
681
+ after: nil, created_before: nil, created_on: nil, created_after: nil,
682
+ unobserved_by_user_id: nil, apply_project_rules_for: nil, conservation_status: nil,
683
+ conservation_status_authority: nil, conservation_status_iucn: nil, geoprivacy: nil,
684
+ taxon_geoprivacy: nil, rank_lowest: nil, rank_highest: nil, iconic_taxa: nil,
685
+ id_below: nil, id_above: nil, identifications: nil, latitude: nil, longitude: nil,
686
+ radius: nil, ne_latitude: nil, ne_longitude: nil, sw_latitude: nil, sw_longitude: nil,
687
+ list_id: nil, not_in_project: nil, not_matching_project_rules_for: nil, quality_grade: nil,
688
+ updated_since: nil, viewer_id: nil, reviewed: nil, locale: nil, preferred_place_id: nil,
689
+ only_id: nil, ttl: nil, order: nil, order_by: nil, page: nil, per_page: nil, headers: false,
690
+ verbose: false)
691
+ endpoint = 'observations'
692
+ endpoint = "#{endpoint}/#{subresource}" unless subresource.nil?
693
+
694
+ Request.new(endpoint: endpoint,
695
+ q: q,
696
+ search_on: search_on,
697
+ id: id,
698
+ not_id: not_id,
699
+ acc: acc,
700
+ captive: captive,
701
+ endemic: endemic,
702
+ geo: geo,
703
+ identified: identified,
704
+ introduced: introduced,
705
+ mappable: mappable,
706
+ native: native,
707
+ out_of_range: out_of_range,
708
+ pcid: pcid,
709
+ photos: photos,
710
+ popular: popular,
711
+ sounds: sounds,
712
+ taxon_is_active: taxon_is_active,
713
+ threatened: threatened,
714
+ verifiable: verifiable,
715
+ licensed: licensed,
716
+ photo_licensed: photo_licensed,
717
+ photo_license: photo_license,
718
+ sound_license: sound_license,
719
+ ofv_datatype: ofv_datatype,
720
+ place_id: place_id,
721
+ project_id: project_id,
722
+ rank: rank,
723
+ site_id: site_id,
724
+ taxon_id: taxon_id,
725
+ without_taxon_id: without_taxon_id,
726
+ taxon_name: taxon_name,
727
+ user_id: user_id,
728
+ user_login: user_login,
729
+ ident_user_id: ident_user_id,
730
+ day: day,
731
+ month: month,
732
+ year: year,
733
+ term_id: term_id,
734
+ without_term_id: without_term_id,
735
+ term_value_id: term_value_id,
736
+ without_term_value_id: without_term_value_id,
737
+ acc_below: acc_below,
738
+ acc_below_or_unknown: acc_below_or_unknown,
739
+ acc_above: acc_above,
740
+ before: before,
741
+ observed_on: observed_on,
742
+ after: after,
743
+ created_before: created_before,
744
+ created_on: created_on,
745
+ created_after: created_after,
746
+ unobserved_by_user_id: unobserved_by_user_id,
747
+ apply_project_rules_for: apply_project_rules_for,
748
+ conservation_status: conservation_status,
749
+ conservation_status_authority: conservation_status_authority,
750
+ conservation_status_iucn: conservation_status_iucn,
751
+ geoprivacy: geoprivacy,
752
+ taxon_geoprivacy: taxon_geoprivacy,
753
+ rank_lowest: rank_lowest,
754
+ rank_highest: rank_highest,
755
+ iconic_taxa: iconic_taxa,
756
+ id_below: id_below,
757
+ id_above: id_above,
758
+ identifications: identifications,
759
+ latitude: latitude,
760
+ longitude: longitude,
761
+ radius: radius,
762
+ ne_latitude: ne_latitude,
763
+ ne_longitude: ne_longitude,
764
+ sw_latitude: sw_latitude,
765
+ sw_longitude: sw_longitude,
766
+ list_id: list_id,
767
+ not_in_project: not_in_project,
768
+ not_matching_project_rules_for: not_matching_project_rules_for,
769
+ quality_grade: quality_grade,
770
+ updated_since: updated_since,
771
+ viewer_id: viewer_id,
772
+ reviewed: reviewed,
773
+ locale: locale,
774
+ preferred_place_id: preferred_place_id,
775
+ only_id: only_id,
776
+ ttl: ttl,
777
+ order: order,
778
+ order_by: order_by,
779
+ page: page,
780
+ per_page: per_page,
781
+ headers: headers,
782
+ verbose: verbose).perform
783
+ end
784
+
785
+ # Taxon search
786
+ # @param id [String, Integer, nil] A taxon ID or comma-separated array of taxon IDs
787
+ # @param q [String, nil] A search query
788
+ # @param is_active [Boolean, nil] Filter to taxa with active taxon concepts
789
+ # @param taxon_id [String, Integer, nil] Filter by a comma-separated array of taxon_ids
790
+ # @param parent_id [Integer, nil] Filter by a taxon parent_id
791
+ # @param rank [String, nil] Filter by an array of taxon ranks
792
+ # @param rank_level [Integer, nil] Filter by taxon rank level (e.g., 70 for kingdom)
793
+ # @param id_above [Integer, nil] ID must be greater than value
794
+ # @param id_below [Integer, nil] ID must be below value
795
+ # @param preferred_place_id [Integer, nil] Place of preference for regional taxon common names
796
+ # @param locale [String, nil] Locale preference for taxon common names (e.g., en-US)
797
+ # @param only_id [Boolean, nil] Only return record IDs
798
+ # @param all_names [Boolean, nil] Include all taxon names in the response
799
+ #
800
+ # @param order [String, nil] Ascending or descending sort order (asc, desc)
801
+ # @param order_by [String, nil] The parameter to sort by
802
+ # @param page [Integer, nil] The results page number
803
+ # @param per_page [Integer, nil] The results limit
804
+ # @param verbose [Boolean] Print headers to STDOUT
805
+ #
806
+ # @return [Hash, Boolean] A hash with search results
807
+ def self.taxa(id: nil, q: nil, is_active: nil, taxon_id: nil, parent_id: nil, rank: nil, rank_level: nil,
808
+ id_above: nil, id_below: nil, locale: nil, only_id: nil, all_names: nil, preferred_place_id: nil,
809
+ order: nil, order_by: nil, page: nil, per_page: nil, verbose: false)
810
+ if id.nil?
811
+ endpoint = 'taxa'
812
+ Request.new(endpoint: endpoint, q: q, is_active: is_active, taxon_id: taxon_id, parent_id: parent_id, rank: rank,
813
+ rank_level: rank_level, id_above: id_above, id_below: id_below, locale: locale, only_id: only_id,
814
+ all_names: all_names, preferred_place_id: preferred_place_id, order: order, order_by: order_by,
815
+ page: page, per_page: per_page, verbose: verbose).perform
816
+ else
817
+ endpoint = "taxa/#{id}"
818
+ Request.new(endpoint: endpoint, verbose: verbose).perform
819
+ end
820
+ end
821
+
822
+ # Taxon suggest
823
+ # @param q [String, nil] A suggest query
824
+ # @param is_active [Boolean, nil] Suggest only taxa with active taxon concepts
825
+ # @param taxon_id [String, nil] Filter by comma-separated taxon IDs
826
+ # @param rank [String, nil] Filter by an array of taxon ranks
827
+ # @param rank_level [Integer, nil] Filter by taxon rank level (e.g., 70 for kingdom)
828
+ # @param locale [String, nil] Locale preference for taxon common names (e.g., en-US)
829
+ # @param preferred_place_id [Integer, nil] Place of preference for regional taxon common names
830
+ # @param all_names [Boolean, nil] Include all taxon names in the response
831
+ #
832
+ # @param per_page [Integer, nil] The results limit
833
+ # @param verbose [Boolean] Print headers to STDOUT
834
+ #
835
+ # @return [Hash, Boolean] A hash with search results
836
+ def self.taxa_autocomplete(q: nil, is_active: nil, taxon_id: nil, rank: nil, rank_level: nil, locale: nil,
837
+ preferred_place_id: nil, all_names: nil, per_page: nil, verbose: false)
838
+ endpoint = 'taxa/autocomplete'
839
+ Request.new(endpoint: endpoint, q: q, is_active: is_active, taxon_id: taxon_id, rank: rank, rank_level: rank_level,
840
+ locale: locale, preferred_place_id: preferred_place_id, all_names: all_names, per_page: per_page,
841
+ verbose: verbose).perform
842
+ end
843
+ end