forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_subscriptions_command.go
49 lines (39 loc) · 1.04 KB
/
get_subscriptions_command.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
package ravendb
import (
"net/http"
"strconv"
)
var (
_ RavenCommand = &GetSubscriptionsCommand{}
)
// GetSubscriptionsCommand describes "delete subscription" command
type GetSubscriptionsCommand struct {
RavenCommandBase
start int
pageSize int
Result []*SubscriptionState
}
func newGetSubscriptionsCommand(start int, pageSize int) *GetSubscriptionsCommand {
cmd := &GetSubscriptionsCommand{
RavenCommandBase: NewRavenCommandBase(),
start: start,
pageSize: pageSize,
}
cmd.IsReadRequest = true
return cmd
}
func (c *GetSubscriptionsCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.URL + "/databases/" + node.Database + "/subscriptions?start=" + strconv.Itoa(c.start) + "&pageSize=" + strconv.Itoa(c.pageSize)
return newHttpGet(url)
}
func (c *GetSubscriptionsCommand) SetResponse(response []byte, fromCache bool) error {
if len(response) == 0 {
return nil
}
var res *GetSubscriptionsResult
if err := jsonUnmarshal(response, &res); err != nil {
return err
}
c.Result = res.Results
return nil
}