From 2e752758f7474dcdc6330d930c829cacdaa2c341 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 19 Apr 2024 20:10:34 +0530 Subject: [PATCH] feat: update feedback + feedback response type + _put for API call --- src/apiResource.ts | 2 ++ src/apis/feedback.ts | 17 +++++++++++++++++ src/baseClient.ts | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/src/apiResource.ts b/src/apiResource.ts index d23b9ff..35b1db3 100644 --- a/src/apiResource.ts +++ b/src/apiResource.ts @@ -3,9 +3,11 @@ import type { Portkey } from "./index"; export class ApiResource { protected client: Portkey; protected post: Portkey["_post"] + protected put: Portkey["_put"] constructor(client: Portkey) { this.client = client this.post = client._post.bind(client) + this.put = client._put.bind(client) } } \ No newline at end of file diff --git a/src/apis/feedback.ts b/src/apis/feedback.ts index d0cf1a7..b77c814 100644 --- a/src/apis/feedback.ts +++ b/src/apis/feedback.ts @@ -7,6 +7,7 @@ import { createHeaders } from "./createHeaders"; interface FeedbackBodyBase { traceID?: string; + feedbackID?: string; value?: number; weight?: number; metadata?: Record @@ -17,6 +18,7 @@ type FeedbackBody = FeedbackBodyBase | Array export interface FeedbackResponse extends APIResponseType { status: string; message: string; + feedback_id: Array; } export class Feedback extends ApiResource { @@ -33,4 +35,19 @@ export class Feedback extends ApiResource { const response = this.post(FEEDBACK_API, { body, ...opts }) return response } + + update( + _body: FeedbackBodyBase, + params?: ApiClientInterface, + opts?: RequestOptions + ): APIPromise { + const body = _body + const feedbackID = _body.feedbackID + if (params) { + const config = overrideConfig(this.client.config, params.config) + this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params, config }) } + } + const response = this.put(FEEDBACK_API+'/'+feedbackID , { body, ...opts }) + return response + } } diff --git a/src/baseClient.ts b/src/baseClient.ts index db692b2..dfec106 100644 --- a/src/baseClient.ts +++ b/src/baseClient.ts @@ -141,6 +141,10 @@ export abstract class ApiClient { return this.methodRequest("post", path, opts); } + _put(path: string, opts?: RequestOptions): APIPromise { + return this.methodRequest("put", path, opts); + } + protected generateError( status: number | undefined, errorResponse: object | undefined,