#api-client #api-bindings #api #ad-tech

beeswax

An easy to use CRUD client for the Beeswax API

3 releases

0.1.2 Jun 19, 2020
0.1.1 Jun 12, 2020
0.1.0 Jun 12, 2020

#225 in #asynchronous

MIT license

93KB
1.5K SLoC

Beeswax

An easy to use CRUD client for the Beeswax API

Warning

This is a very early version of this crate with only a few resources so far.

ToDo:

  • Add the rest of the resources
  • Make runtime agnostic
  • Add blocking version of the client

Usage

Tell the builder what the base url you'd like to connect to is, then create an Authentication object to send to the api to authenticate yourself.

use beeswax::{AsyncBeeswaxClient, resource::authenticate::Authenticate};

let user = std::env::var("BEESWAX_USER")?;
let password = std::env::var("BEESWAX_PASSWORD")?;
let url = "https://buzzkey.api.beeswax.com".to_string();

let beeswax_api = AsyncBeeswaxClient::builder(url)
    .auth(Authenticate::simple(user, password))
    .await?;

You can then create, update, read and delete resources.

use beeswax::resource::Advertiser;

let create_advertiser = Advertiser::create_builder()
    .advertiser_name("Example advertiser")
    .build();

let mut created_advertiser = beeswax_api.create(&create_advertiser).await?;

created_advertiser.active = true;

let updated_advertiser = beeswax_api.update(&created_advertiser).await?;

let read_advertiser = Advertiser::read_builder()
    .advertiser_id(updated_advertiser.advertiser_id)
    .build();

let read_advertiser = beeswax_api.read(&read_advertiser).await?.pop().unwrap();

beeswax_api.delete(&read_advertiser).await?;

Dependencies

~19–30MB
~480K SLoC