Crates.io | uslegalpro |
lib.rs | uslegalpro |
version | 0.1.0 |
source | src |
created_at | 2023-09-15 10:12:58.435684 |
updated_at | 2023-09-15 10:12:58.435684 |
description | uslegalpro is a simple library to help with interacting with uslegalpro's JSON API via the reqwest crate. |
homepage | https://github.com/evictionapp/uslegalpro |
repository | https://github.com/evictionapp/uslegalpro |
max_upload_size | |
id | 973593 |
size | 14,966 |
uslegalpro
is a simple library to help with interacting with uslegalpro's JSON API.
Currently there are a few endpoints available. I hope to add the rest as needed. Feel free to create a pull request to add more.
You can specify what url to use as the endpoint, you can also use the prebuilt on for Texas right now, I plan to add more states later on.
It's presumed the endpoints above have the following routes
POST /authenticate GET /search_case GET /case/{CASE_TRACKING_ID}
The only way to make an authenticated request is IFF (if and only if) you have successfully authenticated. It is impossible to construct a client (authed or not) outside of the methods provided by the library. You can still modify and view properties used on the clients however.
use uslegalpro::{client::NoAuthClient, state::State, auth::{authenticate, user::User}};
use reqwest::Client;
async fn auth() {
let texas = State::Texas;
let client = NoAuthClient::new(client, "MY_CLIENT_TOKEN", texas.endpoint());
let user = User {
username: "MY_USERNAME",
password: "MY_PASSWORD",
};
let authtoken = authenticate(client, user).await.unwrap();
println!("AUTHED = {}", authtoken);
let client = client.into_authed_client(&authtoken);
// client can now make authed requests
}
use uslegalpro::{query::{query, Query}};
async fn pre() {
// client from last part of authentication example
let case_query = Query {
client,
case_number: "MY_CASE_#",
jurisdiction: "county:court",
};
let previews = query(case_query).await.unwrap();
println!("my vector of previews = {:?}", previews);
}