-
Notifications
You must be signed in to change notification settings - Fork 0
/
interaction_rating.go
56 lines (49 loc) · 1.38 KB
/
interaction_rating.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package recombee
import (
"fmt"
"net/http"
)
// AddRating adds a rating of the given item made by the given user.
func AddRating(userId string, itemId string, rating float64, opts ...RequestOption) Request {
params := make(map[string]interface{})
params["userId"] = userId
params["itemId"] = itemId
params["rating"] = rating
for _, o := range opts {
o(params)
}
return Request{
Path: "/ratings/",
Method: http.MethodPost,
Params: params,
}
}
// DeleteRating deletes an existing rating specified by (userId, itemId, timestamp) from the database or all the
// ratings with the given userId and itemId if timestamp is omitted.
func DeleteRating(userId string, itemId string, opts ...RequestOption) Request {
params := make(map[string]interface{})
params["userId"] = userId
params["itemId"] = itemId
for _, o := range opts {
o(params)
}
return Request{
Path: "/ratings/",
Method: http.MethodDelete,
Params: params,
}
}
// ListItemRatings lists all the ratings of an item ever submitted by different users.
func ListItemRatings(itemId string) Request {
return Request{
Path: fmt.Sprintf("/items/%s/ratings/", itemId),
Method: http.MethodGet,
}
}
// ListUserRatings lists all the ratings ever submitted by the given user.
func ListUserRatings(userId string) Request {
return Request{
Path: fmt.Sprintf("/users/%s/ratings/", userId),
Method: http.MethodGet,
}
}