From 94be793df73e5793ad01bdd0899dc2ba9b386497 Mon Sep 17 00:00:00 2001 From: kitsunecafe Date: Sun, 6 Oct 2024 23:14:08 -0500 Subject: [PATCH] readme --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ce409b --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# Unity Release API Client + +This library makes it easier to interact with [Unity's Release API](https://services.docs.unity.com/release/v1/#tag/Release) for querying information about available Unity editor versions. + +## Usage + +```rust +let client = UnityReleaseClient::default(); +let response: Result = client + .request() + .with_order(Order::Ascending) // order by ascending release date + .with_limit(5) // 5 results per query + .with_offset(20) // offset by 20 results + .with_stream(Stream::LTS) // filter for only LTS versions + .with_platform(Platform::Linux) // filter for only Linux releases + .with_architecture(Architecture::Arm64) // filter for only ARM64 support + .with_version("2020.3.44f1".to_string()) // filter for version 2020.3.44f1 + .send() + .await?; +``` + +## Documentation + +To use the client, create a `UnityReleaseClient` by using `Default::default` or `UnityReleaseClient::new(client)` where `client` is a [`reqwuest::Client`](https://docs.rs/reqwest/latest/reqwest/struct.Client.html). + +```rust +let client = UnityReleaseClient::default(); +``` + +```rust +// with a custom client +let client = reqwest::Client::default(); +let unity_client = UnityReleaseClient::new(client); +``` + +To prepare a request, get a new `RequestBuilder` and configure the parameters. + +```rust +let request_builder = client.request().with_limit(10); +``` + +In order to send the request, either build the `Request` or call `RequestBuilder::send` + +```rust +let request: Request = request_builder.into(); +let response = request.send(); +``` + +```rust +let response = request_builder.send(); // build and send in the same step +``` + +The response is a `Result` and the schema is defined by Unity's OpenAPI spec [available from the API documentation](https://services.docs.unity.com/release/v1/). It's also possible to look through [`response.rs`](https://fem.mint.lgbt/kitsunecafe/unity-release-client/src/commit/dc4b909c5a78a6b639d06cb74b4be3b459c64153/src/response.rs#L160).