Skip to content

Commit

Permalink
fix: utils.ts updated with toQueryParams
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-pareek committed Oct 7, 2024
1 parent 14519ec commit f39fe09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
13 changes: 1 addition & 12 deletions src/apis/apiKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ApiResource } from "../apiResource";
import { APIResponseType, ApiClientInterface } from "../_types/generalTypes";
import { APIPromise, RequestOptions } from "../baseClient";
import { createHeaders } from "./createHeaders";
import { toQueryParams } from "portkey-ai/utils";

export interface ApiKeysAddParams {
type?: string;
Expand Down Expand Up @@ -70,18 +71,6 @@ export interface ApiKeysListResponse extends APIResponseType {
export interface ApiKeysDeleteParams {
id?: string;
}

function toQueryParams(params?: ApiKeysListParams): 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 ApiKeys extends ApiResource {
constructor(client: any) {
super(client);
Expand Down
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createResponseHeaders } from "./streaming";
import OpenAI from "openai";
import type { Portkey } from "./index";
import { UserInviteListParams, UsersListParams, WorkspaceMemberListParams, WorkspacesListParams } from "./apis/admin";
import { ApiKeysListParams } from "./apis/apiKeys";

type PlatformProperties = {
"x-portkey-runtime"?: string,
Expand Down Expand Up @@ -131,7 +132,7 @@ export function initOpenAIClient(client: Portkey){
maxRetries: 0
})
}
export function toQueryParams(params?: (UsersListParams | UserInviteListParams | WorkspacesListParams | WorkspaceMemberListParams)): string {
export function toQueryParams(params?: (UsersListParams | UserInviteListParams | WorkspacesListParams | WorkspaceMemberListParams | ApiKeysListParams)): string {
if (!params) {
return '';
}
Expand All @@ -141,4 +142,4 @@ export function toQueryParams(params?: (UsersListParams | UserInviteListParams |
.join('&');

return queryParams ? `?${queryParams}` : '';
}
}

0 comments on commit f39fe09

Please sign in to comment.