plazucchini 0.0.1

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.
@@ -0,0 +1,569 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+ require_relative "plazucchini/error"
5
+ require_relative "plazucchini/version"
6
+ require_relative "plazucchini/request"
7
+ require "plazucchini/helpers/configuration"
8
+
9
+ module Plazucchini
10
+ extend Configuration
11
+
12
+ define_setting :base_url, "http://api.plazi.org"
13
+ define_setting :mailto, ENV["PLAZI_API_EMAIL"]
14
+
15
+
16
+ # Authors Described Species
17
+ # How many new species have been described in papers authored by the given author?
18
+ #
19
+ # @param author [String] The author (default: "Agosti, D")
20
+ # @param limit [nil, Integer] The optional result limit
21
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
22
+ # @param verbose [Boolean] Print headers to STDOUT
23
+ #
24
+ # @return [Array] An array with the authors' described species counts
25
+ def self.authors_described_species(author: nil, limit: nil, order_mode: nil, verbose: false)
26
+ endpoint = "/v1/Authors/DescribedSpecies"
27
+ Request.new(endpoint: endpoint, method: :get, format: :json, author:, limit: limit, order_mode: order_mode, verbose: verbose).perform
28
+ end
29
+
30
+
31
+ # Authors Material Type Citations
32
+ # How many times the given taxon types appear in material citations?
33
+ # NOTE: This endpoint is misplaced in the API - it queries by taxon, not author
34
+ #
35
+ # @param genus_epithet [String] The genus epithet (default: "Tyrannosaurus")
36
+ # @param species_epithet [String] The species epithet (default: "rex")
37
+ # @param limit [nil, Integer] The optional result limit
38
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
39
+ # @param verbose [Boolean] Print headers to STDOUT
40
+ #
41
+ # @return [Array] An array with material type citation counts
42
+ def self.authors_material_type_citations(genus_epithet: nil, species_epithet: nil, limit: nil, order_mode: nil, verbose: false)
43
+ endpoint = "/v1/Authors/MaterialTypeCitations"
44
+ Request.new(endpoint: endpoint, method: :get, format: :json, genus_epithet:, species_epithet:, limit: limit, order_mode: order_mode, verbose: verbose).perform
45
+ end
46
+
47
+
48
+ # Authors New Species
49
+ # How many new species have been described by the given author?
50
+ #
51
+ # @param author [String] The author (required, default: "Malabarba")
52
+ # @param status [String] The taxonomic status (default: "sp. nov.")
53
+ # @param limit [nil, Integer] The optional result limit
54
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
55
+ # @param verbose [Boolean] Print headers to STDOUT
56
+ #
57
+ # @return [Array] An array with the authors' new species counts
58
+ def self.authors_new_species(author: nil, status: nil, limit: nil, order_mode: nil, verbose: false)
59
+ endpoint = "/v1/Authors/NewSpecies"
60
+ Request.new(endpoint: endpoint, method: :get, format: :json, author:, status:, limit: limit, order_mode: order_mode, verbose: verbose).perform
61
+ end
62
+
63
+
64
+ # Authors Publication Dates
65
+ # When did the given author publish?
66
+ #
67
+ # @param author [String] The author (default: "Agosti, D")
68
+ # @param limit [nil, Integer] The optional result limit
69
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
70
+ # @param verbose [Boolean] Print headers to STDOUT
71
+ #
72
+ # @return [Array] An array with the authors' publication dates and counts
73
+ def self.authors_publication_dates(author: nil, limit: nil, order_mode: nil, verbose: false)
74
+ endpoint = "/v1/Authors/PublicationDate"
75
+ Request.new(endpoint: endpoint, method: :get, format: :json, author:, limit: limit, order_mode: order_mode, verbose: verbose).perform
76
+ end
77
+
78
+
79
+ # Authors Publication Journals
80
+ # In which journals did the given author publish?
81
+ #
82
+ # @param author [String] The author (default: "Agosti, D")
83
+ # @param limit [nil, Integer] The optional result limit
84
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
85
+ # @param verbose [Boolean] Print headers to STDOUT
86
+ #
87
+ # @return [Array] An array with the authors' publication journals and counts
88
+ def self.authors_publication_journals(author: nil, limit: nil, order_mode: nil, verbose: false)
89
+ endpoint = "/v1/Authors/PublicationJournals"
90
+ Request.new(endpoint: endpoint, method: :get, format: :json, author:, limit: limit, order_mode: order_mode, verbose: verbose).perform
91
+ end
92
+
93
+
94
+ # Authors Publication Partners (Co-Authors)
95
+ # With whom did the given author publish?
96
+ #
97
+ # @param author [String] The author (default: "Agosti, D")
98
+ # @param limit [nil, Integer] The optional result limit
99
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
100
+ # @param verbose [Boolean] Print headers to STDOUT
101
+ #
102
+ # @return [Array] An array with the authors' co-authors and collaboration counts
103
+ def self.authors_publication_partners(author: nil, limit: nil, order_mode: nil, verbose: false)
104
+ endpoint = "/v1/Authors/PublicationPartners"
105
+ Request.new(endpoint: endpoint, method: :get, format: :json, author:, limit: limit, order_mode: order_mode, verbose: verbose).perform
106
+ end
107
+
108
+
109
+ # Authors Specimen Locations
110
+ # Where are the specimens collected by the given collector deposited?
111
+ # NOTE: This endpoint is misplaced in the API - it queries by collector, not author
112
+ #
113
+ # @param collector [String] The collector (default: "Agosti")
114
+ # @param limit [nil, Integer] The optional result limit
115
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
116
+ # @param verbose [Boolean] Print headers to STDOUT
117
+ #
118
+ # @return [Array] An array with specimen deposit locations and counts
119
+ def self.authors_specimen_locations(collector: nil, limit: nil, order_mode: nil, verbose: false)
120
+ endpoint = "/v1/Authors/SpecimenLocation"
121
+ Request.new(endpoint: endpoint, method: :get, format: :json, collector:, limit: limit, order_mode: order_mode, verbose: verbose).perform
122
+ end
123
+
124
+
125
+ # Authors Treatment Count
126
+ # How many treatments have been authored by the given author?
127
+ #
128
+ # @param author [String] The author (required, default: "Linnaeus")
129
+ # @param limit [nil, Integer] The optional result limit
130
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
131
+ # @param verbose [Boolean] Print headers to STDOUT
132
+ #
133
+ # @return [Array] An array with the authors' treatment counts
134
+ def self.authors_treatment_count(author: nil, limit: nil, order_mode: nil, verbose: false)
135
+ endpoint = "/v1/Authors/TreatmentCount"
136
+ Request.new(endpoint: endpoint, method: :get, format: :json, author:, limit: limit, order_mode: order_mode, verbose: verbose).perform
137
+ end
138
+
139
+
140
+ # Contributors Liberated Material Citations
141
+ # How many material citations have been liberated by the given person?
142
+ #
143
+ # @param user [String] The user that made the contribution (default: "tatiana")
144
+ # @param limit [nil, Integer] The optional result limit
145
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
146
+ # @param verbose [Boolean] Print headers to STDOUT
147
+ #
148
+ # @return [Array] An array with the contributors' material citation counts
149
+ def self.contributors_material_citations(user: nil, limit: nil, order_mode: nil, verbose: false)
150
+ endpoint = "/v1/Contributors/LiberatedMaterialCitations"
151
+ Request.new(endpoint: endpoint, method: :get, format: :json, user:, limit: limit, order_mode: order_mode, verbose: verbose).perform
152
+ end
153
+
154
+
155
+ # Contributors Liberated Pages
156
+ # How many pages have been liberated by the given person?
157
+ #
158
+ # @param user [String] The user that made the contribution (default: "tatiana")
159
+ # @param limit [nil, Integer] The optional result limit
160
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
161
+ # @param verbose [Boolean] Print headers to STDOUT
162
+ #
163
+ # @return [Array] An array with the contributors' page counts
164
+ def self.contributors_pages(user: nil, limit: nil, order_mode: nil, verbose: false)
165
+ endpoint = "/v1/Contributors/LiberatedPages"
166
+ Request.new(endpoint: endpoint, method: :get, format: :json, user:, limit: limit, order_mode: order_mode, verbose: verbose).perform
167
+ end
168
+
169
+
170
+ # Contributors Liberated Publications
171
+ # How many publications have been liberated by the given person?
172
+ #
173
+ # @param user [String] The user that made the contribution (default: "tatiana")
174
+ # @param limit [nil, Integer] The optional result limit
175
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
176
+ # @param verbose [Boolean] Print headers to STDOUT
177
+ #
178
+ # @return [Array] An array with the contributors' publication counts
179
+ def self.contributors_publications(user: nil, limit: nil, order_mode: nil, verbose: false)
180
+ endpoint = "/v1/Contributors/LiberatedPublications"
181
+ Request.new(endpoint: endpoint, method: :get, format: :json, user:, limit: limit, order_mode: order_mode, verbose: verbose).perform
182
+ end
183
+
184
+
185
+ # Contributors Liberated Treatments
186
+ # How many treatments have been liberated by the given person?
187
+ #
188
+ # @param user [String] The user that made the contribution (default: "tatiana")
189
+ # @param limit [nil, Integer] The optional result limit
190
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
191
+ # @param verbose [Boolean] Print headers to STDOUT
192
+ #
193
+ # @return [Array] An array with the contributors' treatment counts
194
+ def self.contributors_treatments(user: nil, limit: nil, order_mode: nil, verbose: false)
195
+ endpoint = "/v1/Contributors/LiberatedTreatments"
196
+ Request.new(endpoint: endpoint, method: :get, format: :json, user:, limit: limit, order_mode: order_mode, verbose: verbose).perform
197
+ end
198
+
199
+
200
+ # Institutions Cited Materials
201
+ # How many publications cite materials deposited in the given institution?
202
+ #
203
+ # @param collection_code [String] The collection code (default: "MNHN")
204
+ # @param limit [nil, Integer] The optional result limit
205
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
206
+ # @param verbose [Boolean] Print headers to STDOUT
207
+ #
208
+ # @return [Array] An array with institutions' cited material counts
209
+ def self.institutions_cited_materials(collection_code: nil, limit: nil, order_mode: nil, verbose: false)
210
+ endpoint = "/v1/Institutions/CitedMaterials"
211
+ Request.new(endpoint: endpoint, method: :get, format: :json, collection_code:, limit: limit, order_mode: order_mode, verbose: verbose).perform
212
+ end
213
+
214
+
215
+ # Institutions Distribution Range
216
+ # What is the range of distribution covered by the given institution?
217
+ #
218
+ # @param collection_code [String] The collection code (default: "MNHN")
219
+ # @param limit [nil, Integer] The optional result limit
220
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
221
+ # @param verbose [Boolean] Print headers to STDOUT
222
+ #
223
+ # @return [Array] An array with institutions' geographic distribution data
224
+ def self.institutions_distribution_range(collection_code: nil, limit: nil, order_mode: nil, verbose: false)
225
+ endpoint = "/v1/Institutions/DistributionRange"
226
+ Request.new(endpoint: endpoint, method: :get, format: :json, collection_code:, limit: limit, order_mode: order_mode, verbose: verbose).perform
227
+ end
228
+
229
+
230
+ # Institutions Journal Occurrences
231
+ # In which journals is the data of the given institution published?
232
+ # NOTE: The API endpoint is misspelled as "JournalOccurances"
233
+ #
234
+ # @param collection_code [String] The collection code (default: "MNHN")
235
+ # @param limit [nil, Integer] The optional result limit
236
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
237
+ # @param verbose [Boolean] Print headers to STDOUT
238
+ #
239
+ # @return [Array] An array with institutions' journal occurrence data
240
+ def self.institutions_journal_occurrences(collection_code: nil, limit: nil, order_mode: nil, verbose: false)
241
+ endpoint = "/v1/Institutions/JournalOccurances" # API endpoint is misspelled
242
+ Request.new(endpoint: endpoint, method: :get, format: :json, collection_code:, limit: limit, order_mode: order_mode, verbose: verbose).perform
243
+ end
244
+
245
+
246
+ # Institutions Specimens Stored
247
+ #
248
+ # @param collection_code [String] The collection code (default: MNHN)
249
+ # @param limit [nil, Integer] The optional result limit
250
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
251
+ # @param verbose [Boolean] Print headers to STDOUT
252
+ #
253
+ # @return [Array] An array with institutions' specimens stored
254
+ def self.institutions_specimens_stored(collection_code: nil, limit: nil, order_mode: nil, verbose: false)
255
+ endpoint = "/v1/Institutions/SpecimenStored"
256
+ Request.new(endpoint: endpoint, method: :get, format: :json, collection_code:, limit: limit, order_mode: order_mode, verbose: verbose).perform
257
+ end
258
+
259
+
260
+ # Institutions Stored Types
261
+ #
262
+ # @param collection_code [String] The collection code (default: MNHN)
263
+ # @param limit [nil, Integer] The optional result limit
264
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
265
+ # @param verbose [Boolean] Print headers to STDOUT
266
+ #
267
+ # @return [Array] An array with institutions' stored types
268
+ def self.institutions_stored_types(collection_code: nil, limit: nil, order_mode: nil, verbose: false)
269
+ endpoint = "/v1/Institutions/StoredTypes"
270
+ Request.new(endpoint: endpoint, method: :get, format: :json, collection_code:, limit: limit, order_mode: order_mode, verbose: verbose).perform
271
+ end
272
+
273
+
274
+ # Journals Cited Collections
275
+ #
276
+ # @param journal [String] The journal name (default: Phytotaxa)
277
+ # @param limit [nil, Integer] The optional result limit
278
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
279
+ # @param verbose [Boolean] Print headers to STDOUT
280
+ #
281
+ # @return [Array] An array with journal cited collections
282
+ def self.journals_cited_collections(journal: nil, limit: nil, order_mode: nil, verbose: false)
283
+ endpoint = "/v1/Journals/CitedCollections"
284
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
285
+ end
286
+
287
+
288
+ # Journals Published Figures Count
289
+ #
290
+ # @param journal [String] The journal name (default: Zootaxa)
291
+ # @param limit [nil, Integer] The optional result limit
292
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
293
+ # @param verbose [Boolean] Print headers to STDOUT
294
+ #
295
+ # @return [Array] An array with published figures counts
296
+ def self.journals_published_figures_count(journal: nil, limit: nil, order_mode: nil, verbose: false)
297
+ endpoint = "/v1/Journals/PublishedFiguresCount"
298
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
299
+ end
300
+
301
+
302
+ # Journals Published Material Distribution
303
+ #
304
+ # @param journal [String] The journal name (default: Phytotaxa)
305
+ # @param limit [nil, Integer] The optional result limit
306
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
307
+ # @param verbose [Boolean] Print headers to STDOUT
308
+ #
309
+ # @return [Array] An array with published material distribution counts
310
+ def self.journals_published_material_distribution(journal: nil, limit: nil, order_mode: nil, verbose: false)
311
+ endpoint = "/v1/Journals/PublishedMaterialDistribution"
312
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
313
+ end
314
+
315
+
316
+ # Journals Published New Species Count
317
+ #
318
+ # @param journal [String] The journal name
319
+ # @param limit [nil, Integer] The optional result limit
320
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
321
+ # @param verbose [Boolean] Print headers to STDOUT
322
+ #
323
+ # @return [Array] An array with published new species counts
324
+ def self.journals_published_new_species_count(journal: nil, limit: nil, order_mode: nil, verbose: false)
325
+ endpoint = "/v1/Journals/PublishedNewSpeciesCount"
326
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
327
+ end
328
+
329
+
330
+ # Journals Published Page Count
331
+ #
332
+ # @param journal [String] The journal name (default: )
333
+ # @param limit [nil, Integer] The optional result limit
334
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
335
+ # @param verbose [Boolean] Print headers to STDOUT
336
+ #
337
+ # @return [Array] An array with published page counts
338
+ def self.journals_published_page_count(journal: nil, limit: nil, order_mode: nil, verbose: false)
339
+ endpoint = "/v1/Journals/PublishedPageCount"
340
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
341
+ end
342
+
343
+
344
+ # Journals Published Synonyms Count
345
+ #
346
+ # @param journal [String] The journal name
347
+ # @param limit [nil, Integer] The optional result limit
348
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
349
+ # @param verbose [Boolean] Print headers to STDOUT
350
+ #
351
+ # @return [Array] An array with published synonyms counts
352
+ def self.journals_published_synonyms(journal: nil, limit: nil, order_mode: nil, verbose: false)
353
+ endpoint = "/v1/Journals/PublishedSynonyms"
354
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
355
+ end
356
+
357
+
358
+ # Journals Published Tables Count
359
+ #
360
+ # @param journal [String] The journal name
361
+ # @param limit [nil, Integer] The optional result limit
362
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
363
+ # @param verbose [Boolean] Print headers to STDOUT
364
+ #
365
+ # @return [Array] An array with published tables counts
366
+ def self.journals_published_tables(journal: nil, limit: nil, order_mode: nil, verbose: false)
367
+ endpoint = "/v1/Journals/PublishedTabels" # endpoint is misspelled in the API
368
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
369
+ end
370
+
371
+
372
+ # Journals Published Treatment Count
373
+ #
374
+ # @param journal [String] The journal name
375
+ # @param limit [nil, Integer] The optional result limit
376
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
377
+ # @param verbose [Boolean] Print headers to STDOUT
378
+ #
379
+ # @return [Array] An array with published treatment counts
380
+ def self.journals_published_treatment_count(journal: nil, limit: nil, order_mode: nil, verbose: false)
381
+ endpoint = "/v1/Journals/PublishedTreatmentCount"
382
+ Request.new(endpoint: endpoint, method: :get, format: :json, journal:, limit: limit, order_mode: order_mode, verbose: verbose).perform
383
+ end
384
+
385
+
386
+ # Metrics Journal Data Count
387
+ #
388
+ # @param limit [nil, Integer] The optional result limit
389
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
390
+ # @param verbose [Boolean] Print headers to STDOUT
391
+ #
392
+ # @return [Array] An array with metrics data counts
393
+ def self.metrics_journal_data_count(limit: nil, order_mode: nil, verbose: false)
394
+ endpoint = "/v1/Metrics/JournalDataCount"
395
+ Request.new(endpoint: endpoint, method: :get, format: :json, limit: limit, order_mode: order_mode, verbose: verbose).perform
396
+ end
397
+
398
+
399
+ # Metrics User Contribution Count
400
+ #
401
+ # @param limit [nil, Integer] The optional result limit
402
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
403
+ # @param verbose [Boolean] Print headers to STDOUT
404
+ #
405
+ # @return [Array] An array with metrics data counts
406
+ def self.metrics_user_contribution_count(limit: nil, order_mode: nil, verbose: false)
407
+ endpoint = "/v1/Metrics/UserContributionCount"
408
+ Request.new(endpoint: endpoint, method: :get, format: :json, limit: limit, order_mode: order_mode, verbose: verbose).perform
409
+ end
410
+
411
+
412
+ # Specimens With Genes
413
+ # How many specimens are documented with gene sequences?
414
+ # NOTE: This endpoint is misplaced in the API under Authors - it queries by genus, not author
415
+ #
416
+ # @param genus_epithet [String] The genus (required, default: "Exobasidium")
417
+ # @param limit [nil, Integer] The optional result limit
418
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
419
+ # @param verbose [Boolean] Print headers to STDOUT
420
+ #
421
+ # @return [Array] An array with specimens that have gene sequence data
422
+ def self.specimens_with_genes(genus_epithet: nil, limit: nil, order_mode: nil, verbose: false)
423
+ endpoint = "/v1/Authors/SpecimenWithGenes" # API endpoint is misplaced under Authors
424
+ Request.new(endpoint: endpoint, method: :get, format: :json, genus_epithet:, limit: limit, order_mode: order_mode, verbose: verbose).perform
425
+ end
426
+
427
+
428
+ # Taxon Materials Citations
429
+ #
430
+ # @param genus_epithet [String] The genus of the treatment
431
+ # @param species_epithet [String] The species of the treatment
432
+ # @param limit [nil, Integer] The optional result limit
433
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
434
+ # @param verbose [Boolean] Print headers to STDOUT
435
+ #
436
+ # @return [Array] An array with taxon materials citations
437
+ def self.taxon_materials_citations(genus_epithet: nil, species_epithet: nil, limit: nil, order_mode: nil, verbose: false)
438
+ endpoint = "/v1/Taxon/MaterialCitations"
439
+ Request.new(endpoint: endpoint, method: :get, format: :json, genus_epithet: genus_epithet, species_epithet: species_epithet,
440
+ limit: limit, order_mode: order_mode, verbose: verbose).perform
441
+ end
442
+
443
+ # Taxon Occurrence By Material Citation
444
+ # NOTE: The API endpoint is misspelled as "OccuranceByMaterialCitation"
445
+ #
446
+ # @param limit [nil, Integer] The optional result limit
447
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
448
+ # @param verbose [Boolean] Print headers to STDOUT
449
+ #
450
+ # @return [Array] An array with taxon occurrence by material citation results
451
+ def self.taxon_occurrence_by_materials_citation(limit: nil, order_mode: nil, verbose: false)
452
+ endpoint = "/v1/Taxon/OccuranceByMaterialCitation" # API endpoint is misspelled
453
+ Request.new(endpoint: endpoint, method: :get, format: :json, limit: limit, order_mode: order_mode, verbose: verbose).perform
454
+ end
455
+
456
+ # Taxon Specimens In Collections
457
+ #
458
+ # @param genus_epithet [String] The genus of the treatment
459
+ # @param limit [nil, Integer] The optional result limit
460
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
461
+ # @param verbose [Boolean] Print headers to STDOUT
462
+ #
463
+ # @return [Array] An array of taxon specimens in collections
464
+ def self.taxon_specimens_in_collections(genus_epithet: nil, limit: nil, order_mode: nil, verbose: false)
465
+ endpoint = "/v1/Taxon/SpecimensInCollections"
466
+ Request.new(endpoint: endpoint, method: :get, format: :json, genus_epithet: genus_epithet, limit: limit, order_mode: order_mode, verbose: verbose).perform
467
+ end
468
+
469
+ # Taxon Treatments for taxon
470
+ #
471
+ # @param genus_epithet [String] The genus of the treatment
472
+ # @param species_epithet [String] The species of the treatment
473
+ # @param limit [nil, Integer] The optional result limit
474
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
475
+ # @param verbose [Boolean] Print headers to STDOUT
476
+ #
477
+ # @return [Array] An array of taxon treatments for taxon results
478
+ def self.taxon_treatments_for_taxon(genus_epithet: nil, species_epithet: nil, limit: nil, order_mode: nil, verbose: false)
479
+ endpoint = "/v1/Taxon/TreatmentsForTaxon"
480
+ Request.new(endpoint: endpoint, method: :get, format: :json, genus_epithet: genus_epithet, species_epithet: species_epithet,
481
+ limit: limit, order_mode: order_mode, verbose: verbose).perform
482
+ end
483
+
484
+
485
+ # Taxon Treatments With Keys
486
+ # Find treatments that contain taxonomic keys for the given genus
487
+ #
488
+ # @param genus_epithet [String] The genus of the treatment
489
+ # @param limit [nil, Integer] The optional result limit
490
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
491
+ # @param verbose [Boolean] Print headers to STDOUT
492
+ #
493
+ # @return [Array] An array of treatments with taxonomic keys
494
+ def self.taxon_treatments_with_keys(genus_epithet: nil, limit: nil, order_mode: nil, verbose: false)
495
+ endpoint = "/v1/Taxon/TreatmentsWithKeys"
496
+ Request.new(endpoint: endpoint, method: :get, format: :json, genus_epithet: genus_epithet, limit: limit, order_mode: order_mode, verbose: verbose).perform
497
+ end
498
+
499
+
500
+ # Treatments Fetch
501
+ # Fetch the full treatment document by UUID
502
+ #
503
+ # @param uuid [String] The UUID of the treatment to fetch (required)
504
+ # @param verbose [Boolean] Print headers to STDOUT
505
+ #
506
+ # @return [Hash] The full treatment data as a hash (converted from XML)
507
+ def self.treatments_fetch(uuid:, verbose: false)
508
+ endpoint = "/v1/Treatments/fetch"
509
+ Request.new(endpoint: endpoint, method: :get, format: :xml, uuid:, verbose: verbose).perform
510
+ end
511
+
512
+
513
+ # Search treatments
514
+ # Search for treatments by taxonomic rank
515
+ #
516
+ # @param kingdom_epithet [nil, String] The kingdom to search (optional)
517
+ # @param phylum_epithet [nil, String] The phylum to search (optional)
518
+ # @param class_epithet [nil, String] The class to search (optional)
519
+ # @param order_epithet [nil, String] The order to search (optional)
520
+ # @param family_epithet [nil, String] The family to search (optional)
521
+ # @param genus_epithet [nil, String] The genus to search (optional)
522
+ # @param species_epithet [nil, String] The species to search (optional)
523
+ # @param limit [nil, Integer] The search result limit (optional)
524
+ # @param order_mode [nil, String] The optional sort order (ASC, DESC, nil)
525
+ # @param verbose [Boolean] Print headers to STDOUT
526
+ #
527
+ # @return [Array] An array of matching treatments
528
+ def self.treatments_search(kingdom_epithet: nil, phylum_epithet: nil, class_epithet: nil, order_epithet: nil, family_epithet: nil, genus_epithet: nil, species_epithet: nil, limit: nil, order_mode: nil, verbose: false)
529
+ endpoint = "/v1/Treatments/search"
530
+ Request.new(endpoint: endpoint, method: :get, format: :json, kingdom_epithet:, phylum_epithet:, class_epithet:, order_epithet:, family_epithet:, genus_epithet:, species_epithet:, limit:, order_mode:, verbose: verbose).perform
531
+ end
532
+
533
+
534
+ # Search treatments by DOI
535
+ # Find treatments associated with the given DOI
536
+ #
537
+ # @param doi [String] The DOI to search for (required)
538
+ # @param verbose [Boolean] Print headers to STDOUT
539
+ #
540
+ # @return [Array] An array of matching treatments
541
+ def self.treatments_search_by_doi(doi:, verbose: false)
542
+ endpoint = "/v1/Treatments/searchByDOI"
543
+ Request.new(endpoint: endpoint, method: :get, format: :json, doi:, verbose: verbose).perform
544
+ end
545
+
546
+ # Get a treatment summary
547
+ # Fetch a summary of the treatment by UUID
548
+ #
549
+ # @param uuid [String] The UUID of the treatment (required)
550
+ # @param verbose [Boolean] Print headers to STDOUT
551
+ #
552
+ # @return [Array] An array with the treatment summary data
553
+ def self.treatments_summary(uuid:, verbose: false)
554
+ endpoint = "/v1/Treatments/summary"
555
+ Request.new(endpoint: endpoint, method: :get, format: :json, uuid:, verbose: verbose).perform
556
+ end
557
+
558
+ # Ping the API (check if the service is alive)
559
+ #
560
+ # @param verbose [Boolean] Print headers to STDOUT
561
+ #
562
+ # @return [Hash] Returns {"pong" => true} if the API is reachable
563
+ # @raise [Plazucchini::Error] If the API is not reachable
564
+ def self.ping(verbose: false)
565
+ endpoint = "/v1/Metrics/JournalDataCount"
566
+ Request.new(endpoint: endpoint, method: :get, format: :json, limit: 1, verbose: verbose).perform
567
+ {"pong" => true}
568
+ end
569
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/plazucchini/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "plazucchini"
7
+ s.version = Plazucchini::VERSION
8
+ s.authors = ["Geoff Ower"]
9
+ s.email = ["gdower@illinois.edu"]
10
+
11
+ s.summary = "Plazi TreatmentBank API Client"
12
+ s.description = "plazucchini is a low-level wrapper around the Plazi TreatmentBank API."
13
+ s.homepage = "https://github.com/SpeciesFileGroup/plazucchini"
14
+ s.license = "MIT"
15
+ s.required_ruby_version = ">= 2.5.0"
16
+
17
+ s.metadata["homepage_uri"] = s.homepage
18
+ s.metadata["source_code_uri"] = "https://github.com/SpeciesFileGroup/plazucchini"
19
+ s.metadata["changelog_uri"] = "https://github.com/SpeciesFileGroup/plazucchini/releases/tag/v#{s.version}"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ s.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|s|features)/}) }
25
+ end
26
+ s.bindir = "exe"
27
+ s.executables = s.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ s.require_paths = ["lib"]
29
+
30
+ s.add_development_dependency "bundler", "~> 2.1", ">= 2.1.4"
31
+ s.add_development_dependency "rake", "~> 13.0", ">= 13.0.1"
32
+ s.add_development_dependency "test-unit", "~> 3.3", ">= 3.3.6"
33
+ s.add_development_dependency "vcr", "~> 6.0"
34
+ s.add_development_dependency "webmock", "~> 3.18"
35
+ s.add_development_dependency "rexml", "~> 3.3", ">= 3.3.6"
36
+
37
+ s.add_runtime_dependency "faraday", "~> 2.2"
38
+ s.add_runtime_dependency "faraday-follow_redirects", "~> 0.1"
39
+ s.add_runtime_dependency "multi_json", "~> 1.15"
40
+ s.add_runtime_dependency "nokogiri", "~> 1.16"
41
+ end