ddclient-rs

Crates.ioddclient-rs
lib.rsddclient-rs
version0.1.3
sourcesrc
created_at2023-12-19 21:55:22.988301
updated_at2024-01-22 17:36:44.837719
descriptionA Rust client library for the Direct Decisions API.
homepagehttps://directdecisions.com/
repositoryhttps://github.com/directdecisions/ddclient-rs
max_upload_size
id1074656
size109,900
Petar Radovic (pradovic)

documentation

README

Direct Decisions API v1 Rust client

Rust

A client library for accessing the Direct Decisions v1 API.

You can view Direct Decisions API v1 docs here: https://api.directdecisions.com/v1

This is an asynchronous Rust client using reqwest. The plan in the future is to also provide a blocking(sync) version and a support for other HTTP clients as well.

Usage

The async client uses tokio and reqwest as dependencies. To use it you would need to setup your Cargo.toml to something like this:

[dependencies]
ddclient = "0.1.1"
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.11", features = ["json"] }

And then use it in your code:

#[tokio::main]
async fn main() -> Result<(), ApiError> {
    let client = Client::new("my-api-key".to_string());

    let v = client
        .create_voting(vec![
            "Einstein".to_string(),
            "Maxwell".to_string(),
            "Newton".to_string(),
        ])
        .await?;

    Ok(())
}

Features

This client implements all Direct API features.

  • Create votings
  • Retrieve voting information
  • Set voting choices
  • Delete votings
  • Vote with a ballot
  • Unvote
  • Get submitted ballot
  • Calculate results

Examples

Feel free to check out the examples in the examples directory. These examples cover both regular flow and error handling. Also, for specific errors you can check out the tests directory and APIError enum.

Versioning

Each version of the client is tagged and the version is updated accordingly. To see the list of past versions, run git tag.

Contributing

We love pull requests! Please see the contribution guidelines.

License

This library is distributed under the BSD-style license found in the LICENSE file.

Commit count: 6

cargo fmt