Skip to content

Commit

Permalink
feat: implement delete call endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Jun 20, 2024
1 parent 2d81816 commit 5a148a2
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 10 deletions.
6 changes: 6 additions & 0 deletions __tests__/call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,11 @@ describe('call API', () => {
);
});
});

it('delete', async () => {
const response = await call.delete({ hard: true });

expect(response.call.cid).toBe(call.cid);
});
});
});
4 changes: 2 additions & 2 deletions __tests__/external-recording-storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('external storage CRUD API', () => {
const response = await client.video.createExternalStorage({
name: storageName,
bucket: 'test',
storage_type: 'test',
storage_type: 'abs',
});

expect(response).toBeDefined();
Expand All @@ -32,7 +32,7 @@ describe('external storage CRUD API', () => {
const newBucket = 'new bucket';
const response = await client.video.updateExternalStorage(storageName, {
bucket: newBucket,
storage_type: 'test',
storage_type: 'abs',
});

expect(response.bucket).toBe('new bucket');
Expand Down
16 changes: 14 additions & 2 deletions src/StreamCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
GetCallStatsRequest,
ProductvideoApi,
VideoBlockUserRequest,
VideoDeleteCallRequest,
VideoGetOrCreateCallRequest,
VideoGoLiveRequest,
VideoMuteUsersRequest,
Expand All @@ -28,21 +29,32 @@ export class StreamCall {

constructor(
private readonly streamClient: StreamClient,
private readonly type: string,
private readonly id: string,
public readonly type: string,
public readonly id: string,
) {
this.baseRequest = { id: this.id, type: this.type };
const configuration = this.streamClient.getConfiguration('video');
this.apiClient = new ProductvideoApi(configuration);
}

get cid() {
return `${this.type}:${this.id}`;
}

blockUser = (videoBlockUserRequest: VideoBlockUserRequest) => {
return this.apiClient.blockUser({
...this.baseRequest,
videoBlockUserRequest,
});
};

delete = (videoDeleteCallRequest?: VideoDeleteCallRequest) => {
return this.apiClient.deleteCall({
...this.baseRequest,
videoDeleteCallRequest: videoDeleteCallRequest ?? null,
});
};

endCall = () => {
return this.apiClient.endCall({ ...this.baseRequest });
};
Expand Down
65 changes: 64 additions & 1 deletion src/gen/video/apis/ProductvideoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Stream API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v116.0.0
* The version of the OpenAPI document: v120.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -28,6 +28,8 @@ import type {
VideoCreateExternalStorageResponse,
VideoCreateGuestRequest,
VideoCreateGuestResponse,
VideoDeleteCallRequest,
VideoDeleteCallResponse,
VideoDeleteExternalStorageResponse,
VideoDeleteRecordingResponse,
VideoDeleteTranscriptionResponse,
Expand Down Expand Up @@ -116,6 +118,12 @@ export interface CreateGuestRequest {
videoCreateGuestRequest: VideoCreateGuestRequest | null;
}

export interface DeleteCallRequest {
type: string;
id: string;
videoDeleteCallRequest: VideoDeleteCallRequest | null;
}

export interface DeleteCallTypeRequest {
name: string;
}
Expand Down Expand Up @@ -650,6 +658,61 @@ export class ProductvideoApi extends runtime.BaseAPI {
return await response.value();
}

/**
* Sends events: - call.deleted Required permissions: - DeleteCall
* Delete Call
*/
async deleteCallRaw(requestParameters: DeleteCallRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<VideoDeleteCallResponse>> {
if (requestParameters.type === null || requestParameters.type === undefined) {
throw new runtime.RequiredError('type','Required parameter requestParameters.type was null or undefined when calling deleteCall.');
}

if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling deleteCall.');
}

if (requestParameters.videoDeleteCallRequest === null || requestParameters.videoDeleteCallRequest === undefined) {
throw new runtime.RequiredError('videoDeleteCallRequest','Required parameter requestParameters.videoDeleteCallRequest was null or undefined when calling deleteCall.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

if (this.configuration && this.configuration.apiKey) {
headerParameters["Stream-Auth-Type"] = this.configuration.apiKey("Stream-Auth-Type"); // stream-auth-type authentication
}

if (this.configuration && this.configuration.apiKey) {
queryParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
}

if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // JWT authentication
}

const response = await this.request({
path: `/video/call/{type}/{id}/delete`.replace(`{${"type"}}`, encodeURIComponent(String(requestParameters.type))).replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: requestParameters.videoDeleteCallRequest,
}, initOverrides);

return new runtime.JSONApiResponse(response);
}

/**
* Sends events: - call.deleted Required permissions: - DeleteCall
* Delete Call
*/
async deleteCall(requestParameters: DeleteCallRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<VideoDeleteCallResponse> {
const response = await this.deleteCallRaw(requestParameters, initOverrides);
return await response.value();
}

/**
*
* Delete Call Type
Expand Down
Loading

0 comments on commit 5a148a2

Please sign in to comment.