diff --git a/package.json b/package.json index 29e692f..d5232a8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/client.ts b/src/client.ts index 503b127..b511556 100644 --- a/src/client.ts +++ b/src/client.ts @@ -27,6 +27,8 @@ import { getFeedbacks, getFeedbacksByType, insertFeedbacks, + itemFeedbackByType, + itemFeedbacks, upsertFeedbacks, userFeedbackByType, userFeedbacks, @@ -149,12 +151,20 @@ class Gorse { return upsertFeedbacks(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 diff --git a/src/model/feedback.ts b/src/model/feedback.ts index 5c42bf1..246c75f 100644 --- a/src/model/feedback.ts +++ b/src/model/feedback.ts @@ -89,9 +89,25 @@ export function upsertFeedbacks( }); } -// TODO - Item Feedbacks +export function itemFeedbacks( + axios: AxiosInstance, + itemId: T +) { + return axios + .get[]>>(`/item/${itemId}/feedback`) + .then(({ data }) => data); +} -// TODO - User Feedbacks +export function itemFeedbackByType( + axios: AxiosInstance, + { itemId, feedbackType }: { itemId: T; feedbackType: T } +) { + return axios + .get[]>>( + `/item/${itemId}/feedback/${feedbackType}` + ) + .then(({ data }) => data); +} export function userFeedbacks( axios: AxiosInstance,