#connector #sdk #http-request #http-api #requests #enmeshed

connector-sdk

A SDK to communicate with an enmeshed connector

9 releases

0.2.6 Jul 8, 2024
0.2.5 Jul 3, 2024
0.2.3 Jun 22, 2024
0.1.1 Jun 21, 2024

#174 in HTTP client

Download history 323/week @ 2024-06-20 153/week @ 2024-06-27 185/week @ 2024-07-04 22/week @ 2024-07-11 2/week @ 2024-07-18 18/week @ 2024-07-25

440 downloads per month

MIT/Apache

110KB
3K SLoC

The connector-sdk crate exposes a http client that serves as a wrapper around the HTTP-api of the enmeshed connector. In addition it exposes sane type definitions for request and return values implement some convenience functions for handeling common operations.

Example

use connector_sdk::ConnectorClient;

#[tokio::main]
async fn main() {
    let client = ConnectorClient::new(BASE_URL, API_KEY);
    let req = GetRequestsRequest::default();
    let incomming_requests = client
        .get_incomming_requests(&req)
        .await
        .expect("receive incomming requests");
    let request = &incomming_requests[0];
    let id = request.id;
    // Accept all incomming requestsitems
    let r: DecideRequest = request
        .content
        .items
        .iter()
        .map(RequestContent::accept)
        .collect();
    let can_accept_res = client.can_accept(id.as_ref(), &r).await;
    assert!(can_accept_res.is_ok());
}

Dependencies

~5–16MB
~242K SLoC