-
Notifications
You must be signed in to change notification settings - Fork 97
/
user.ts
47 lines (42 loc) · 1.5 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
import type { AxiosInstance } from 'contentful-sdk-core'
import {
CollectionProp,
GetOrganizationParams,
GetSpaceParams,
QueryParams,
} from '../../../common-types'
import { UserProps } from '../../../entities/user'
import { RestEndpoint } from '../types'
import * as raw from './raw'
export const getForSpace: RestEndpoint<'User', 'getForSpace'> = (
http: AxiosInstance,
params: GetSpaceParams & { userId: string }
) => {
return raw.get<UserProps>(http, `/spaces/${params.spaceId}/users/${params.userId}`)
}
export const getCurrent: RestEndpoint<'User', 'getCurrent'> = <T = UserProps>(
http: AxiosInstance,
params?: QueryParams
) => raw.get<T>(http, `/users/me`, { params: params?.query })
export const getManyForSpace: RestEndpoint<'User', 'getManyForSpace'> = (
http: AxiosInstance,
params: GetSpaceParams & QueryParams
) => {
return raw.get<CollectionProp<UserProps>>(http, `/spaces/${params.spaceId}/users`, {
params: params.query,
})
}
export const getForOrganization: RestEndpoint<'User', 'getForOrganization'> = (
http: AxiosInstance,
params: GetOrganizationParams & { userId: string }
) => {
return raw.get<UserProps>(http, `/organizations/${params.organizationId}/users/${params.userId}`)
}
export const getManyForOrganization: RestEndpoint<'User', 'getManyForOrganization'> = (
http: AxiosInstance,
params: GetOrganizationParams & QueryParams
) => {
return raw.get<CollectionProp<UserProps>>(http, `/organizations/${params.organizationId}/users`, {
params: params.query,
})
}