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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66ba5bbbea189d32ad44cc227c649b767d950897
4
- data.tar.gz: 29d7e6f4cf70b10595809a3b21596817c4228075
3
+ metadata.gz: a44ea106ba3591361fde501303512df72c9ce028
4
+ data.tar.gz: 81749952c556b4751decee830384a316c4293212
5
5
  SHA512:
6
- metadata.gz: 9c1311ae16a9383819247355444c4b5199741be9f9f2ba0c3803a344c8a8a55e4b779147ab174b451b7954e04a3c3050bb02524044fa26b0dda42dde53564660
7
- data.tar.gz: 3da75d71b74c7a2468409b9662d25b4c36640528adcdd3d265f67f1b117f57435edb4e2251f1530c7ac0aa9a17b96e1df6379aef99b0bda885b860b392f52bab
6
+ metadata.gz: 4f51072673fea4331ca3274a267bd89eef4dce0cc0e13835a41fef0815124c745564f067a59d35969a92b071080f146d64d0ba9990b54911838c6963b3931204
7
+ data.tar.gz: 8459a3b057bdf11595ce8e1da9771ade7802c25c3dfbf5d9db0fcd7d19372ad41fa6e05b9e9301601cea3069d60f111a3cb6c1f996cdc731159327b4c1efa73b
@@ -1,418 +1,438 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse/subcommand'
4
- # $LOAD_PATH.push("/Users/robertlabrie/Documents/code/cisco-spark-ruby/lib")
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
- opts.on('-h','--help', 'Show Help') do
10
- options[:help] = 'root'
11
- end
12
- opts.subcommand 'webhook' do |subcommand|
13
- options[:entity] = 'webhook'
14
- subcommand.on('-h','--help','Show help') { |o| options[:help] = 'webhook'}
15
- subcommand.subcommand 'list' do |action|
16
- options[:action] = 'list'
17
- action.on('-h','--help','Show help') { |o| options[:help] = 'webhook-list'}
18
- end
19
- subcommand.subcommand 'get' do |action|
20
- options[:action] = 'get'
21
- action.on('-h','--help','Show help') { |o| options[:help] = 'webhook-get'}
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
- opts.subcommand 'message' do |subcommand|
50
- options[:entity] = 'message'
51
- subcommand.on('-h','--help','Show help') { |o| options[:help] = 'message'}
52
- subcommand.subcommand 'list' do |action|
53
- options[:action] = 'list'
54
- action.on('-r','--roomId roomId ','List messages for a room, by ID') { |o| options[:roomId] = o}
55
- action.on('-p','--mentionedPeople mentionedPeople','List messages where the caller is mentioned by specifying "me" or the caller personId') { |o| options[:mentionedPeople] = o}
56
- action.on('-b','--before before ','List messages before a sent time in ISO8601 format') { |o| options[:before] = o}
57
- action.on('-b','--beforeMessage beforeMessage ','List messages before a message, by ID') { |o| options[:beforeMessage] = o}
58
- end
59
- subcommand.subcommand 'get' do |action|
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
- opts.subcommand 'teammembership' do |subcommand|
82
- options[:entity] = 'teammembership'
83
- subcommand.on('-h','--help','Show help') { |o| options[:help] = 'teammembership'}
84
- subcommand.subcommand 'list' do |action|
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
- opts.subcommand 'membership' do |subcommand|
117
- options[:entity] = 'membership'
118
- subcommand.on('-h','--help','Show help') { |o| options[:help] = 'membership'}
119
- subcommand.subcommand 'list' do |action|
120
- options[:action] = 'list'
121
- action.on('-e','--personEmail personEmail','Email address') { |o| options[:personEmail] = o}
122
- action.on('-r','--roomId roomId ','Display name') { |o| options[:roomId] = o}
123
- action.on('-p','--personId personId','Person ID') { |o| options[:personId] = o}
124
- end
125
- subcommand.subcommand 'get' do |action|
126
- options[:action] = 'get'
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
- opts.subcommand 'people' do |subcommand|
152
- options[:entity] = 'people'
153
- subcommand.on('-h','--help','Show help') { |o| options[:help] = 'people'}
154
- subcommand.subcommand 'list' do |action|
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
- opts.subcommand 'team' do |subcommand|
193
- options[:entity] = 'team'
194
- subcommand.on('-h','--help','Show help') { |o| options[:help] = 'team'}
195
- subcommand.subcommand 'list' do |action|
196
- options[:action] = 'list'
197
- action.on('-h','--help','Show help') { |o| options[:help] = 'team-list'}
198
- end
199
- subcommand.subcommand 'get' do |action|
200
- options[:action] = 'get'
201
- action.on('-h','--help','Show help') { |o| options[:help] = 'team-get'}
202
- action.on('-i','--id id','ID') { |o| options[:id] = o}
203
- end
204
- end
205
- opts.subcommand 'room' do |subcommand|
206
- options[:entity] = 'room'
207
- subcommand.on('-h','--help','Show help') { |o| options[:help] = 'room'}
208
- subcommand.subcommand 'list' do |action|
209
- options[:action] = 'list'
210
- action.on('-h','--help','Show help') { |o| options[:help] = 'room-list'}
211
- action.on('-t','--type type','type direct or group') { |o| options[:type] = o}
212
- action.on('-m','--teamId teamId','team ID') { |o| options[:teamId] = o}
213
-
214
- end
215
- subcommand.subcommand 'create' do |action|
216
- options[:action] = 'create'
217
- action.on('-h','--help','Show help') { |o| options[:help] = 'room-create'}
218
- action.on('-i','--id id','ID') { |o| options[:id] = o}
219
- action.on('-t', '--title title','Title') { |o| options[:title] = o}
220
- end
221
- subcommand.subcommand 'update' do |action|
222
- options[:action] = 'update'
223
- action.on('-h','--help','Show help') { |o| options[:help] = 'room-update'}
224
- action.on('-i','--id id','ID') { |o| options[:id] = o}
225
- action.on('-t', '--title title','Title') { |o| options[:title] = o}
226
- end
227
- subcommand.subcommand 'get' do |action|
228
- options[:action] = 'get'
229
- action.on('-h','--help','Show help') { |o| options[:help] = 'room-get'}
230
- action.on('-i','--id id','ID') { |o| options[:id] = o}
231
- end
232
- subcommand.subcommand 'delete' do |action|
233
- options[:action] = 'delete'
234
- action.on('-h','--help','Show help') { |o| options[:help] = 'room-delete'}
235
- action.on('-i','--id id','ID') { |o| options[:id] = o}
236
- end
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
- puts "#{help[options[:help]]}" if options[:help]
259
+ if options[:help]
260
+ puts options[:help].to_s
261
+ exit 0
262
+ end
242
263
  # puts "options=#{options}"
243
- Spark::Configure()
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
- case options[:action]
284
- when 'list'
285
- params = {}
286
- [:email, :displayName, :id, :orgId].each { |k| params[k] = options[k] if options[k] }
287
- raise "Must specify -id, -disaplyname or -email must be specified" if params.empty?
288
- people = Spark::People::List(params)
289
- people.each { |p| printf "%-80s %-25s %s\n", p.id, p.displayName, p.emails}
290
- when 'get'
291
- raise "Specify person ID with --id" unless options[:id]
292
- person = Spark::Person::Get(options[:id])
293
- person.instance_variables.each { |k| printf "%-25s %s\n", k,person[k.to_s.sub('@','')] }
294
- when 'update'
295
- raise "Specify person ID with --id" unless options[:id]
296
- payload = {}
297
- [:emails, :displayName, :firstName, :lastName, :avatar, :orgId, :roles, :licenses].each { |k| payload[k] = options[k] if options[k] }
298
- person = Spark::Person::Get(options[:id])
299
- person.update(payload)
300
- when 'create'
301
- raise "Specify one or more email addresses with --email" unless options[:email]
302
- person = Spark::Person::Create(options[:email])
303
- when 'delete'
304
- raise "Specify person ID with --id" unless options[:id]
305
- person = Spark::Person::Get(options[:id])
306
- person.delete()
307
- end
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
- case options[:action]
310
- when 'list'
311
- params = {}
312
- [:personEmail, :roomId, :personId].each { |k| params[k] = options[k] if options[k] }
313
- raise "-personEmail, -roomId or -personId must be specified" if params.empty?
314
- memberships = Spark::Memberships::List(params)
315
- memberships.each { |m| printf "%-80s %-80s %-80s %s\n", m.id, m.roomId, m.personId, m.personEmail}
316
- when 'get'
317
- raise "Specify membership ID with --id" unless options[:id]
318
- membership = Spark::Membership::Get(options[:id])
319
- membership.instance_variables.each { |k| printf "%-25s %s\n", k,membership[k.to_s.sub('@','')] }
320
- when 'create'
321
- raise "Specify room ID with --roomid" unless options[:roomId]
322
- params = {}
323
- [:personId, :personEmail, :isModerator].each { |k| params[k] = options[k] if options[k] }
324
- membership = Spark::Membership::Create(options[:roomId],params)
325
- membership.instance_variables.each { |k| printf "%-25s %s\n", k,membership[k.to_s.sub('@','')] }
326
- when 'update'
327
- raise "Specify membership ID with --id" unless options[:id]
328
- payload = {}
329
- [:isModerator].each { |k| payload[k] = options[k] if options[k] }
330
- membership = Spark::Membership::Get(options[:id])
331
- membership.update(payload)
332
- when 'delete'
333
- raise "Specify membership ID with --id" unless options[:id]
334
- membership = Spark::Membership::Get(options[:id])
335
- membership.delete()
336
- end
337
- when 'message'
338
- case options[:action]
339
- when 'list'
340
- params = {}
341
- [:before, :roomId, :mentionedPeople, :beforeMessage].each { |k| params[k] = options[k] if options[k] }
342
- raise "--roomId must be specified" unless options[:roomId]
343
- messages = Spark::Messages::List(params)
344
- messages.each { |m| printf "%-80s %-28s %-30s %s\n", m.id, m.created, m.personEmail, m.text}
345
- when 'get'
346
- raise "Specify message ID with --id" unless options[:id]
347
- message = Spark::Message::Get(options[:id])
348
- message.instance_variables.each { |k| printf "%-25s %s\n", k,message[k.to_s.sub('@','')] }
349
- when 'create'
350
- raise "Specify room ID with --roomid" unless options[:roomId]
351
- params = {}
352
- [:toPersonId, :toPersonEmail, :text, :markdown, :files].each { |k| params[k] = options[k] if options[k] }
353
- message = Spark::Message::Create(options[:roomId], params)
354
- message.instance_variables.each { |k| printf "%-25s %s\n", k,message[k.to_s.sub('@','')] }
355
- when 'delete'
356
- raise "Specify message ID with --id" unless options[:id]
357
- message = Spark::Message::Get(options[:id])
358
- message.delete()
359
- end
360
- when 'teammembership'
361
- case options[:action]
362
- when 'list'
363
- params = {}
364
- [:personEmail, :roomId, :personId].each { |k| params[k] = options[k] if options[k] }
365
- raise "-personEmail, -roomId or -personId must be specified" if params.empty?
366
- teammemberships = Spark::TeamMemberships::List(params)
367
- teammemberships.each { |m| printf "%-80s %-80s %-80s %s\n", m.id, m.roomId, m.personId, m.personEmail}
368
- when 'get'
369
- raise "Specify teammembership ID with --id" unless options[:id]
370
- teammembership = Spark::TeamMembership::Get(options[:id])
371
- teammembership.instance_variables.each { |k| printf "%-25s %s\n", k,teammembership[k.to_s.sub('@','')] }
372
- when 'create'
373
- raise "Specify team ID with --teamId" unless options[:roomId]
374
- params = {}
375
- [:personId, :personEmail, :isModerator].each { |k| params[k] = options[k] if options[k] }
376
- teammembership = Spark::TeamMembership::Create(options[:roomId],params)
377
- membeteammembershiprship.instance_variables.each { |k| printf "%-25s %s\n", k,teammembership[k.to_s.sub('@','')] }
378
- when 'update'
379
- raise "Specify teammembership ID with --id" unless options[:id]
380
- payload = {}
381
- [:isModerator].each { |k| payload[k] = options[k] if options[k] }
382
- teammembership = Spark::TeamMembership::Get(options[:id])
383
- teammembership.update(payload)
384
- when 'delete'
385
- raise "Specify teammembership ID with --id" unless options[:id]
386
- teammembership = Spark::TeamMembership::Get(options[:id])
387
- teammembership.delete()
388
- end
389
-
390
- when 'webhook'
391
- case options[:action]
392
- when 'list'
393
- params = {}
394
- webhooks = Spark::Webhooks::List(params)
395
- webhooks.each { |h| printf "%-80s %-20s %s\n", h.id, h.name, h.targetUrl}
396
- when 'get'
397
- raise "Specify webhook ID with --id" unless options[:id]
398
- webhook = Spark::Webhook::Get(options[:id])
399
- webhook.instance_variables.each { |k| printf "%-25s %s\n", k,webhook[k.to_s.sub('@','')] }
400
- when 'create'
401
- params = {}
402
- [:name, :targetUrl, :resource, :event].each { |k| params[k] = options[k] if options[k] }
403
- raise "Must specify --name, --targetUrl, --resource, --event" if params.empty?
404
- [:filter, :secret].each { |k| params[k] = options[k] if options[k] }
405
- webhook = Spark::Webhook::Create(options[:roomId],params)
406
- webhook.instance_variables.each { |k| printf "%-25s %s\n", k,webhook[k.to_s.sub('@','')] }
407
- when 'update'
408
- raise "Specify webhook ID with --id" unless options[:id]
409
- payload = {}
410
- [:name, :targetUrl, :secret, :status].each { |k| payload[k] = options[k] if options[k] }
411
- webhook = Spark::Webhook::Get(options[:id])
412
- webhook.update(payload)
413
- when 'delete'
414
- raise "Specify webhook ID with --id" unless options[:id]
415
- webhook = Spark::Webhook::Get(options[:id])
416
- webhook.delete()
417
- end
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