Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update feedback #55

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/apiResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
17 changes: 17 additions & 0 deletions src/apis/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createHeaders } from "./createHeaders";

interface FeedbackBodyBase {
traceID?: string;
feedbackID?: string;
value?: number;
weight?: number;
metadata?: Record<string, any>
Expand All @@ -17,6 +18,7 @@ type FeedbackBody = FeedbackBodyBase | Array<FeedbackBodyBase>
export interface FeedbackResponse extends APIResponseType {
status: string;
message: string;
feedback_id: Array<string>;
}

export class Feedback extends ApiResource {
Expand All @@ -33,4 +35,19 @@ export class Feedback extends ApiResource {
const response = this.post<FeedbackResponse>(FEEDBACK_API, { body, ...opts })
return response
}

update(
_body: FeedbackBodyBase,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<FeedbackResponse> {
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<FeedbackResponse>(FEEDBACK_API+'/'+feedbackID , { body, ...opts })
return response
}
}
4 changes: 4 additions & 0 deletions src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ export abstract class ApiClient {
return this.methodRequest("post", path, opts);
}

_put<Rsp extends APIResponseType>(path: string, opts?: RequestOptions): APIPromise<Rsp> {
return this.methodRequest("put", path, opts);
}

protected generateError(
status: number | undefined,
errorResponse: object | undefined,
Expand Down
Loading