Skip to content

Commit

Permalink
fix: toQueryParams has been added to utils.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-pareek committed Oct 7, 2024
1 parent 647b839 commit 6d5fbd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
12 changes: 1 addition & 11 deletions src/apis/virtualKeys.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 VirtualKeysAddParams {
name?: string;
Expand Down Expand Up @@ -65,17 +66,6 @@ export interface VirtualKeysDeleteParams {
slug?: string;
}

function toQueryParams(params?: VirtualKeysListParams): 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 VirtualKeys extends ApiResource {
constructor(client: any) {
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 { VirtualKeysListParams } from "./apis/virtualKeys";

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 |VirtualKeysListParams)): string {
if (!params) {
return '';
}
Expand All @@ -141,4 +142,4 @@ export function toQueryParams(params?: (UsersListParams | UserInviteListParams |
.join('&');

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

0 comments on commit 6d5fbd9

Please sign in to comment.