fauna-api 1.0.773

The Fauna SDK for Rust: accounts, Drive, groups, calendar, chats, payments, Parrot and live rooms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use serde_json::{Value, json};

use crate::authentification::{Credentials, PartialProfile, Profile};
use crate::error::Result;
use crate::http::{client, ok};

pub async fn query(credentials: &Credentials, profile: &PartialProfile) -> Result<Vec<Profile>> {
    let response = client()
        .post(format!("{}/credentials/query", crate::get_url()))
        .header("Authorization", format!("Token {}", credentials.token))
        .json(&json!({ "email": profile.email, "displayName": profile.display_name }))
        .send()
        .await?;
    let json: Value = ok(response).await?.json().await?;
    Ok(serde_json::from_value(
        json.get("accounts").cloned().unwrap_or(json),
    )?)
}