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),
)?)
}