cisco-spark-ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ciscospark +417 -397
- data/bin/cs +265 -0
- data/lib/base.rb +34 -30
- data/lib/cisco-spark-ruby.rb +120 -105
- data/lib/cli.rb +21 -0
- data/lib/collection.rb +28 -20
- data/lib/membership.rb +28 -28
- data/lib/memberships.rb +14 -15
- data/lib/message.rb +28 -27
- data/lib/messages.rb +42 -16
- data/lib/people.rb +14 -15
- data/lib/person.rb +29 -26
- data/lib/room.rb +27 -28
- data/lib/rooms.rb +21 -19
- data/lib/team.rb +27 -18
- data/lib/teammembership.rb +28 -28
- data/lib/teammemberships.rb +14 -15
- data/lib/teams.rb +14 -15
- data/lib/webhook.rb +24 -24
- data/lib/webhooks.rb +14 -14
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a44ea106ba3591361fde501303512df72c9ce028
|
4
|
+
data.tar.gz: 81749952c556b4751decee830384a316c4293212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f51072673fea4331ca3274a267bd89eef4dce0cc0e13835a41fef0815124c745564f067a59d35969a92b071080f146d64d0ba9990b54911838c6963b3931204
|
7
|
+
data.tar.gz: 8459a3b057bdf11595ce8e1da9771ade7802c25c3dfbf5d9db0fcd7d19372ad41fa6e05b9e9301601cea3069d60f111a3cb6c1f996cdc731159327b4c1efa73b
|
data/bin/ciscospark
CHANGED
@@ -1,418 +1,438 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'optparse/subcommand'
|
4
|
-
|
4
|
+
$LOAD_PATH.push("/Users/robertlabrie/Documents/code/cisco-spark-ruby/lib")
|
5
5
|
|
6
6
|
require 'cisco-spark-ruby'
|
7
7
|
options = {}
|
8
8
|
parser = OptionParser.new do |opts|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
23
|
-
end
|
24
|
-
subcommand.subcommand 'delete' do |action|
|
25
|
-
options[:action] = 'delete'
|
26
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'webhook-delete'}
|
27
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
28
|
-
end
|
29
|
-
subcommand.subcommand 'create' do |action|
|
30
|
-
options[:action] = 'create'
|
31
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'webhook-create'}
|
32
|
-
action.on('-n','--name name','A user-friendly name for the webhook.') { |o| options[:name] = o}
|
33
|
-
action.on('-u','--targetUrl targetUrl','The URL that receives POST requests for each event.') { |o| options[:targetUrl] = o}
|
34
|
-
action.on('-r','--resource resource','The resource type for the webhook. Creating a webhook requires read scope on the resource the webhook is for.') { |o| options[:resource] = o}
|
35
|
-
action.on('-e','--event event','The event type for the webhook.') { |o| options[:event] = o}
|
36
|
-
action.on('-f','--filter filter','The filter that defines the webhook scope.') { |o| options[:filter] = o}
|
37
|
-
action.on('-s','--secret secret','The secret used to generate payload signature.') { |o| options[:secret] = o}
|
38
|
-
end
|
39
|
-
subcommand.subcommand 'update' do |action|
|
40
|
-
options[:action] = 'update'
|
41
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'webhook-update'}
|
42
|
-
action.on('-n','--name name','A user-friendly name for the webhook.') { |o| options[:name] = o}
|
43
|
-
action.on('-u','--targetUrl targetUrl','The URL that receives POST requests for each event.') { |o| options[:targetUrl] = o}
|
44
|
-
action.on('-s','--secret secret','The secret used to generate payload signature.') { |o| options[:secret] = o}
|
45
|
-
action.on('-t','--status status','The status of the webhook. Use active to reactivate a disabled webhook.') { |o| options[:status] = o}
|
46
|
-
end
|
47
|
-
|
9
|
+
opts.on('-h', '--help', 'Show Help') do
|
10
|
+
options[:help] = "Available subcommands:\npeople\nrooms\nmemberships\nmessages\nteams\nteammemberships\nwebhooks"
|
11
|
+
end
|
12
|
+
opts.subcommand 'people' do |subcommand|
|
13
|
+
options[:entity] = 'people'
|
14
|
+
subcommand.on('-h', '--help', 'Show help') { |_o| options[:help] = "Available subcommands:\nlist\ncreate\nget\nupdate\ndelete" }
|
15
|
+
subcommand.subcommand 'list' do |action|
|
16
|
+
options[:action] = 'list'
|
17
|
+
action.on('-e', '--email email', 'List people with this email address. For non-admin requests, either this or displayName are required.') { |o| options[:email] = o }
|
18
|
+
action.on('-d', '--displayName displayName ', 'List people whose name starts with this string. For non-admin requests, either this or email are required.') { |o| options[:displayName] = o }
|
19
|
+
action.on('-i', '--id id', 'List people by ID. Accepts up to 85 person IDs separated by commas.') { |o| options[:id] = o }
|
20
|
+
action.on('-o', '--orgId orgId', 'List people in this organization. Only admin users of another organization (such as partners) may use this parameter.') { |o| options[:orgId] = o }
|
21
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
48
22
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
options[:action] = 'get'
|
61
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'message-get'}
|
62
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
63
|
-
end
|
64
|
-
subcommand.subcommand 'delete' do |action|
|
65
|
-
options[:action] = 'delete'
|
66
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'message-delete'}
|
67
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
68
|
-
end
|
69
|
-
subcommand.subcommand 'create' do |action|
|
70
|
-
options[:action] = 'create'
|
71
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'message-create'}
|
72
|
-
action.on('-r','--roomId roomId','The room ID') { |o| options[:roomId] = o}
|
73
|
-
action.on('-p','--toPersonId toPersonId','The ID of the recipient when sending a private 1:1 message') { |o| options[:toPersonId] = o}
|
74
|
-
action.on('-e','--toPersonEmail toPersonEmail','The ID of the recipient when sending a private 1:1 message') { |o| options[:toPersonEmail] = o}
|
75
|
-
action.on('-m','--markdown markdown','The message, in markdown format') { |o| options[:markdown] = o}
|
76
|
-
action.on('-t','--text text','The message, in text format') { |o| options[:text] = o}
|
77
|
-
action.on('-f','--files files','The public URL to a file to be posted in the room') { |o| options[:files] = o}
|
78
|
-
end
|
79
|
-
|
23
|
+
subcommand.subcommand 'create' do |action|
|
24
|
+
options[:action] = 'get'
|
25
|
+
action.on('-e', '--emails emails', 'Email addresses of the person') { |o| options[:emails] = o }
|
26
|
+
action.on('-d', '--displayName displayName', 'Full name of the person') { |o| options[:displayName] = o }
|
27
|
+
action.on('-f', '--firstName firstName', 'First name of the person') { |o| options[:firstName] = o }
|
28
|
+
action.on('-l', '--lastName lastName', 'Last name of the person') { |o| options[:lastName] = o }
|
29
|
+
action.on('-a', '--avatar avatar', 'URL to persons avatar in PNG format') { |o| options[:avatar] = o }
|
30
|
+
action.on('-o', '--orgId orgId', 'ID of the organization to which the person belongs') { |o| options[:orgId] = o }
|
31
|
+
action.on('-r', '--roles roles', 'Roles of the person') { |o| options[:roles] = o }
|
32
|
+
action.on('-c', '--licenses licenses', 'Licenses allocated to the person') { |o| options[:licenses] = o }
|
33
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
80
34
|
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
options[:action] = 'list'
|
86
|
-
action.on('-t','--teamId teamId ','List team memberships for a team, by ID') { |o| options[:teamId] = o}
|
87
|
-
end
|
88
|
-
subcommand.subcommand 'get' do |action|
|
89
|
-
options[:action] = 'get'
|
90
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'teammembership-get'}
|
91
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
92
|
-
end
|
93
|
-
subcommand.subcommand 'update' do |action|
|
94
|
-
options[:action] = 'update'
|
95
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'teammembership-update'}
|
96
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
97
|
-
action.on('-m','--isModerator isModerator','Set true to make the person a moderator') { |o| options[:isModerator] = o}
|
98
|
-
end
|
99
|
-
|
100
|
-
subcommand.subcommand 'delete' do |action|
|
101
|
-
options[:action] = 'delete'
|
102
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'teammembership-delete'}
|
103
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
104
|
-
end
|
105
|
-
subcommand.subcommand 'create' do |action|
|
106
|
-
options[:action] = 'create'
|
107
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'teammembership-create'}
|
108
|
-
action.on('-t','--teamId teamId ','List team memberships for a team, by ID') { |o| options[:teamId] = o}
|
109
|
-
action.on('-p','--personId personId','The person ID') { |o| options[:personId] = o}
|
110
|
-
action.on('-e','--personEmail personEmail','The person email') { |o| options[:personEmail] = o}
|
111
|
-
action.on('-m','--isModerator isModerator','Set to true to make the person a moderator') { |o| options[:isModerator] = o}
|
112
|
-
end
|
113
|
-
|
35
|
+
subcommand.subcommand 'get' do |action|
|
36
|
+
options[:action] = 'get'
|
37
|
+
action.on('-i', '--id id', 'personId') { |o| options[:id] = o }
|
38
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
114
39
|
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'membership-get'}
|
128
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
129
|
-
end
|
130
|
-
subcommand.subcommand 'delete' do |action|
|
131
|
-
options[:action] = 'delete'
|
132
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'membership-delete'}
|
133
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
134
|
-
end
|
135
|
-
subcommand.subcommand 'update' do |action|
|
136
|
-
options[:action] = 'update'
|
137
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'membership-update'}
|
138
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
139
|
-
action.on('-m','--isModerator isModerator','Set true to make the person a moderator') { |o| options[:isModerator] = o}
|
140
|
-
end
|
141
|
-
subcommand.subcommand 'create' do |action|
|
142
|
-
options[:action] = 'create'
|
143
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'membership-create'}
|
144
|
-
action.on('-r','--roomId roomId','The room ID') { |o| options[:roomId] = o}
|
145
|
-
action.on('-p','--personId personId','The person ID') { |o| options[:personId] = o}
|
146
|
-
action.on('-e','--personEmail personEmail','The email address of the person') { |o| options[:personEmail] = o}
|
147
|
-
action.on('-m','--isModerator isModerator','Set true to make the person a moderator') { |o| options[:isModerator] = o}
|
148
|
-
end
|
149
|
-
|
40
|
+
subcommand.subcommand 'update' do |action|
|
41
|
+
options[:action] = 'update'
|
42
|
+
action.on('-i', '--id id', 'personId') { |o| options[:id] = o }
|
43
|
+
action.on('-e', '--emails emails', 'email') { |o| options[:emails] = o }
|
44
|
+
action.on('-d', '--displayName displayName', 'Full name of the person') { |o| options[:displayName] = o }
|
45
|
+
action.on('-f', '--firstName firstName', 'First name of the person') { |o| options[:firstName] = o }
|
46
|
+
action.on('-l', '--lastName lastName', 'Last name of the person') { |o| options[:lastName] = o }
|
47
|
+
action.on('-a', '--avatar avatar', 'URL to persons avatar in PNG format') { |o| options[:avatar] = o }
|
48
|
+
action.on('-o', '--orgId orgId', 'ID of the organization to which the person belongs') { |o| options[:orgId] = o }
|
49
|
+
action.on('-r', '--roles roles', 'Roles of the person') { |o| options[:roles] = o }
|
50
|
+
action.on('-c', '--licenses licenses', 'Licenses allocated to the person') { |o| options[:licenses] = o }
|
51
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
150
52
|
end
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
options[:action] = 'list'
|
156
|
-
action.on('-e','--email email','Email address') { |o| options[:email] = o}
|
157
|
-
action.on('-d','--displayName displayName ','Display name') { |o| options[:displayName] = o}
|
158
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
159
|
-
action.on('-o','--orgId orgId','orgid') { |o| options[:orgId] = o}
|
160
|
-
|
161
|
-
end
|
162
|
-
subcommand.subcommand 'get' do |action|
|
163
|
-
options[:action] = 'get'
|
164
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'people-get'}
|
165
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
166
|
-
end
|
167
|
-
subcommand.subcommand 'delete' do |action|
|
168
|
-
options[:action] = 'get'
|
169
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'people-delete'}
|
170
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
171
|
-
end
|
172
|
-
subcommand.subcommand 'create' do |action|
|
173
|
-
options[:action] = 'get'
|
174
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'people-create'}
|
175
|
-
action.on('-e','--email email','ID') { |o| options[:email] = o}
|
176
|
-
end
|
177
|
-
subcommand.subcommand 'update' do |action|
|
178
|
-
options[:action] = 'update'
|
179
|
-
action.on('-h','--help','Show help') { |o| options[:help] = 'people-update'}
|
180
|
-
action.on('-i','--id id','ID') { |o| options[:id] = o}
|
181
|
-
action.on('-e','--email email','email') { |o| options[:email] = o}
|
182
|
-
action.on('-d','--displayName displayName','Full name of the person') { |o| options[:displayName] = o}
|
183
|
-
action.on('-f','--firstName firstName','First name of the person') { |o| options[:firstName] = o}
|
184
|
-
action.on('-l','--lastName lastName','Last name of the person') { |o| options[:lastName] = o}
|
185
|
-
action.on('-a','--avatar avatar','URL to persons avatar in PNG format') { |o| options[:avatar] = o}
|
186
|
-
action.on('-o','--orgId orgId','ID of the organization to which the person belongs') { |o| options[:orgId] = o}
|
187
|
-
action.on('-r','--roles roles','Roles of the person') { |o| options[:roles] = o}
|
188
|
-
action.on('-c','--licenses licenses','Licenses allocated to the person') { |o| options[:licenses] = o}
|
189
|
-
end
|
190
|
-
|
53
|
+
subcommand.subcommand 'delete' do |action|
|
54
|
+
options[:action] = 'get'
|
55
|
+
action.on('-i', '--id id', 'personIdID') { |o| options[:id] = o }
|
56
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
191
57
|
end
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
58
|
+
end
|
59
|
+
opts.subcommand 'rooms' do |subcommand|
|
60
|
+
options[:entity] = 'rooms'
|
61
|
+
subcommand.on('-h', '--help', 'Show help') { |_o| options[:help] = "Available subcommands:\nlist\ncreate\nget\nupdate\ndelete" }
|
62
|
+
subcommand.subcommand 'list' do |action|
|
63
|
+
options[:action] = 'list'
|
64
|
+
action.on('-i', '--teamId teamId', 'Limit the rooms to those associated with a team, by ID.') { |o| options[:teamId] = o }
|
65
|
+
action.on('-t', '--type type', 'direct returns all 1-to-1 rooms. group returns all group rooms.') { |o| options[:type] = o }
|
66
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
67
|
+
end
|
68
|
+
subcommand.subcommand 'create' do |action|
|
69
|
+
options[:action] = 'create'
|
70
|
+
action.on('-t', '--title title', 'A user-friendly name for the room.') { |o| options[:title] = o }
|
71
|
+
action.on('-i', '--teamId teamId', 'The ID for the team with which this room is associated.') { |o| options[:teamId] = o }
|
72
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
73
|
+
end
|
74
|
+
subcommand.subcommand 'get' do |action|
|
75
|
+
options[:action] = 'get'
|
76
|
+
action.on('-i', '--id id', 'roomId') { |o| options[:id] = o }
|
77
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
78
|
+
end
|
79
|
+
subcommand.subcommand 'update' do |action|
|
80
|
+
options[:action] = 'update'
|
81
|
+
action.on('-i', '--id id', 'roomId') { |o| options[:id] = o }
|
82
|
+
action.on('-t', '--title title', 'A user-friendly name for the room.') { |o| options[:title] = o }
|
83
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
84
|
+
end
|
85
|
+
subcommand.subcommand 'delete' do |action|
|
86
|
+
options[:action] = 'delete'
|
87
|
+
action.on('-i', '--id id', 'roomId') { |o| options[:id] = o }
|
88
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
opts.subcommand 'memberships' do |subcommand|
|
92
|
+
options[:entity] = 'memberships'
|
93
|
+
subcommand.on('-h', '--help', 'Show help') { |_o| options[:help] = "Available subcommands:\nlist\ncreate\nget\nupdate\ndelete" }
|
94
|
+
subcommand.subcommand 'list' do |action|
|
95
|
+
options[:action] = 'list'
|
96
|
+
action.on('-r', '--roomId roomId ', 'Limit results to a specific room, by ID.') { |o| options[:roomId] = o }
|
97
|
+
action.on('-p', '--personId personId', 'Limit results to a specific person, by ID.') { |o| options[:personId] = o }
|
98
|
+
action.on('-e', '--personEmail personEmail', 'Limit results to a specific person, by email address.') { |o| options[:personEmail] = o }
|
99
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
100
|
+
end
|
101
|
+
subcommand.subcommand 'create' do |action|
|
102
|
+
options[:action] = 'create'
|
103
|
+
action.on('-r', '--roomId roomId', 'The room ID') { |o| options[:roomId] = o }
|
104
|
+
action.on('-p', '--personId personId', 'The person ID') { |o| options[:personId] = o }
|
105
|
+
action.on('-e', '--personEmail personEmail', 'The email address of the person') { |o| options[:personEmail] = o }
|
106
|
+
action.on('-m', '--isModerator isModerator', 'Set true to make the person a moderator') { |o| options[:isModerator] = o }
|
107
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
108
|
+
end
|
109
|
+
subcommand.subcommand 'get' do |action|
|
110
|
+
options[:action] = 'get'
|
111
|
+
action.on('-i', '--id id', 'membershipId') { |o| options[:id] = o }
|
112
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
113
|
+
end
|
114
|
+
subcommand.subcommand 'delete' do |action|
|
115
|
+
options[:action] = 'delete'
|
116
|
+
action.on('-i', '--id id', 'membershipId') { |o| options[:id] = o }
|
117
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
118
|
+
end
|
119
|
+
subcommand.subcommand 'update' do |action|
|
120
|
+
options[:action] = 'update'
|
121
|
+
action.on('-i', '--id id', 'membershipId') { |o| options[:id] = o }
|
122
|
+
action.on('-m', '--isModerator isModerator', 'Set true to make the person a moderator') { |o| options[:isModerator] = o }
|
123
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
opts.subcommand 'messages' do |subcommand|
|
127
|
+
options[:entity] = 'messages'
|
128
|
+
subcommand.on('-h', '--help', 'Show help') { |_o| options[:help] = "Available subcommands:\nlist\ncreate\nget\delete" }
|
129
|
+
subcommand.subcommand 'list' do |action|
|
130
|
+
options[:action] = 'list'
|
131
|
+
action.on('-r', '--roomId roomId ', 'List messages for a room, by .') { |o| options[:roomId] = o }
|
132
|
+
action.on('-p', '--mentionedPeople mentionedPeople', 'List messages where the caller is mentioned by specifying "me" or the caller personId') { |o| options[:mentionedPeople] = o }
|
133
|
+
action.on('-b', '--before before ', 'List messages before a sent time in ISO8601 format') { |o| options[:before] = o }
|
134
|
+
action.on('-b', '--beforeMessage beforeMessage ', 'List messages before a message, by ID') { |o| options[:beforeMessage] = o }
|
135
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
136
|
+
end
|
137
|
+
subcommand.subcommand 'create' do |action|
|
138
|
+
options[:action] = 'create'
|
139
|
+
action.on('-r', '--roomId roomId', 'The room ID') { |o| options[:roomId] = o }
|
140
|
+
action.on('-p', '--toPersonId toPersonId', 'The ID of the recipient when sending a private 1:1 message') { |o| options[:toPersonId] = o }
|
141
|
+
action.on('-e', '--toPersonEmail toPersonEmail', 'The ID of the recipient when sending a private 1:1 message') { |o| options[:toPersonEmail] = o }
|
142
|
+
action.on('-t', '--text text', 'The message, in plain text. If markdown is specified this parameter may be optionally used to provide alternate text for UI clients that do not support rich text.') { |o| options[:text] = o }
|
143
|
+
action.on('-m', '--markdown markdown', 'The message, in markdown format') { |o| options[:markdown] = o }
|
144
|
+
action.on('-f', '--files files', 'The public URL to a file to be posted in the room') { |o| options[:files] = o }
|
145
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
237
146
|
end
|
147
|
+
subcommand.subcommand 'get' do |action|
|
148
|
+
options[:action] = 'get'
|
149
|
+
action.on('-i', '--id id', 'ID') { |o| options[:id] = o }
|
150
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
151
|
+
end
|
152
|
+
subcommand.subcommand 'delete' do |action|
|
153
|
+
options[:action] = 'delete'
|
154
|
+
action.on('-i', '--id id', 'ID') { |o| options[:id] = o }
|
155
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
156
|
+
end
|
157
|
+
end
|
158
|
+
opts.subcommand 'teams' do |subcommand|
|
159
|
+
options[:entity] = 'teams'
|
160
|
+
subcommand.on('-h', '--help', 'Show help') { |_o| options[:help] = "Available subcommands:\nlist\ncreate\nget\nupdate\ndelete" }
|
161
|
+
subcommand.subcommand 'list' do |action|
|
162
|
+
options[:action] = 'list'
|
163
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
164
|
+
end
|
165
|
+
subcommand.subcommand 'create' do |action|
|
166
|
+
options[:action] = 'create'
|
167
|
+
action.on('-n', '--name name', 'A user-friendly name for the team.') { |o| options[:name] = o }
|
168
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
169
|
+
end
|
170
|
+
subcommand.subcommand 'get' do |action|
|
171
|
+
options[:action] = 'get'
|
172
|
+
action.on('-i', '--id id', 'teamId') { |o| options[:id] = o }
|
173
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
174
|
+
end
|
175
|
+
subcommand.subcommand 'update' do |action|
|
176
|
+
options[:action] = 'update'
|
177
|
+
action.on('-i', '--id id', 'teamId') { |o| options[:id] = o }
|
178
|
+
action.on('-n', '--name name', 'A user-friendly name for the team.') { |o| options[:name] = o }
|
179
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
180
|
+
end
|
181
|
+
subcommand.subcommand 'delete' do |action|
|
182
|
+
options[:action] = 'delete'
|
183
|
+
action.on('-i', '--id id', 'teamId') { |o| options[:id] = o }
|
184
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
185
|
+
end
|
186
|
+
end
|
187
|
+
opts.subcommand 'teammemberships' do |subcommand|
|
188
|
+
options[:entity] = 'teammemberships'
|
189
|
+
subcommand.on('-h', '--help', 'Show help') { |_o| options[:help] = "Available subcommands:\nlist\ncreate\nget\nupdate\ndelete" }
|
190
|
+
subcommand.subcommand 'list' do |action|
|
191
|
+
options[:action] = 'list'
|
192
|
+
action.on('-t', '--teamId teamId ', 'List team memberships for a team, by ID') { |o| options[:teamId] = o }
|
193
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
194
|
+
end
|
195
|
+
subcommand.subcommand 'create' do |action|
|
196
|
+
options[:action] = 'create'
|
197
|
+
action.on('-t', '--teamId teamId ', 'The team ID') { |o| options[:teamId] = o }
|
198
|
+
action.on('-p', '--personId personId', 'The person ID') { |o| options[:personId] = o }
|
199
|
+
action.on('-e', '--personEmail personEmail', 'The person email') { |o| options[:personEmail] = o }
|
200
|
+
action.on('-m', '--isModerator isModerator', 'Set to true to make the person a moderator') { |o| options[:isModerator] = o }
|
201
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
202
|
+
end
|
203
|
+
subcommand.subcommand 'get' do |action|
|
204
|
+
options[:action] = 'get'
|
205
|
+
action.on('-i', '--id id', 'teamMembershipId') { |o| options[:id] = o }
|
206
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
207
|
+
end
|
208
|
+
subcommand.subcommand 'update' do |action|
|
209
|
+
options[:action] = 'update'
|
210
|
+
action.on('-i', '--id id', 'teamMembershipId') { |o| options[:id] = o }
|
211
|
+
action.on('-m', '--isModerator isModerator', 'Set true to make the person a moderator') { |o| options[:isModerator] = o }
|
212
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
213
|
+
end
|
214
|
+
subcommand.subcommand 'delete' do |action|
|
215
|
+
options[:action] = 'delete'
|
216
|
+
action.on('-i', '--id id', 'teamMembershipId') { |o| options[:id] = o }
|
217
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
218
|
+
end
|
219
|
+
end
|
220
|
+
opts.subcommand 'webhooks' do |subcommand|
|
221
|
+
options[:entity] = 'webhooks'
|
222
|
+
subcommand.on('-h', '--help', 'Show help') { |_o| options[:help] = "Available subcommands:\nlist\ncreate\nget\nupdate\ndelete" }
|
223
|
+
subcommand.subcommand 'list' do |action|
|
224
|
+
options[:action] = 'list'
|
225
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
226
|
+
end
|
227
|
+
subcommand.subcommand 'create' do |action|
|
228
|
+
options[:action] = 'create'
|
229
|
+
action.on('-n', '--name name', 'A user-friendly name for the webhook.') { |o| options[:name] = o }
|
230
|
+
action.on('-u', '--targetUrl targetUrl', 'The URL that receives POST requests for each event.') { |o| options[:targetUrl] = o }
|
231
|
+
action.on('-r', '--resource resource', 'The resource type for the webhook. Creating a webhook requires read scope on the resource the webhook is for.') { |o| options[:resource] = o }
|
232
|
+
action.on('-e', '--event event', 'The event type for the webhook.') { |o| options[:event] = o }
|
233
|
+
action.on('-f', '--filter filter', 'The filter that defines the webhook scope.') { |o| options[:filter] = o }
|
234
|
+
action.on('-s', '--secret secret', 'The secret used to generate payload signature.') { |o| options[:secret] = o }
|
235
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
236
|
+
end
|
237
|
+
subcommand.subcommand 'get' do |action|
|
238
|
+
options[:action] = 'get'
|
239
|
+
action.on('-i', '--id id', 'ID') { |o| options[:id] = o }
|
240
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
241
|
+
end
|
242
|
+
subcommand.subcommand 'update' do |action|
|
243
|
+
options[:action] = 'update'
|
244
|
+
action.on('-n', '--name name', 'A user-friendly name for the webhook.') { |o| options[:name] = o }
|
245
|
+
action.on('-u', '--targetUrl targetUrl', 'The URL that receives POST requests for each event.') { |o| options[:targetUrl] = o }
|
246
|
+
action.on('-s', '--secret secret', 'The secret used to generate payload signature.') { |o| options[:secret] = o }
|
247
|
+
action.on('-t', '--status status', 'The status of the webhook. Use active to reactivate a disabled webhook.') { |o| options[:status] = o }
|
248
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
249
|
+
end
|
250
|
+
subcommand.subcommand 'delete' do |action|
|
251
|
+
options[:action] = 'delete'
|
252
|
+
action.on('-i', '--id id', 'webhookId') { |o| options[:id] = o }
|
253
|
+
action.on('-h', '--help', 'Show help') { |_o| options[:help] = action }
|
254
|
+
end
|
255
|
+
end
|
238
256
|
end
|
239
257
|
parser.parse!
|
240
258
|
|
241
|
-
|
259
|
+
if options[:help]
|
260
|
+
puts options[:help].to_s
|
261
|
+
exit 0
|
262
|
+
end
|
242
263
|
# puts "options=#{options}"
|
243
|
-
|
264
|
+
CiscoSpark::configure()
|
244
265
|
case options[:entity]
|
245
|
-
when 'room'
|
246
|
-
case options[:action]
|
247
|
-
when 'list'
|
248
|
-
params = {}
|
249
|
-
[:teamId, :type].each { |k| params[k] = options[k] if options[k] }
|
250
|
-
rooms = Spark::Rooms::List(params)
|
251
|
-
rooms.each { |r| printf "%-80s %s\n", r.id, r.title }
|
252
|
-
when 'get'
|
253
|
-
raise "Specify room ID with --id" unless options[:id]
|
254
|
-
room = Spark::Room::Get(options[:id])
|
255
|
-
room.instance_variables.each { |k| printf "%-25s %s\n", k,room[k.to_s.sub('@','')] }
|
256
|
-
when 'delete'
|
257
|
-
raise "Specify room ID with --id" unless options[:id]
|
258
|
-
room = Spark::Room::Get(options[:id])
|
259
|
-
room.delete()
|
260
|
-
when 'create'
|
261
|
-
teamid = options[:teamid] || nil
|
262
|
-
raise "Creating a room must specify a title" unless options[:title]
|
263
|
-
room = Spark::Room::Create(options[:title], teamid)
|
264
|
-
when 'update'
|
265
|
-
raise "Specify room ID with --id" unless options[:id]
|
266
|
-
raise "Creating a room must specify a title" unless options[:title]
|
267
|
-
room = Spark::Room::Get(options[:id])
|
268
|
-
room.title = options[:title]
|
269
|
-
room.update()
|
270
|
-
end
|
271
|
-
when 'team'
|
272
|
-
case options[:action]
|
273
|
-
when 'list'
|
274
|
-
teams = Spark::Teams::List()
|
275
|
-
teams.each { |t| printf "%-80s %s\n", t.id, t.name }
|
276
|
-
when 'get'
|
277
|
-
raise "Specify team ID with --id" unless options[:id]
|
278
|
-
team = Spark::Team::Get(options[:id])
|
279
|
-
team.instance_variables.each { |k| printf "%-25s %s\n", k,team[k.to_s.sub('@','')] }
|
280
|
-
end
|
281
|
-
#TODO: create, update, delete
|
282
266
|
when 'people'
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
267
|
+
case options[:action]
|
268
|
+
when 'list'
|
269
|
+
params = {}
|
270
|
+
%i[email displayName id orgId].each { |k| params[k] = options[k] if options[k] }
|
271
|
+
raise 'Must specify -id, -disaplyname or -email must be specified' if params.empty?
|
272
|
+
people = CiscoSpark::People::list(params)
|
273
|
+
people.each { |p| printf "%-80s %-25s %s\n", p.id, p.displayName, p.emails }
|
274
|
+
when 'get'
|
275
|
+
raise 'Specify person ID with --id' unless options[:id]
|
276
|
+
person = CiscoSpark::Person::get(options[:id])
|
277
|
+
person.instance_variables.each { |k| printf "%-25s %s\n", k, person[k.to_s.sub('@', '')] }
|
278
|
+
when 'update'
|
279
|
+
raise 'Specify person ID with --id' unless options[:id]
|
280
|
+
payload = {}
|
281
|
+
%i[emails displayName firstName lastName avatar orgId roles licenses].each { |k| payload[k] = options[k] if options[k] }
|
282
|
+
person = CiscoSpark::Person::get(options[:id])
|
283
|
+
person.update(payload)
|
284
|
+
when 'create'
|
285
|
+
raise 'Specify one or more email addresses with --email' unless options[:email]
|
286
|
+
person = CiscoSpark::Person::create(options[:email])
|
287
|
+
when 'delete'
|
288
|
+
raise 'Specify person ID with --id' unless options[:id]
|
289
|
+
person = CiscoSpark::Person::get(options[:id])
|
290
|
+
person.delete
|
291
|
+
end
|
292
|
+
when 'rooms'
|
293
|
+
case options[:action]
|
294
|
+
when 'list'
|
295
|
+
params = {}
|
296
|
+
%i[teamId type].each { |k| params[k] = options[k] if options[k] }
|
297
|
+
rooms = CiscoSpark::Rooms::list(params)
|
298
|
+
rooms.each { |r| printf "%-80s %s\n", r.id, r.title }
|
299
|
+
when 'get'
|
300
|
+
raise 'Specify room ID with --id' unless options[:id]
|
301
|
+
room = CiscoSpark::Room::get(options[:id])
|
302
|
+
room.instance_variables.each { |k| printf "%-25s %s\n", k, room[k.to_s.sub('@', '')] }
|
303
|
+
when 'delete'
|
304
|
+
raise 'Specify room ID with --id' unless options[:id]
|
305
|
+
room = CiscoSpark::Room::get(options[:id])
|
306
|
+
room.delete
|
307
|
+
when 'create'
|
308
|
+
teamid = options[:teamid] || nil
|
309
|
+
raise 'Creating a room must specify a title' unless options[:title]
|
310
|
+
room = CiscoSpark::Room::create(options[:title], teamid)
|
311
|
+
when 'update'
|
312
|
+
raise 'Specify room ID with --id' unless options[:id]
|
313
|
+
raise 'Creating a room must specify a title' unless options[:title]
|
314
|
+
room = CiscoSpark::Room::get(options[:id])
|
315
|
+
room.title = options[:title]
|
316
|
+
room.update
|
317
|
+
end
|
308
318
|
when 'membership'
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
when '
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
when '
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
319
|
+
case options[:action]
|
320
|
+
when 'list'
|
321
|
+
params = {}
|
322
|
+
%i[personEmail roomId personId].each { |k| params[k] = options[k] if options[k] }
|
323
|
+
raise '-personEmail, -roomId or -personId must be specified' if params.empty?
|
324
|
+
memberships = CiscoSpark::Memberships::list(params)
|
325
|
+
memberships.each { |m| printf "%-80s %-80s %-80s %s\n", m.id, m.roomId, m.personId, m.personEmail }
|
326
|
+
when 'get'
|
327
|
+
raise 'Specify membership ID with --id' unless options[:id]
|
328
|
+
membership = CiscoSpark::Membership::get(options[:id])
|
329
|
+
membership.instance_variables.each { |k| printf "%-25s %s\n", k, membership[k.to_s.sub('@', '')] }
|
330
|
+
when 'create'
|
331
|
+
raise 'Specify room ID with --roomid' unless options[:roomId]
|
332
|
+
params = {}
|
333
|
+
%i[personId personEmail isModerator].each { |k| params[k] = options[k] if options[k] }
|
334
|
+
membership = CiscoSpark::Membership::create(options[:roomId], params)
|
335
|
+
membership.instance_variables.each { |k| printf "%-25s %s\n", k, membership[k.to_s.sub('@', '')] }
|
336
|
+
when 'update'
|
337
|
+
raise 'Specify membership ID with --id' unless options[:id]
|
338
|
+
payload = {}
|
339
|
+
[:isModerator].each { |k| payload[k] = options[k] if options[k] }
|
340
|
+
membership = CiscoSpark::Membership::get(options[:id])
|
341
|
+
membership.update(payload)
|
342
|
+
when 'delete'
|
343
|
+
raise 'Specify membership ID with --id' unless options[:id]
|
344
|
+
membership = CiscoSpark::Membership::get(options[:id])
|
345
|
+
membership.delete
|
346
|
+
end
|
347
|
+
when 'messages'
|
348
|
+
case options[:action]
|
349
|
+
when 'list'
|
350
|
+
params = {}
|
351
|
+
%i[before roomId mentionedPeople beforeMessage].each { |k| params[k] = options[k] if options[k] }
|
352
|
+
raise '--roomId must be specified' unless options[:roomId]
|
353
|
+
messages = CiscoSpark::Messages::list(params)
|
354
|
+
messages.each { |m| printf "%-80s %-28s %-30s %s\n", m.id, m.created, m.personEmail, m.text }
|
355
|
+
when 'get'
|
356
|
+
raise 'Specify message ID with --id' unless options[:id]
|
357
|
+
message = CiscoSpark::Message::get(options[:id])
|
358
|
+
message.instance_variables.each { |k| printf "%-25s %s\n", k, message[k.to_s.sub('@', '')] }
|
359
|
+
when 'create'
|
360
|
+
raise 'Specify room ID with --roomid' unless options[:roomId]
|
361
|
+
params = {}
|
362
|
+
%i[toPersonId toPersonEmail text markdown files].each { |k| params[k] = options[k] if options[k] }
|
363
|
+
message = CiscoSpark::Message::create(options[:roomId], params)
|
364
|
+
message.instance_variables.each { |k| printf "%-25s %s\n", k, message[k.to_s.sub('@', '')] }
|
365
|
+
when 'delete'
|
366
|
+
raise 'Specify message ID with --id' unless options[:id]
|
367
|
+
message = CiscoSpark::Message::get(options[:id])
|
368
|
+
message.delete
|
369
|
+
end
|
370
|
+
when 'teams'
|
371
|
+
case options[:action]
|
372
|
+
when 'list'
|
373
|
+
teams = CiscoSpark::Teams::list()
|
374
|
+
teams.each { |t| printf "%-80s %s\n", t.id, t.name }
|
375
|
+
when 'get'
|
376
|
+
raise 'Specify team ID with --id' unless options[:id]
|
377
|
+
team = CiscoSpark::Team::get(options[:id])
|
378
|
+
team.instance_variables.each { |k| printf "%-25s %s\n", k, team[k.to_s.sub('@', '')] }
|
379
|
+
end
|
380
|
+
# TODO: create, update, delete
|
381
|
+
when 'teammemberships'
|
382
|
+
case options[:action]
|
383
|
+
when 'list'
|
384
|
+
params = {}
|
385
|
+
%i[personEmail roomId personId].each { |k| params[k] = options[k] if options[k] }
|
386
|
+
raise '-personEmail, -roomId or -personId must be specified' if params.empty?
|
387
|
+
teammemberships = CiscoSpark::TeamMemberships::list(params)
|
388
|
+
teammemberships.each { |m| printf "%-80s %-80s %-80s %s\n", m.id, m.roomId, m.personId, m.personEmail }
|
389
|
+
when 'get'
|
390
|
+
raise 'Specify teammembership ID with --id' unless options[:id]
|
391
|
+
teammembership = CiscoSpark::TeamMembership::get(options[:id])
|
392
|
+
teammembership.instance_variables.each { |k| printf "%-25s %s\n", k, teammembership[k.to_s.sub('@', '')] }
|
393
|
+
when 'create'
|
394
|
+
raise 'Specify team ID with --teamId' unless options[:roomId]
|
395
|
+
params = {}
|
396
|
+
%i[personId personEmail isModerator].each { |k| params[k] = options[k] if options[k] }
|
397
|
+
teammembership = CiscoSpark::TeamMembership::create(options[:roomId], params)
|
398
|
+
membeteammembershiprship.instance_variables.each { |k| printf "%-25s %s\n", k, teammembership[k.to_s.sub('@', '')] }
|
399
|
+
when 'update'
|
400
|
+
raise 'Specify teammembership ID with --id' unless options[:id]
|
401
|
+
payload = {}
|
402
|
+
[:isModerator].each { |k| payload[k] = options[k] if options[k] }
|
403
|
+
teammembership = CiscoSpark::TeamMembership::get(options[:id])
|
404
|
+
teammembership.update(payload)
|
405
|
+
when 'delete'
|
406
|
+
raise 'Specify teammembership ID with --id' unless options[:id]
|
407
|
+
teammembership = CiscoSpark::TeamMembership::get(options[:id])
|
408
|
+
teammembership.delete
|
409
|
+
end
|
410
|
+
when 'webhooks'
|
411
|
+
case options[:action]
|
412
|
+
when 'list'
|
413
|
+
params = {}
|
414
|
+
webhooks = CiscoSpark::Webhooks::list(params)
|
415
|
+
webhooks.each { |h| printf "%-80s %-20s %s\n", h.id, h.name, h.targetUrl }
|
416
|
+
when 'get'
|
417
|
+
raise 'Specify webhook ID with --id' unless options[:id]
|
418
|
+
webhook = CiscoSpark::Webhook::get(options[:id])
|
419
|
+
webhook.instance_variables.each { |k| printf "%-25s %s\n", k, webhook[k.to_s.sub('@', '')] }
|
420
|
+
when 'create'
|
421
|
+
params = {}
|
422
|
+
%i[name targetUrl resource event].each { |k| params[k] = options[k] if options[k] }
|
423
|
+
raise 'Must specify --name, --targetUrl, --resource, --event' if params.empty?
|
424
|
+
%i[filter secret].each { |k| params[k] = options[k] if options[k] }
|
425
|
+
webhook = CiscoSpark::Webhook::create(options[:roomId], params)
|
426
|
+
webhook.instance_variables.each { |k| printf "%-25s %s\n", k, webhook[k.to_s.sub('@', '')] }
|
427
|
+
when 'update'
|
428
|
+
raise 'Specify webhook ID with --id' unless options[:id]
|
429
|
+
payload = {}
|
430
|
+
%i[name targetUrl secret status].each { |k| payload[k] = options[k] if options[k] }
|
431
|
+
webhook = CiscoSpark::Webhook::get(options[:id])
|
432
|
+
webhook.update(payload)
|
433
|
+
when 'delete'
|
434
|
+
raise 'Specify webhook ID with --id' unless options[:id]
|
435
|
+
webhook = CiscoSpark::Webhook::get(options[:id])
|
436
|
+
webhook.delete
|
437
|
+
end
|
418
438
|
end
|