1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::client::GraphClient;
use serde_json::Value;
use std::error::Error;

pub fn create_user(client: &GraphClient, body: Value) -> Result<Value, Box<dyn Error>> {
    client.post("/users", body)
}

pub fn list_users(client: &GraphClient) -> Result<Value, Box<dyn Error>> {
    let response = client.get("/users")?;
    crate::pagination::fetch_all_pages(client, response)
}

pub fn get_user(client: &GraphClient, user_id: &str) -> Result<Value, Box<dyn Error>> {
    let path = format!("/users/{}", user_id);
    client.get(&path)
}

pub fn delete_user(client: &GraphClient, user_id: &str) -> Result<(), Box<dyn Error>> {
    let path = format!("/users/{}", user_id);
    client.delete(&path)
}

pub fn update_user(
    client: &GraphClient,
    user_id: &str,
    body: Value,
) -> Result<Value, Box<dyn Error>> {
    let path = format!("/users/{}", user_id);
    client.patch(&path, body)
}

pub fn revoke_sign_in_sessions(client: &GraphClient, user_id: &str) -> Result<Value, Box<dyn Error>> {
    let path = format!("/users/{}/revokeSignInSessions", user_id);
    client.post(&path, serde_json::json!({}))
}