-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteraction_purchase.go
55 lines (48 loc) · 1.34 KB
/
interaction_purchase.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
package recombee
import (
"fmt"
"net/http"
)
// AddPurchase adds a purchase of the given item made by the given user.
func AddPurchase(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: "/purchases/",
Method: http.MethodPost,
Params: params,
}
}
// DeletePurchase deletes an existing purchase uniquely specified by userId, itemId, and timestamp or all the purchases
// with the given userId and itemId if timestamp is omitted.
func DeletePurchase(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: "/purchases/",
Method: http.MethodDelete,
Params: params,
}
}
// ListItemPurchases lists all the ever-made purchases of the given item.
func ListItemPurchases(itemId string) Request {
return Request{
Path: fmt.Sprintf("/items/%s/purchases/", itemId),
Method: http.MethodGet,
}
}
// ListUserPurchases lists all the purchases ever made by the given user.
func ListUserPurchases(userId string) Request {
return Request{
Path: fmt.Sprintf("/users/%s/purchases/", userId),
Method: http.MethodGet,
}
}