-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_channel_group_request.go
135 lines (101 loc) · 2.92 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package pubnub
import (
"fmt"
"net/http"
"net/url"
"github.com/pubnub/go/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 {
builder := deleteChannelGroupBuilder{
opts: &deleteChannelGroupOpts{
pubnub: pubnub,
},
}
return &builder
}
func newDeleteChannelGroupBuilderWithContext(
pubnub *PubNub, context Context) *deleteChannelGroupBuilder {
builder := deleteChannelGroupBuilder{
opts: &deleteChannelGroupOpts{
pubnub: pubnub,
ctx: context,
},
}
return &builder
}
// ChannelGroup sets the channel group to delete.
func (b *deleteChannelGroupBuilder) ChannelGroup(
cg string) *deleteChannelGroupBuilder {
b.opts.ChannelGroup = cg
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
}
type deleteChannelGroupOpts struct {
pubnub *PubNub
ChannelGroup string
Transport http.RoundTripper
ctx Context
}
func (o *deleteChannelGroupOpts) config() Config {
return *o.pubnub.Config
}
func (o *deleteChannelGroupOpts) client() *http.Client {
return o.pubnub.GetClient()
}
func (o *deleteChannelGroupOpts) context() Context {
return o.ctx
}
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)
return q, nil
}
func (o *deleteChannelGroupOpts) buildBody() ([]byte, error) {
return []byte{}, nil
}
func (o *deleteChannelGroupOpts) httpMethod() string {
return "GET"
}
func (o *deleteChannelGroupOpts) isAuthRequired() bool {
return true
}
func (o *deleteChannelGroupOpts) requestTimeout() int {
return o.pubnub.Config.NonSubscribeRequestTimeout
}
func (o *deleteChannelGroupOpts) connectTimeout() int {
return o.pubnub.Config.ConnectTimeout
}
func (o *deleteChannelGroupOpts) operationType() OperationType {
return PNRemoveGroupOperation
}
func (o *deleteChannelGroupOpts) telemetryManager() *TelemetryManager {
return o.pubnub.telemetryManager
}