/
Invitations.ts
75 lines (73 loc) · 2.48 KB
/
Invitations.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { ClassDoAPIClient, Result } from '.'
import { InvitationKeys, buildSendInvitationMutation, InvitationOption, InvitationResult } from '../models/Invitations';
import { RoomKeys } from '../models/Rooms';
import { OrganizationKeys } from '../models/Organizations';
import { RoomMemberKeys } from '../models/RoomMembers';
import { UserKeys } from '../models/Users';
import { UserProfileKeys } from '../models/UserProfiles';
import { MutationSendInvitationArgs } from '../generated/graphql';
import { EmailKeys } from '../models/Emails';
/** Client to call mutation for invitations */
export class InvitatationsClient {
/** @ignore */
constructor(private client: ClassDoAPIClient) {}
/**
* Send an invitatoin.
*
* ```typescript
* client.invitatoins.send(['id'], {
* data: {
* contactFullName: 'joe',
* contactType: ContactType.Email,
* contactInfo: 'example@gmail.com',
* organizationMemberRoleId: 'xxxxxxxxxxxxxxxxxx',
* roomId: 'xxxxxxxxxxxxxxxxxx',
* locale: Enum.Locale.En
* }
* }).then(v => {
* console.log(v)
* })
* ```
*
* If you don't want to send a notificatoin message from classdo, you can use `withoutNotificattion` flag.
*
* ```typescript
* client.invitatoins.send(['id'], {
* data: {
* contactFullName: 'joe',
* contactType: ContactType.Email,
* contactInfo: 'example@gmail.com',
* organizationMemberRoleId: 'xxxxxxxxxxxxxxxxxx',
* roomId: 'xxxxxxxxxxxxxxxxxx',
* locale: Enum.Locale.En,
* withoutNotification: true
* }
* }).then(v => {
* console.log(v)
* })
* ```
*
* @param fields Array of [[Invitation]] key names. Returns specified fields as result.
* @param args
* @param option
*/
async send<
I extends InvitationKeys,
R extends RoomKeys | null,
R_O extends OrganizationKeys | null,
R_RM extends RoomMemberKeys | null,
R_RM_U extends UserKeys | null,
R_RM_U_UP extends UserProfileKeys | null,
R_RM_U_UP_E extends EmailKeys | null,
O extends OrganizationKeys | null
>(
fields: I[],
args: MutationSendInvitationArgs,
option?: InvitationOption<R, R_O, R_RM, R_RM_U, R_RM_U_UP, R_RM_U_UP_E, O>
): Promise<Result<InvitationResult<I, R, R_O, R_RM, R_RM_U, R_RM_U_UP, R_RM_U_UP_E, O>>> {
const result = await this.client.mutate(
buildSendInvitationMutation(fields, args, option)
)
return { errors: result.errors, data: result.data?.sendInvitation || null }
}
}