Skip to content

Commit

Permalink
fix: add missing listConfigsParam type
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-pareek committed Sep 30, 2024
1 parent 48b57db commit cd18c16
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/apis/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export interface ConfigsUpdateParams {
config?: Record<string, unknown>;
status?: string;
}

export interface CongfigsListParams {
workspace_id?: string;
}
export interface ConfigsCreateResponse extends APIResponseType {
id?: string;
version_id?: string;
Expand Down Expand Up @@ -53,6 +55,17 @@ export interface ConfigsUpdateResponse extends APIResponseType {
version_id?: string;
object?: string;
}
function toQueryParams(params?: CongfigsListParams): string {
if (!params) {
return '';
}
const queryParams = Object.entries(params)
.filter(([, value]) => value !== undefined && value !== null)
.map(([key, value]) => `${key}=${value}`)
.join('&');

return queryParams ? `?${queryParams}` : '';
}
export class Configs extends ApiResource {
constructor(client: any) {
super(client);
Expand Down Expand Up @@ -103,10 +116,11 @@ export class Configs extends ApiResource {
opts?: RequestOptions
):APIPromise<ConfigsListResponse>{
const body = _body;
const query = toQueryParams(body);
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.get<ConfigsListResponse>(`/configs`, { body, ...opts});
const response = this.get<ConfigsListResponse>(`/configs${query}`, {...opts});
return response;
}
}
Expand Down

0 comments on commit cd18c16

Please sign in to comment.