-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
user.ts
57 lines (50 loc) · 1.27 KB
/
user.ts
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* SPDX-FileCopyrightText: 2022-present Kriasoft */
/* SPDX-License-Identifier: MIT */
import { baseUrl, createFetch, HttpMethod, type Credentials } from "./fetch.js";
// #region TypeScript
export type User = {
id: string;
email: string;
first_name: string | null;
last_name: string | null;
username: string | null;
telephone: string | null;
country: string | null;
zipcode: string | null;
created_on: string;
modified_on: string;
two_factor_authentication_enabled: boolean;
two_factor_authentication_locked: boolean;
has_pro_zones: boolean;
has_business_zones: boolean;
has_enterprise_zones: boolean;
organizations: Organization[];
betas: string[];
suspended: boolean;
};
export type Organization = {
id: string;
name: string;
permissions: string[];
roles: string[];
status: string;
};
// #endregion
/**
* The currently logged in / authenticated User
* @see https://api.cloudflare.com/#user-properties
*/
export function user(credentials: Credentials) {
const url = `${baseUrl}/user`;
return {
/**
* The currently logged in/authenticated user
* @see https://api.cloudflare.com/#user-properties
*/
get: createFetch(() => ({
method: HttpMethod.GET,
url,
credentials,
})).response<User>(),
};
}