From 781851152729429a4550c6e16d78e27828235ff3 Mon Sep 17 00:00:00 2001 From: Ferris Chi Date: Sun, 4 Aug 2024 20:35:07 -0400 Subject: [PATCH] add delete apis --- client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 7a839d1..12ebef2 100644 --- a/client.go +++ b/client.go @@ -18,11 +18,12 @@ import ( "context" "encoding/json" "fmt" - "github.com/zhenghaoz/gorse/base/log" "io" "net/http" "strings" + "github.com/zhenghaoz/gorse/base/log" + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) @@ -48,6 +49,14 @@ func (c *GorseClient) ListFeedbacks(ctx context.Context, feedbackType, userId st return request[[]Feedback, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/user/"+userId+"/feedback/"+feedbackType), nil) } +func (c *GorseClient) DeleteFeedback(ctx context.Context, feedbackType, userId, itemId string) (Feedback, error) { + return request[Feedback, any](ctx, c, "DELETE", c.entryPoint+fmt.Sprintf("/api/feedback/%s/%s/%s", feedbackType, userId, itemId), nil) +} + +func (c *GorseClient) DeleteFeedbacks(ctx context.Context, userId, itemId string) ([]Feedback, error) { + return request[[]Feedback, any](ctx, c, "DELETE", c.entryPoint+fmt.Sprintf("/api/feedback/%s/%s", userId, itemId), nil) +} + func (c *GorseClient) GetRecommend(ctx context.Context, userId string, category string, n, offset int) ([]string, error) { return request[[]string, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/recommend/%s/%s?n=%d&offset=%v", userId, category, n, offset), nil) }