Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
- **BaseClient**:
  - Add methods and types for Xml requests
  - Add methods for download files
  - Do not convert query parameters to lower-case
  - Handle `enums` with flags as lists on query parameters
- **WormsClient:** Add `GetAphiaLink(string|int)` method to get a link to WoRMS
- **IUCN:** Make `GetSpecieRedirectLink(string|int)` method static
- Add Barcode of Life Data Sytem (`BoldSystemsClient`)
  • Loading branch information
sn4k3 committed Aug 15, 2023
1 parent 1488129 commit af64bac
Show file tree
Hide file tree
Showing 54 changed files with 3,003 additions and 105 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Change Log

## 12/08/2023 - v1.1.0
## 15/08/2023 - v1.2.0

- **BaseClient**:
- Add methods and types for Xml requests
- Add methods for download files
- Do not convert query parameters to lower-case
- Handle `enums` with flags as lists on query parameters
- **WormsClient:** Add `GetAphiaLink(string|int)` method to get a link to WoRMS
- **IUCN:** Make `GetSpecieRedirectLink(string|int)` method static
- Add Barcode of Life Data Sytem (`BoldSystemsClient`)

## 13/08/2023 - v1.1.0

- Add Species+/CITES (`SpeciesPlusClient`)
- Move `Worms` to `MarineSpecies` namespace
Expand All @@ -17,5 +28,5 @@
- Fix the regex for `WebsiteUrl` to better remove the api sub-domain

## 11/08/2023 - v1.0.0

- First release
9 changes: 5 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Authors>Tiago Conceição; sn4k3</Authors>
<Authors>Tiago Conceição (sn4k3)</Authors>
<Company>PTRTECH</Company>
<Copyright>Copyright 2023-$([System.DateTime]::Now.ToString(`yyyy`)) © PTRTECH</Copyright>
<Version>1.1.0</Version>
<Description>Queries and fetch data from species, taxon, regions and conservation database(s) to retrieve information using the provider API.</Description>
<ApplicationIcon>$(MSBuildThisFileDirectory)images/icon.ico</ApplicationIcon>

<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/sn4k3/SpeciesDatabaseApi</RepositoryUrl>
<PackageProjectUrl>https://github.com/sn4k3/SpeciesDatabaseApi</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/sn4k3/SpeciesDatabaseApi/releases</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>species, taxomy, taxomony, biota, database, api, rest, world, register, marine, wrms, worms, iucn, mr, conservation, nature, regions</PackageTags>
<PackageIcon>icon-128.png</PackageIcon>
<PackageTags>species taxomy taxomony biota database api rest world register marine wrms worms iucn mr conservation nature regions bold systems</PackageTags>
<RepositoryType>Git</RepositoryType>

<Nullable>enable</Nullable>
Expand All @@ -26,7 +27,7 @@
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)icon.png" Pack="true" PackagePath="" Visible="false"/>
<None Include="$(MSBuildThisFileDirectory)images/icon-128.png" Pack="true" PackagePath="" Visible="false"/>
<None Include="$(MSBuildThisFileDirectory)README.md" Pack="true" PackagePath="" Visible="false"/>
<None Include="$(MSBuildThisFileDirectory)LICENSE.txt" Pack="true" PackagePath="" Visible="false"/>
</ItemGroup>
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@



# <img src="https://raw.githubusercontent.com/sn4k3/SpeciesDatabaseApi/master/icon.png" width='64'> Species Database Api
# ![Icon](https://raw.githubusercontent.com/sn4k3/SpeciesDatabaseApi/master/images/icon-64.png) Species Database Api

Queries and fetch data from species, taxon, regions and conservation database(s) to retrieve information using the provider API.

## 🌐 Clients

| Name / Provider | Class | Terms of use |
| ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [International Union for Conservation of Nature (IUCN)](https://iucn.org) | [IucnClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/Iucn/IucnClient.cs) | [Terms of use](http://apiv3.iucnredlist.org/about) |
| [Marine Regions](https://marineregions.org) | [MarineRegionsClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/MarineRegions/MarineRegionsClient.cs) | [Terms of use](https://marineregions.org/disclaimer.php) |
| [Species+/CITES](https://speciesplus.net) | [SpeciesPlusClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/SpeciesPlus/SpeciesPlusClient.cs) | [Terms of use](https://speciesplus.net/terms-of-use) |
| [World Register of Marine Species (WoRMS)](https://marinespecies.org) | [WormsClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/MarineSpecies/WormsClient.cs) | [Terms of use](https://marinespecies.org/about.php#terms) |
| Name / Provider | Class | Terms of use |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [Barcode of Life Data Sytem (BoldSystems)](https://www.boldsystems.org) | [BoldSystemsClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/BoldSystems/BoldSystemsClient.cs) | [Terms of use](https://www.boldsystems.org/index.php/Resources/whatIsBOLD) |
| [International Union for Conservation of Nature (IUCN)](https://www.iucn.org) | [IucnClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/Iucn/IucnClient.cs) | [Terms of use](http://apiv3.iucnredlist.org/about) |
| [Marine Regions](https://www.marineregions.org) | [MarineRegionsClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/MarineRegions/MarineRegionsClient.cs) | [Terms of use](https://www.marineregions.org/disclaimer.php) |
| [Species+/CITES](https://www.speciesplus.net) | [SpeciesPlusClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/SpeciesPlus/SpeciesPlusClient.cs) | [Terms of use](https://www.speciesplus.net/terms-of-use) |
| [World Register of Marine Species (WoRMS)](https://www.marinespecies.org) | [WormsClient](https://github.com/sn4k3/SpeciesDatabaseApi/blob/master/SpeciesDatabaseApi/MarineSpecies/WormsClient.cs) | [Terms of use](https://www.marinespecies.org/about.php#terms) |

## 🤝 Terms of use

Expand Down Expand Up @@ -117,10 +118,11 @@ Run the "SpeciesDatabaseCmd.exe" and follow the in-terminal instructions to call
# -?, -h, --help Show help and usage information
#
# Commands:
# WORMS Query - World Register of Marine Species (https://marinespecies.org)
# IUCN Query - International Union for Conservation of Nature (http://iucnredlist.org)
# MARINEREGIONS Query - Marine Regions (https://marineregions.org)
# SPECIES+ Query - Species+/CITES (https://speciesplus.net)
# BOLDSYSTEMS Query - Barcode of Life Data Sytem (https://www.boldsystems.org)
# IUCN Query - International Union for Conservation of Nature (http://www.iucnredlist.org)
# MARINEREGIONS Query - Marine Regions (https://www.marineregions.org)
# SPECIES+ Query - Species+/CITES (https://www.speciesplus.net)
# WORMS Query - World Register of Marine Species (https://www.marinespecies.org)

SpeciesDatabaseCmd.exe IUCN SpecieCommonNames "Carcharodon carcharias"

Expand Down
23 changes: 23 additions & 0 deletions SpeciesDatabaseApi/ApiToken.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Net.Http.Headers;

namespace SpeciesDatabaseApi;

Expand Down Expand Up @@ -101,6 +103,27 @@ protected internal void Set(string key, string value, ApiTokenPlacement placemen
Placement = placement;
}

/// <summary>
/// Try to inject this token into a <see cref="HttpRequestMessage"/> if configured and possible
/// </summary>
/// <param name="request">The <see cref="HttpRequestMessage"/> where it will try to inject the token</param>
/// <returns></returns>
public bool TryInject(HttpRequestMessage request)
{
if (!CanUse) return false;
switch (Placement)
{
case ApiTokenPlacement.Header:
request.Headers.Add(Key, Value);
return true;
case ApiTokenPlacement.HeaderAuthorization:
request.Headers.Authorization = new AuthenticationHeaderValue(Key, Value);
return true;
default:
return false;
}
}

#endregion

#region Equality and Format
Expand Down
Loading

0 comments on commit af64bac

Please sign in to comment.