API wrapper for the tankerkönig api

Overview

tankerkoenig-rs

API wrapper for the tankerkoenig-api written in rust.

Gives you ready deserialized structs and a easy to use and strictly typed api.

Installation

This crate is currently not released as it is still unter heavy development. However, if you still want to use it, you can install it by adding this to your Cargo.toml:

[dependencies]
tankerkoenig = { git = "https://github.com/jontze/tankerkoenig-rs" }

Quickstart

use tankerkoenig::Tankerkoenig;
use tankerkoenig::models;

async fn request_station_details() -> Result<models::station::DetailsResponse, tankerkoenig::Error> {
    let tanker = Tankerkoenig::new("your-api-key", None);
    let details = tanker.station.fetch_detail("id-of-the-fuel-station").await?;
     Ok(details)
}
Comments
  • Replace runtime ToManyStations error with compile time check

    Replace runtime ToManyStations error with compile time check

    This change was done to prevent runtime errors if the user tried to fetch prices for more than 10 stations at once. Due to a limitation of the tankerkoenig API it's not possible to request more than 10 stations at once.

    To ensure this behavior already at compile time, the fetch station prices function now accepts only an array with up to 10 entries instead a vector with unknown size.

    This comes at costs to the usability, as you now have to wrap the ids in the array to options, but on the other side it is less likely to cause runtime errors.

    enhancement 
    opened by jontze 0
  • feat: Throw error if prices for more than 10 stations requested

    feat: Throw error if prices for more than 10 stations requested

    This PR introduces a new error that will be thrown if the user fetches the prices for more than 10 stations at once. This is due to a limitation of the tankerkoenig api. The api allows only 10 stations at one and ignores every additional station. Since this unintended behaviour and confusing for the user, the function will now throw an error in such a case and restrict the user to request only 10 stations at once.

    Related to #7

    enhancement 
    opened by jontze 0
  • refactor: Remove strum macro dependency and adjust imports

    refactor: Remove strum macro dependency and adjust imports

    This PR adjusts the usage of the strum lib so there are not 2 dependencies linked to the lib.

    Additionally some information was added to the cargo manifest.

    enhancement 
    opened by jontze 0
  • feat: Improve parsing error message

    feat: Improve parsing error message

    This PR adds the response json body as string to the parsing error so the user can get an idea why the parsing failed.

    Close #9

    • feat(error): Add response body to parsing error
    • feat(api): Throw parsing error with response body as string
    • refactor(cargo): Remove json feature from reqwest as not used anymore
    enhancement 
    opened by jontze 0
  • Stabilize the api

    Stabilize the api

    Improve the api parameters and functions.

    • [x] Allow all kind of Vector/array of strings 8043e61bbf79a8f586181fcf1c065ae2942cfd82 ( Vec<String>, Vec<&str>, [String], [&str] )
    • [x] Propagate more errors that lead to a panic before 4c62498bd8157653fcfa4b25cbf8505a810089b5
    • [x] Allow every rust string type as parameter instead only a reference b10f7a8e160bae6a2f9d5fe7f332565fb611d92a
    • [x] Add more error types e03b5d62cb85eda9c2f5daf8b1646c091cac40d6
    • [x] Remove some remaining println statements 095854fefd22f72a893b278818891a954edba774
    • [x] Use rustls-tls to avoid to depend on the openssl 649377c
    • [x] Add more commen traits to public data structs 5bb28ee
    • [x] Check all points here https://rust-lang.github.io/api-guidelines/checklist.html
    enhancement 
    opened by jontze 0
  • docs: Introduce documentation

    docs: Introduce documentation

    This PR adds documentation to the crate.

    Other minor changes:

    • Removal of an unnecessary Arc from the reqwest Client as the client is already wrapped in an Arc internally
    documentation 
    opened by jontze 0
  • chore(deps): Update strum requirement from 0.23 to 0.24

    chore(deps): Update strum requirement from 0.23 to 0.24

    Updates the requirements on strum to permit the latest version.

    Changelog

    Sourced from strum's changelog.

    0.24.0

    • #212. Fix some clippy lints

    • #209. Use core instead of std in a few places.

    • #206. Add get_documentation() to EnumMessage. This provides the ability to get the doc comment for a variant. Currently, very little formatting is done. That is subject to change. Please do not abuse this feature. Rust docs are meant for developer documentation, not long messages for users. However, this may be useful in some situations so we've added support for it.

    • #202. Add a missing doc comment

    • #201. Upgrade Heck version

    0.23.1

    • #193 Fixes an ambiguity introduced by #186 when your enum has a variant called Error.

    • #192 The work done in #189 was lost in other PR's. This re-added the functionality to support no-std.

    0.23.0

    • #185 Adds the FromRepr derive that adds a from_repr(x: usize) -> Option<Self> method to your enum. This lets you convert integer values to your enum. If you specify a #[repr(..)] attribute on your enum, or use an explicit discriminant, this will be incorporated into the derive.

      • from_repr will be const if you use a recent rust version.
      • This cannot be a trait method currently because only inherent methods support const.
    • #186 Automatically implement TryFrom<str> for enums that implement EnumString. This is only enabled for rustc >= 1.34 which is when `TryFrom was stabilized.

      • This is a small breaking change. If you had manually implemented TryFrom<str> for your enum, this will cause a conflict. You can probably remove your manual implementation.
    • #189 Use core::result::Result instead of std::result::Result. This should be more portable in no-std environments.

    0.22.0

    • #180: Deprecates ToString derive. You should use Display instead.

    • #178: Deprecates AsStaticStr. This has been undocumented for a while. The recommended method is to derive IntoStaticStr instead.

    • #171: Improve no-std support.

    • #170: enable changing the path to strum traits. This is necessary if you re-export strum as a submodule in another crate.

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • chore(deps): Update strum_macros requirement from 0.23 to 0.24

    chore(deps): Update strum_macros requirement from 0.23 to 0.24

    Updates the requirements on strum_macros to permit the latest version.

    Changelog

    Sourced from strum_macros's changelog.

    0.24.0

    • #212. Fix some clippy lints

    • #209. Use core instead of std in a few places.

    • #206. Add get_documentation() to EnumMessage. This provides the ability to get the doc comment for a variant. Currently, very little formatting is done. That is subject to change. Please do not abuse this feature. Rust docs are meant for developer documentation, not long messages for users. However, this may be useful in some situations so we've added support for it.

    • #202. Add a missing doc comment

    • #201. Upgrade Heck version

    0.23.1

    • #193 Fixes an ambiguity introduced by #186 when your enum has a variant called Error.

    • #192 The work done in #189 was lost in other PR's. This re-added the functionality to support no-std.

    0.23.0

    • #185 Adds the FromRepr derive that adds a from_repr(x: usize) -> Option<Self> method to your enum. This lets you convert integer values to your enum. If you specify a #[repr(..)] attribute on your enum, or use an explicit discriminant, this will be incorporated into the derive.

      • from_repr will be const if you use a recent rust version.
      • This cannot be a trait method currently because only inherent methods support const.
    • #186 Automatically implement TryFrom<str> for enums that implement EnumString. This is only enabled for rustc >= 1.34 which is when `TryFrom was stabilized.

      • This is a small breaking change. If you had manually implemented TryFrom<str> for your enum, this will cause a conflict. You can probably remove your manual implementation.
    • #189 Use core::result::Result instead of std::result::Result. This should be more portable in no-std environments.

    0.22.0

    • #180: Deprecates ToString derive. You should use Display instead.

    • #178: Deprecates AsStaticStr. This has been undocumented for a while. The recommended method is to derive IntoStaticStr instead.

    • #171: Improve no-std support.

    • #170: enable changing the path to strum traits. This is necessary if you re-export strum as a submodule in another crate.

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Enusre the api response deserializing covers most cases

    Enusre the api response deserializing covers most cases

    The responses of the tankerkoenig api are very dynamic. Just for an example:

    The type of the price field of a fuel can have multiple formats. Sometimes false (boolean) instead of a number, if the station is closed or the station don't offer the fuel type. But sometimes the field will just not be present at all in this case. In the regular case the price will just be a floating number. Therefore, the deserializer needs to be configured to cover false or the missing field as None (Option).

    There are very likely more fields like this that have to be detected and covered to ensure that the library is stable and can be used without throwing parsing errors.

    This can only be achieved with systematic testing and logging.

    After the implementation of #11 the parsing error will contain the json body as string, so if the error is printed or logged it will contain the json that could not be parsed to a rust struct.

    opened by jontze 0
  • tankerkoenig-rs 0.1.0 Initial Release Tracking Issue

    tankerkoenig-rs 0.1.0 Initial Release Tracking Issue

    This tracking issue contain tasks that need to be considered before the first initial public release of the crate.

    Initial Release is blocked by:

    • [x] #9
    • [x] #8
    • [x] #10
    • [x] #13
    • [x] Publish v0.1.0 release candidate
    • [ ] #7
    opened by jontze 0
Releases(v0.1.0-rc.3)
  • v0.1.0-rc.3(Dec 8, 2022)

    What's Changed

    • Replace runtime ToManyStations error with compile time check by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/18

    Full Changelog: https://github.com/jontze/tankerkoenig-rs/compare/v0.1.0-rc.2...v0.1.0-rc.3

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0-rc.2(Jun 27, 2022)

    What's Changed

    • feat: Throw error if prices for more than 10 stations requested by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/17

    Full Changelog: https://github.com/jontze/tankerkoenig-rs/compare/v0.1.0-rc.1...v0.1.0-rc.2

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0-rc.1(Jun 14, 2022)

    What's Changed

    • chore(deps): Update strum requirement from 0.23 to 0.24 by @dependabot in https://github.com/jontze/tankerkoenig-rs/pull/3
    • chore(deps): Update strum_macros requirement from 0.23 to 0.24 by @dependabot in https://github.com/jontze/tankerkoenig-rs/pull/2
    • chore(workflows): Split up workflows and reuse test flow by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/5
    • docs: Introduce documentation by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/4
    • feat: Improve parsing error message by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/11
    • chore: Run test workflow as matrix by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/12
    • refactor: Remove strum macro dependency and adjust imports by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/14
    • chore(workflow): Publish cargo release on github release by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/15
    • chore(workflow): Depend crates release workflow on tests by @jontze in https://github.com/jontze/tankerkoenig-rs/pull/16

    New Contributors

    • @dependabot made their first contribution in https://github.com/jontze/tankerkoenig-rs/pull/3

    Full Changelog: https://github.com/jontze/tankerkoenig-rs/commits/v0.1.0-rc.1

    Source code(tar.gz)
    Source code(zip)
Owner
Jonathan
Self-taught Python and TypeScript Programmer. Currently learning Rust :crab:
Jonathan
A Rust wrapper for the SponsorBlock API.

sponsor-block A Rust wrapper for the SponsorBlock API, which you can find complete documentation for here. Uses SponsorBlock data licensed under CC BY

Zacchary Dempsey-Plante 8 Nov 19, 2022
Wrapper library for utilizing DigitalOcean API v2 in Rust

doapi-rs Wrapper library for utilizing DigitalOcean API v2 in Rust Disclaimer This library is in alpha - it may do anything up to, and including, eati

Kevin K. 30 Nov 5, 2022
A simple, yet feature-filled wrapper around the coqui-stt C API

A simple, yet feature-filled wrapper around the coqui-stt C API

0/0 56 Jan 3, 2023
Autogenerated wrapper for the Telegram Bot API written in Rust.

An Elegant Rust Client for Telegram Bot API crates.io • docs.rs Table of contents Introduction Key Features Installation Getting Started Documentation

FerrisGram 22 Oct 29, 2022
A simple, fast and fully-typed JSPaste API wrapper for Rust

rspaste A simple, fast and fully-typed JSPaste API wrapper for Rust. aidak.tk » Installation Put the desired version of the crate into the dependencie

Aidak 2 May 17, 2022
A safe wrapper around Gamercade's raw Api.

gamercade-rs A safe wrapper around Gamercade's Raw Api. As the Raw Api requires using a lot of unsafe and hiding of values through different types (fo

null 1 Aug 23, 2022
A minimal discord api wrapper.

descord Descord is a discord api wrapper. Example use descord::prelude::*; #[tokio::main] async fn main() { let mut client = Client::new(

null 12 May 6, 2024
Thin wrapper around starship.rs to format kakoune status line

kakship is just a thin wrapper around starship to format the status line of kakoune and is meant to be used with the included kakoune script kakship.kak.

Eric Burghard 15 Jun 7, 2022
dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle!

dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle (such as rewriting/refactroing your DM code).

SS220 20 Dec 13, 2022
A lightweight Discord wrapper made in Tauri

Discord-Tauri is a work in progress lightweight wrapper for Discord.

null 104 Dec 20, 2022
FFI wrapper around cfitsio in Rust

rust-fitsio FFI wrapper around cfitsio in Rust Installation fitsio supports versions of cfitsio >= 3.08. cfitsio must be compiled with reentrant suppo

Simon Walker 22 Dec 24, 2022
cargo-check This is a wrapper around cargo rustc

cargo-check This is a wrapper around cargo rustc -- -Zno-trans. It can be helpful for running a faster compile if you only need correctness checks. In

Ray Solomon 99 Oct 13, 2022
Provides a wrapper to deserialize clap app using serde.

clap-serde Provides a wrapper to deserialize clap app using serde. API Reference toml const CLAP_TOML: &'static str = r#" name = "app_clap_serde" vers

null 17 Jan 9, 2023
🌋 A very lightweight wrapper around the Vulkan Memory Allocator 🦀

?? vk-mem-alloc-rs A very lightweight wrapper around the Vulkan Memory Allocator ?? [dependencies] vk-mem-alloc = "0.1.1" Simple Vulkan Memory Allocat

Project KML 13 Nov 8, 2022
Modrinth API is a simple library for using, you guessed it, the Modrinth API in Rust projects

Modrinth API is a simple library for using, you guessed it, the Modrinth API in Rust projects. It uses reqwest as its HTTP(S) client and deserialises responses to typed structs using serde.

null 21 Jan 1, 2023
A repository full of manually generated hand curated JSON files, which contain the API Types that the Discord API returns.

Discord API Types A repository full of manually generated hand curated JSON files, which contain the API Types that the Discord API returns. Also did

Unofficial Discord Documentation 1 Sep 16, 2022
Notion Offical API client library for rust

Notion API client library for rust.

Jake Swenson 65 Dec 26, 2022
Rust lib for Scaleway API

Notes This Scaleway API Crate is created and maintained by Qovery and used in production in the Qovery Engine. This project relies on OpenAPI Generato

Qovery 5 Nov 10, 2022
mdzk is a plain text Zettelkasten system that is based on the mdBook API.

mdzk A lovingly designed system and static publishing tool for your plain text Zettelkasten mdzk is a plain text Zettelkasten system that is based on

mdzk 176 Jan 4, 2023