Skip to content

Commit c6a1c82

Browse files
committed
feat: update open api
1 parent c63222d commit c6a1c82

File tree

8 files changed

+1481
-340
lines changed

8 files changed

+1481
-340
lines changed

__tests__/call.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,35 @@ describe('call API', () => {
253253
});
254254
});
255255

256+
it('closed caption settings', async () => {
257+
const response = await call.update({
258+
settings_override: {
259+
transcription: {
260+
mode: 'available',
261+
closed_caption_mode: 'disabled',
262+
},
263+
},
264+
});
265+
266+
expect(response.call.settings.transcription.mode).toBe('available');
267+
expect(response.call.settings.transcription.closed_caption_mode).toBe(
268+
'disabled',
269+
);
270+
expect(response.call.captioning).toBe(false);
271+
});
272+
273+
it('should start-stop closed captions', async () => {
274+
// somewhat dummy test, we should do a proper test in the future where we join a call and start recording
275+
await expect(() => call.startClosedCaptions()).rejects.toThrowError(
276+
'Stream error code 4: StartClosedCaptions failed with error: "there is no active session"',
277+
);
278+
279+
// somewhat dummy test, we should do a proper test in the future where we join a call and start recording
280+
await expect(() => call.stopClosedCaptions()).rejects.toThrowError(
281+
'Stream error code 4: StopClosedCaptions failed with error: "call is not being transcribed"',
282+
);
283+
});
284+
256285
it('delete call', async () => {
257286
try {
258287
await call.delete({ hard: true });

__tests__/create-test-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ const apiKey = process.env.STREAM_API_KEY!;
55
const secret = process.env.STREAM_SECRET!;
66

77
export const createTestClient = () => {
8-
return new StreamClient(apiKey, secret, { timeout: 10000 });
8+
return new StreamClient(apiKey, secret, {
9+
timeout: 10000,
10+
});
911
};

src/gen/chat/ChatApi.ts

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BaseApi } from '../../BaseApi';
22
import { StreamResponse } from '../../types';
33
import {
4+
CampaignResponse,
45
CastPollVoteRequest,
56
ChannelGetOrCreateRequest,
67
ChannelStateResponse,
@@ -16,18 +17,21 @@ import {
1617
DeleteChannelsResponse,
1718
DeleteCommandResponse,
1819
DeleteMessageResponse,
20+
DeleteSegmentTargetsRequest,
1921
EventResponse,
2022
ExportChannelsRequest,
2123
ExportChannelsResponse,
2224
FileUploadRequest,
2325
FileUploadResponse,
26+
GetCampaignResponse,
2427
GetChannelTypeResponse,
2528
GetCommandResponse,
2629
GetExportChannelsStatusResponse,
2730
GetManyMessagesResponse,
2831
GetMessageResponse,
2932
GetReactionsResponse,
3033
GetRepliesResponse,
34+
GetSegmentResponse,
3135
GetThreadResponse,
3236
HideChannelRequest,
3337
HideChannelResponse,
@@ -50,6 +54,8 @@ import {
5054
PollVotesResponse,
5155
QueryBannedUsersPayload,
5256
QueryBannedUsersResponse,
57+
QueryCampaignsRequest,
58+
QueryCampaignsResponse,
5359
QueryChannelsRequest,
5460
QueryChannelsResponse,
5561
QueryMembersPayload,
@@ -62,6 +68,10 @@ import {
6268
QueryPollsResponse,
6369
QueryReactionsRequest,
6470
QueryReactionsResponse,
71+
QuerySegmentTargetsRequest,
72+
QuerySegmentTargetsResponse,
73+
QuerySegmentsRequest,
74+
QuerySegmentsResponse,
6575
QueryThreadsRequest,
6676
QueryThreadsResponse,
6777
ReactionRemovalResponse,
@@ -77,6 +87,9 @@ import {
7787
ShowChannelRequest,
7888
ShowChannelResponse,
7989
SortParamRequest,
90+
StartCampaignRequest,
91+
StartCampaignResponse,
92+
StopCampaignRequest,
8093
TranslateMessageRequest,
8194
TruncateChannelRequest,
8295
TruncateChannelResponse,
@@ -108,6 +121,83 @@ import {
108121
import { decoders } from '../model-decoders';
109122

110123
export class ChatApi extends BaseApi {
124+
queryCampaigns = async (
125+
request?: QueryCampaignsRequest,
126+
): Promise<StreamResponse<QueryCampaignsResponse>> => {
127+
const body = {
128+
limit: request?.limit,
129+
next: request?.next,
130+
prev: request?.prev,
131+
sort: request?.sort,
132+
filter: request?.filter,
133+
};
134+
135+
const response = await this.sendRequest<
136+
StreamResponse<QueryCampaignsResponse>
137+
>('POST', '/api/v2/chat/campaigns/query', undefined, undefined, body);
138+
139+
decoders.QueryCampaignsResponse?.(response.body);
140+
141+
return { ...response.body, metadata: response.metadata };
142+
};
143+
144+
getCampaign = async (request: {
145+
id: string;
146+
}): Promise<StreamResponse<GetCampaignResponse>> => {
147+
const pathParams = {
148+
id: request?.id,
149+
};
150+
151+
const response = await this.sendRequest<
152+
StreamResponse<GetCampaignResponse>
153+
>('GET', '/api/v2/chat/campaigns/{id}', pathParams, undefined);
154+
155+
decoders.GetCampaignResponse?.(response.body);
156+
157+
return { ...response.body, metadata: response.metadata };
158+
};
159+
160+
startCampaign = async (
161+
request: StartCampaignRequest & { id: string },
162+
): Promise<StreamResponse<StartCampaignResponse>> => {
163+
const pathParams = {
164+
id: request?.id,
165+
};
166+
const body = {
167+
scheduled_for: request?.scheduled_for,
168+
stop_at: request?.stop_at,
169+
};
170+
171+
const response = await this.sendRequest<
172+
StreamResponse<StartCampaignResponse>
173+
>('POST', '/api/v2/chat/campaigns/{id}/start', pathParams, undefined, body);
174+
175+
decoders.StartCampaignResponse?.(response.body);
176+
177+
return { ...response.body, metadata: response.metadata };
178+
};
179+
180+
scheduleCampaign = async (
181+
request: StopCampaignRequest & { id: string },
182+
): Promise<StreamResponse<CampaignResponse>> => {
183+
const pathParams = {
184+
id: request?.id,
185+
};
186+
const body = {};
187+
188+
const response = await this.sendRequest<StreamResponse<CampaignResponse>>(
189+
'POST',
190+
'/api/v2/chat/campaigns/{id}/stop',
191+
pathParams,
192+
undefined,
193+
body,
194+
);
195+
196+
decoders.CampaignResponse?.(response.body);
197+
198+
return { ...response.body, metadata: response.metadata };
199+
};
200+
111201
queryChannels = async (
112202
request?: QueryChannelsRequest,
113203
): Promise<StreamResponse<QueryChannelsResponse>> => {
@@ -1758,6 +1848,137 @@ export class ChatApi extends BaseApi {
17581848
return { ...response.body, metadata: response.metadata };
17591849
};
17601850

1851+
querySegments = async (
1852+
request: QuerySegmentsRequest,
1853+
): Promise<StreamResponse<QuerySegmentsResponse>> => {
1854+
const body = {
1855+
filter: request?.filter,
1856+
limit: request?.limit,
1857+
next: request?.next,
1858+
prev: request?.prev,
1859+
sort: request?.sort,
1860+
};
1861+
1862+
const response = await this.sendRequest<
1863+
StreamResponse<QuerySegmentsResponse>
1864+
>('POST', '/api/v2/chat/segments/query', undefined, undefined, body);
1865+
1866+
decoders.QuerySegmentsResponse?.(response.body);
1867+
1868+
return { ...response.body, metadata: response.metadata };
1869+
};
1870+
1871+
deleteSegment = async (request: {
1872+
id: string;
1873+
}): Promise<StreamResponse<Response>> => {
1874+
const pathParams = {
1875+
id: request?.id,
1876+
};
1877+
1878+
const response = await this.sendRequest<StreamResponse<Response>>(
1879+
'DELETE',
1880+
'/api/v2/chat/segments/{id}',
1881+
pathParams,
1882+
undefined,
1883+
);
1884+
1885+
decoders.Response?.(response.body);
1886+
1887+
return { ...response.body, metadata: response.metadata };
1888+
};
1889+
1890+
getSegment = async (request: {
1891+
id: string;
1892+
}): Promise<StreamResponse<GetSegmentResponse>> => {
1893+
const pathParams = {
1894+
id: request?.id,
1895+
};
1896+
1897+
const response = await this.sendRequest<StreamResponse<GetSegmentResponse>>(
1898+
'GET',
1899+
'/api/v2/chat/segments/{id}',
1900+
pathParams,
1901+
undefined,
1902+
);
1903+
1904+
decoders.GetSegmentResponse?.(response.body);
1905+
1906+
return { ...response.body, metadata: response.metadata };
1907+
};
1908+
1909+
deleteSegmentTargets = async (
1910+
request: DeleteSegmentTargetsRequest & { id: string },
1911+
): Promise<StreamResponse<Response>> => {
1912+
const pathParams = {
1913+
id: request?.id,
1914+
};
1915+
const body = {
1916+
target_ids: request?.target_ids,
1917+
};
1918+
1919+
const response = await this.sendRequest<StreamResponse<Response>>(
1920+
'POST',
1921+
'/api/v2/chat/segments/{id}/deletetargets',
1922+
pathParams,
1923+
undefined,
1924+
body,
1925+
);
1926+
1927+
decoders.Response?.(response.body);
1928+
1929+
return { ...response.body, metadata: response.metadata };
1930+
};
1931+
1932+
segmentTargetExists = async (request: {
1933+
id: string;
1934+
target_id: string;
1935+
}): Promise<StreamResponse<Response>> => {
1936+
const pathParams = {
1937+
id: request?.id,
1938+
target_id: request?.target_id,
1939+
};
1940+
1941+
const response = await this.sendRequest<StreamResponse<Response>>(
1942+
'GET',
1943+
'/api/v2/chat/segments/{id}/target/{target_id}',
1944+
pathParams,
1945+
undefined,
1946+
);
1947+
1948+
decoders.Response?.(response.body);
1949+
1950+
return { ...response.body, metadata: response.metadata };
1951+
};
1952+
1953+
controllerNameQuerySegmentTargets = async (
1954+
request: QuerySegmentTargetsRequest & { id: string },
1955+
): Promise<StreamResponse<QuerySegmentTargetsResponse>> => {
1956+
const pathParams = {
1957+
id: request?.id,
1958+
};
1959+
const body = {
1960+
limit: request?.limit,
1961+
next: request?.next,
1962+
prev: request?.prev,
1963+
sort: request?.sort,
1964+
filter: request?.filter,
1965+
};
1966+
1967+
const response = await this.sendRequest<
1968+
StreamResponse<QuerySegmentTargetsResponse>
1969+
>(
1970+
'POST',
1971+
'/api/v2/chat/segments/{id}/targets/query',
1972+
pathParams,
1973+
undefined,
1974+
body,
1975+
);
1976+
1977+
decoders.QuerySegmentTargetsResponse?.(response.body);
1978+
1979+
return { ...response.body, metadata: response.metadata };
1980+
};
1981+
17611982
queryThreads = async (
17621983
request?: QueryThreadsRequest,
17631984
): Promise<StreamResponse<QueryThreadsResponse>> => {

0 commit comments

Comments
 (0)