-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathdelete_channel_group_request.go
106 lines (83 loc) · 2.64 KB
/
delete_channel_group_request.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package pubnub
import (
"fmt"
"net/http"
"net/url"
"github.com/pubnub/go/v7/utils"
)
const deleteChannelGroupPath = "/v1/channel-registration/sub-key/%s/channel-group/%s/remove"
var emptyDeleteChannelGroupResponse *DeleteChannelGroupResponse
type deleteChannelGroupBuilder struct {
opts *deleteChannelGroupOpts
}
func newDeleteChannelGroupBuilder(pubnub *PubNub) *deleteChannelGroupBuilder {
return newDeleteChannelGroupBuilderWithContext(pubnub, pubnub.ctx)
}
func newDeleteChannelGroupBuilderWithContext(
pubnub *PubNub, context Context) *deleteChannelGroupBuilder {
builder := deleteChannelGroupBuilder{
opts: newDeleteChannelGroupOpts(
pubnub,
context,
deleteChannelGroupOpts{},
),
}
return &builder
}
// ChannelGroup sets the channel group to delete.
func (b *deleteChannelGroupBuilder) ChannelGroup(
cg string) *deleteChannelGroupBuilder {
b.opts.ChannelGroup = cg
return b
}
// QueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.
func (b *deleteChannelGroupBuilder) QueryParam(queryParam map[string]string) *deleteChannelGroupBuilder {
b.opts.QueryParam = queryParam
return b
}
// Execute runs the DeleteChannelGroup request.
func (b *deleteChannelGroupBuilder) Execute() (
*DeleteChannelGroupResponse, StatusResponse, error) {
_, status, err := executeRequest(b.opts)
if err != nil {
return emptyDeleteChannelGroupResponse, status, err
}
return emptyDeleteChannelGroupResponse, status, nil
}
func newDeleteChannelGroupOpts(pubnub *PubNub, ctx Context, opts deleteChannelGroupOpts) *deleteChannelGroupOpts {
opts.endpointOpts = endpointOpts{
pubnub: pubnub,
ctx: ctx,
}
return &opts
}
type deleteChannelGroupOpts struct {
endpointOpts
ChannelGroup string
Transport http.RoundTripper
QueryParam map[string]string
}
func (o *deleteChannelGroupOpts) validate() error {
if o.config().SubscribeKey == "" {
return newValidationError(o, StrMissingSubKey)
}
if o.ChannelGroup == "" {
return newValidationError(o, StrMissingChannelGroup)
}
return nil
}
// DeleteChannelGroupResponse is response structure for Delete Channel Group function
type DeleteChannelGroupResponse struct{}
func (o *deleteChannelGroupOpts) buildPath() (string, error) {
return fmt.Sprintf(deleteChannelGroupPath,
o.pubnub.Config.SubscribeKey,
utils.URLEncode(o.ChannelGroup)), nil
}
func (o *deleteChannelGroupOpts) buildQuery() (*url.Values, error) {
q := defaultQuery(o.pubnub.Config.UUID, o.pubnub.telemetryManager)
SetQueryParam(q, o.QueryParam)
return q, nil
}
func (o *deleteChannelGroupOpts) operationType() OperationType {
return PNRemoveGroupOperation
}