Skip to content

Commit

Permalink
feat: add uncomplete feedback apis (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: ubrmnsh <[email protected]>
  • Loading branch information
ubrmnsh and ubrmnsh authored Aug 3, 2023
1 parent 921ab8b commit e3e1f8d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gorsejs",
"description": "",
"version": "0.4.7",
"version": "0.4.8",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "Apache-2.0",
Expand Down
14 changes: 12 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
getFeedbacks,
getFeedbacksByType,
insertFeedbacks,
itemFeedbackByType,
itemFeedbacks,
upsertFeedbacks,
userFeedbackByType,
userFeedbacks,
Expand Down Expand Up @@ -149,12 +151,20 @@ class Gorse<T extends string> {
return upsertFeedbacks<T>(this.axiosClient, feedbacksList);
}

getItemFeedback(itemId: string) {
return itemFeedbacks(this.axiosClient, itemId);
}

getItemFeedbackByType(itemId: string, feedbackType: string) {
return itemFeedbackByType(this.axiosClient, { itemId, feedbackType });
}

getUserFeedback(userId: string) {
return userFeedbacks(this.axiosClient, userId);
}

getUserFeedbackByType(userId: string, type: string) {
return userFeedbackByType(this.axiosClient, { userId, feedbackType: type });
getUserFeedbackByType(userId: string, feedbackType: string) {
return userFeedbackByType(this.axiosClient, { userId, feedbackType });
}

// Item
Expand Down
20 changes: 18 additions & 2 deletions src/model/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,25 @@ export function upsertFeedbacks<T extends string>(
});
}

// TODO - Item Feedbacks
export function itemFeedbacks<T extends string>(
axios: AxiosInstance,
itemId: T
) {
return axios
.get<Success, AxiosResponse<Feedback<T>[]>>(`/item/${itemId}/feedback`)
.then(({ data }) => data);
}

// TODO - User Feedbacks
export function itemFeedbackByType<T extends string>(
axios: AxiosInstance,
{ itemId, feedbackType }: { itemId: T; feedbackType: T }
) {
return axios
.get<Success, AxiosResponse<Feedback<T>[]>>(
`/item/${itemId}/feedback/${feedbackType}`
)
.then(({ data }) => data);
}

export function userFeedbacks<T extends string>(
axios: AxiosInstance,
Expand Down

0 comments on commit e3e1f8d

Please sign in to comment.