@vonage/client-sdk 1.1.0-alpha.5 → 1.1.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,10 @@ export declare const LegStatus: typeof vonage.LegStatusJS;
24
24
  export type CallSayParams = Partial<vonage.CallSayParams> & {
25
25
  text: string;
26
26
  };
27
+ type JSONValue = string | number | boolean | {
28
+ [x: string]: JSONValue;
29
+ } | JSONValue[];
30
+ import { Conversation, ConversationsPage, EventsPage, Member, MembersPage, PresentingOrder } from '../utils';
27
31
  export declare const setVonageClientLoggingLevel: typeof vonage.setDefaultLoggingLevel;
28
32
  /**
29
33
  * VonageClient is the main entry point for the Vonage Client SDK.
@@ -46,13 +50,39 @@ export declare class VonageClient extends vonage.CombinedClientJS {
46
50
  /**
47
51
  * Register a callback for an event.
48
52
  *
49
- * NOTE: you can only register one callback per event.
50
- *
51
53
  * @param event - the event to register for (e.g. 'legStatusUpdate')
52
54
  * @param callback - the callback to register for the event
55
+ * @returns a symbol that can be used to unregister the callback
56
+ * @remarks
57
+ * Besure to store the symbol returned by this method so you can unregister the callback later.
58
+ * We recommend deregistering callbacks when you no longer need them. See {@link off}.
59
+ */
60
+ on<T extends keyof VonageEvent, Fn extends VonageEvent[T]>(event: T, callback: Fn): symbol;
61
+ /**
62
+ * Unregister a callback for an event.
63
+ *
64
+ * @param event - the event to register for (e.g. 'legStatusUpdate')
65
+ * @param callbackSymbol - the callback symbol to unregister
66
+ * @returns true if the callback was unregistered, false otherwise
67
+ * @remarks
68
+ * We recommend deregistering callbacks when you no longer need them.
69
+ */
70
+ off<T extends keyof VonageEvent>(event: T, callbackSymbol: symbol): boolean;
71
+ /**
72
+ * Clear all callbacks for an event.
73
+ *
74
+ * @param event - the event to register for (e.g. 'legStatusUpdate')
53
75
  * @returns void
76
+ *
77
+ * @remarks
78
+ * This is useful for cleaning up callbacks when you no longer need them.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * client.clearCallbacks('legStatusUpdate');
83
+ * ```
54
84
  */
55
- on<T extends keyof VonageEvent, Fn extends VonageEvent[T]>(event: T, callback: Fn): void;
85
+ clearCallbacks<T extends keyof VonageEvent>(event: T): void;
56
86
  /**
57
87
  * Create a session with a token and optional sessionId
58
88
  * If no sessionId is provided, a new one will be generated
@@ -98,5 +128,92 @@ export declare class VonageClient extends vonage.CombinedClientJS {
98
128
  * @returns void
99
129
  */
100
130
  say(callId: string, params: CallSayParams): Promise<void>;
131
+ /**
132
+ * Get a list of Conversations for the user.
133
+ *
134
+ * @param order - the order to return the conversations in (default: 'asc')
135
+ * @param pageSize - the number of conversations to return per page (default: 100)
136
+ * @param cursor - the cursor to use for pagination (default: null)
137
+ * @returns a `ConversationsPage` containing the conversations
138
+ */
139
+ getConversations(order?: PresentingOrder, pageSize?: number, cursor?: string | null): Promise<ConversationsPage>;
140
+ /**
141
+ * Get a Conversation's Events
142
+ *
143
+ * @param id - the Conversation's id
144
+ * @param order - the order to return the events in (default: 'asc')
145
+ * @param pageSize - the number of events to return per page (default: 100)
146
+ * @param cursor - the cursor to use for pagination (default: null)
147
+ * @returns a `EventsPage` containing the events
148
+ */
149
+ getConversationEvents(id: string, order?: PresentingOrder, pageSize?: number, cursor?: string | null): Promise<EventsPage>;
150
+ /**
151
+ * Get a Conversation's Members
152
+ * @param id - the Conversation's id
153
+ * @param order - the order to return the members in (default: 'asc')
154
+ * @param pageSize - the number of members to return per page (default: 100)
155
+ * @param cursor - the cursor to use for pagination (default: null)
156
+ * @returns a `MembersPage` containing the members
157
+ */
158
+ getConversationMembers(id: string, order?: PresentingOrder, pageSize?: number, cursor?: string | null): Promise<MembersPage>;
159
+ /**
160
+ * Create a conversation
161
+ * @param name - the name of the conversation
162
+ * @param displayName - the display name of the conversation
163
+ * @returns the `cid` of the conversation
164
+ */
165
+ createConversation(name?: string, displayName?: string): Promise<string>;
166
+ /**
167
+ * Get a Conversation
168
+ * @param id - the Conversation's id
169
+ * @returns the `Conversation`
170
+ */
171
+ getConversation(cid: string): Promise<Conversation>;
172
+ /**
173
+ * Leave a Conversation
174
+ * @param id - the Conversation's id
175
+ * @returns void
176
+ */
177
+ leaveConversation(id: string): Promise<void>;
178
+ /**
179
+ * Join a Conversation
180
+ * @param id - the Conversation's id
181
+ * @returns the `memberId` of the member
182
+ */
183
+ joinConversation(id: string): Promise<string>;
184
+ /**
185
+ * Delete a Conversation
186
+ * @param id - the Conversation's id
187
+ * @returns void
188
+ */
189
+ deleteConversation(id: string): Promise<void>;
190
+ /**
191
+ * Invite a user to a Conversation by user's `name`
192
+ * @param id - the Conversation's id
193
+ * @param name - the namne of the user to invite
194
+ * @returns the `memberId` of the member
195
+ */
196
+ inviteToConversation(id: string, name: string): Promise<string>;
197
+ /**
198
+ * Send a text message to a Conversation
199
+ * @param id - the Conversation's id
200
+ * @param text - the Body of the message
201
+ * @returns the `timestamp` of the message
202
+ */
203
+ sendTextMessage(id: string, text: string): Promise<string>;
204
+ /**
205
+ * Send a custom message to a Conversation
206
+ * @param id - the Conversation's id
207
+ * @param customData - the body of the message
208
+ * @returns the `timestamp` of the message
209
+ */
210
+ sendCustomMessage(id: string, customData: JSONValue): Promise<string>;
211
+ /**
212
+ * Get a Member of a Conversation
213
+ * @param cid - the Conversation's id
214
+ * @param mid - the Member's id
215
+ * @returns the `Member`
216
+ */
217
+ getConversationMember(cid: string, mid: string): Promise<Member>;
101
218
  }
102
219
  export default VonageClient;