This is a convenience crate for handling http requests and errors.
Examples
use Client;
use HttpResult;
use Deserialize;
use dotenv;
use env;
// dotenv is being used for lack of an example not requiring private keys and public wallet addresses.
// dotenv is not required for this crate to work.
dotenv.ok;
let api_key = var.unwrap;
let wallet_address = var.unwrap;
let client = new;
let url =
&.concat;
// Here is the main feature, Balance is the data structure expected back, defined above.
// You define your own struct and use the serde crate and tag the struct with #[derive(Deserialize)]
// and put the name of your struct where our example is using "Balance".
// the 10 means we are going to try 10 times, if there is a too_many_requests response, or
// an unknown error (perhaps our crate just doesn't handle it yet) then it will wait 1 second and try again.
// each time it will double the wait time. The return type is HttpResult<T>
let balance = client..unwrap.result;
dbg!;
// If you are unsure the shape of the data, you can at first use the "get_as_text" function.
// Here is an example of that "get_as_text" function, so you can get a look at all the fields to base your struct off of:
let balance = client.get_as_text;
dbg!;