/
user.ts
32 lines (27 loc) · 1.16 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
import { AxiosInstance } from 'axios'
import * as raw from './raw'
import { CollectionProp, QueryParams, GetSpaceParams, GetOrganizationParams } from './common-types'
import { UserProps } from '../../entities/user'
export const getForSpace = (http: AxiosInstance, params: GetSpaceParams & { userId: string }) => {
return raw.get<UserProps>(http, `/spaces/${params.spaceId}/users/${params.userId}`)
}
export const getCurrent = (http: AxiosInstance) => raw.get<UserProps>(http, `/users/me`)
export const getManyForSpace = (http: AxiosInstance, params: GetSpaceParams & QueryParams) => {
return raw.get<CollectionProp<UserProps>>(http, `/spaces/${params.spaceId}/users`, {
params: params.query,
})
}
export const getForOrganization = (
http: AxiosInstance,
params: GetOrganizationParams & { userId: string }
) => {
return raw.get<UserProps>(http, `/organizations/${params.organizationId}/users/${params.userId}`)
}
export const getManyForOrganization = (
http: AxiosInstance,
params: GetOrganizationParams & QueryParams
) => {
return raw.get<CollectionProp<UserProps>>(http, `/organizations/${params.organizationId}/users`, {
params: params.query,
})
}