slack-ruby-client 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.github/workflows/test.yml +6 -0
- data/.github/workflows/update_api.yml +76 -0
- data/.gitignore +1 -0
- data/.rubocop_todo.yml +17 -29
- data/CHANGELOG.md +23 -1
- data/CONTRIBUTING.md +35 -32
- data/Gemfile +2 -0
- data/README.md +123 -14
- data/bin/commands/admin_apps_activities.rb +32 -0
- data/bin/commands/admin_apps_approved.rb +1 -0
- data/bin/commands/admin_apps_config.rb +31 -0
- data/bin/commands/admin_apps_requests.rb +1 -0
- data/bin/commands/admin_apps_restricted.rb +1 -0
- data/bin/commands/admin_functions.rb +23 -0
- data/bin/commands/admin_functions_permissions.rb +31 -0
- data/bin/commands/admin_roles.rb +1 -1
- data/bin/commands/admin_teams.rb +1 -1
- data/bin/commands/admin_users.rb +2 -2
- data/bin/commands/admin_workflows.rb +38 -0
- data/bin/commands/admin_workflows_collaborators.rb +31 -0
- data/bin/commands/admin_workflows_permissions.rb +21 -0
- data/bin/commands/apps_activities.rb +32 -0
- data/bin/commands/apps_auth_external.rb +32 -0
- data/bin/commands/apps_datastore.rb +70 -0
- data/bin/commands/auth_teams.rb +2 -2
- data/bin/commands/calls.rb +1 -1
- data/bin/commands/chat.rb +6 -6
- data/bin/commands/chat_scheduledMessages.rb +2 -2
- data/bin/commands/conversations.rb +3 -3
- data/bin/commands/dnd.rb +1 -1
- data/bin/commands/functions_workflows_steps.rb +2 -1
- data/bin/commands/functions_workflows_steps_responses.rb +2 -1
- data/bin/commands/reminders.rb +1 -1
- data/bin/commands/stars.rb +4 -4
- data/bin/commands/team.rb +3 -1
- data/bin/commands/users.rb +1 -1
- data/lib/slack/messages/formatting.rb +44 -0
- data/lib/slack/real_time/client.rb +14 -2
- data/lib/slack/real_time/concurrency/async.rb +4 -0
- data/lib/slack/real_time/config.rb +3 -0
- data/lib/slack/real_time/socket.rb +4 -0
- data/lib/slack/real_time/stores/starter.rb +2 -2
- data/lib/slack/real_time/stores/store.rb +2 -2
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_apps_activities.rb +53 -0
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +2 -0
- data/lib/slack/web/api/endpoints/admin_apps_config.rb +40 -0
- data/lib/slack/web/api/endpoints/admin_apps_requests.rb +2 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +2 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +1 -0
- data/lib/slack/web/api/endpoints/admin_functions.rb +36 -0
- data/lib/slack/web/api/endpoints/admin_functions_permissions.rb +41 -0
- data/lib/slack/web/api/endpoints/admin_roles.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_teams.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_users.rb +2 -2
- data/lib/slack/web/api/endpoints/admin_workflows.rb +59 -0
- data/lib/slack/web/api/endpoints/admin_workflows_collaborators.rb +42 -0
- data/lib/slack/web/api/endpoints/admin_workflows_permissions.rb +26 -0
- data/lib/slack/web/api/endpoints/apps_activities.rb +54 -0
- data/lib/slack/web/api/endpoints/apps_auth_external.rb +41 -0
- data/lib/slack/web/api/endpoints/apps_datastore.rb +110 -0
- data/lib/slack/web/api/endpoints/apps_manifest.rb +2 -0
- data/lib/slack/web/api/endpoints/auth_teams.rb +1 -1
- data/lib/slack/web/api/endpoints/calls.rb +1 -1
- data/lib/slack/web/api/endpoints/chat.rb +14 -45
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +2 -2
- data/lib/slack/web/api/endpoints/conversations.rb +3 -3
- data/lib/slack/web/api/endpoints/dialog.rb +1 -6
- data/lib/slack/web/api/endpoints/dnd.rb +1 -1
- data/lib/slack/web/api/endpoints/functions_workflows_steps.rb +3 -1
- data/lib/slack/web/api/endpoints/functions_workflows_steps_responses.rb +3 -1
- data/lib/slack/web/api/endpoints/reminders.rb +1 -1
- data/lib/slack/web/api/endpoints/stars.rb +2 -2
- data/lib/slack/web/api/endpoints/team.rb +12 -2
- data/lib/slack/web/api/endpoints/users.rb +1 -1
- data/lib/slack/web/api/endpoints/users_profile.rb +1 -0
- data/lib/slack/web/api/endpoints/views.rb +7 -23
- data/lib/slack/web/api/endpoints/workflows.rb +2 -0
- data/lib/slack/web/api/endpoints.rb +20 -0
- data/lib/slack/web/api/errors.rb +66 -4
- data/lib/slack/web/api/options.rb +26 -0
- data/lib/slack/web/api/patches/chat.attachments-blocks.patch +7 -55
- data/lib/slack/web/api/templates/method.erb +12 -0
- data/lib/slack/web/api/templates/method_spec.erb +40 -4
- data/lib/slack/web/client.rb +1 -0
- data/lib/slack-ruby-client.rb +1 -0
- data/lib/tasks/web.rake +2 -4
- data/slack-ruby-client.gemspec +1 -0
- data/spec/slack/messages/formatting_spec.rb +60 -0
- data/spec/slack/real_time/client_spec.rb +25 -7
- data/spec/slack/real_time/concurrency/clients/async_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/admin_apps_activities_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_config_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +6 -6
- data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +14 -10
- data/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb +21 -0
- data/spec/slack/web/api/endpoints/admin_functions_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_roles_spec.rb +6 -6
- data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +1 -1
- data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +6 -6
- data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/admin_users_spec.rb +8 -8
- data/spec/slack/web/api/endpoints/admin_workflows_collaborators_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/admin_workflows_permissions_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_workflows_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_activities_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_auth_external_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_datastore_spec.rb +45 -0
- data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/apps_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/auth_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/bookmarks_spec.rb +4 -4
- data/spec/slack/web/api/endpoints/calls_participants_spec.rb +4 -4
- data/spec/slack/web/api/endpoints/calls_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/chat_spec.rb +62 -0
- data/spec/slack/web/api/endpoints/conversations_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +1 -1
- data/spec/slack/web/api/endpoints/dialog_spec.rb +14 -0
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/files_remote_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/files_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/reactions_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/reminders_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/users_profile_spec.rb +6 -0
- data/spec/slack/web/api/endpoints/users_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/views_spec.rb +65 -0
- data/spec/slack/web/api/endpoints/workflows_spec.rb +8 -0
- data/spec/slack/web/api/options_spec.rb +69 -0
- data/spec/spec_helper.rb +9 -0
- metadata +45 -5
- data/lib/slack/web/api/patches/dialog.encoded-json.patch +0 -17
- data/lib/slack/web/api/patches/views.view-json.patch +0 -55
data/lib/slack/web/api/errors.rb
CHANGED
@@ -6,6 +6,7 @@ module Slack
|
|
6
6
|
module Api
|
7
7
|
module Errors
|
8
8
|
class AccessDenied < SlackError; end
|
9
|
+
class AccessTokenExchangeFailed < SlackError; end
|
9
10
|
class Accesslimited < SlackError; end
|
10
11
|
class AccountInactive < SlackError; end
|
11
12
|
class ActionAlreadyInProgress < SlackError; end
|
@@ -25,6 +26,7 @@ module Slack
|
|
25
26
|
class AppMissingActionUrl < SlackError; end
|
26
27
|
class AppNotEligible < SlackError; end
|
27
28
|
class AppNotFound < SlackError; end
|
29
|
+
class AppNotHosted < SlackError; end
|
28
30
|
class AppRestrictedOrgWide < SlackError; end
|
29
31
|
class ApprovalInactive < SlackError; end
|
30
32
|
class ApprovalNotFound < SlackError; end
|
@@ -77,10 +79,10 @@ module Slack
|
|
77
79
|
class CannotParse < SlackError; end
|
78
80
|
class CannotParseAttachment < SlackError; end
|
79
81
|
class CannotPrompt < SlackError; end
|
82
|
+
class CannotReplyToMessage < SlackError; end
|
80
83
|
class CannotResetBot < SlackError; end
|
81
84
|
class CannotResetPrimaryOwner < SlackError; end
|
82
85
|
class CannotResolveAlias < SlackError; end
|
83
|
-
class CannotSetBothNumMinutesAndIsIndefinite < SlackError; end
|
84
86
|
class CannotSetThisGuestToRegularAtTeamLevel < SlackError; end
|
85
87
|
class CannotShareCrossWorkspaceChannel < SlackError; end
|
86
88
|
class CannotShareMandatoryChannel < SlackError; end
|
@@ -101,6 +103,7 @@ module Slack
|
|
101
103
|
class CantUpdateMessage < SlackError; end
|
102
104
|
class CanvasDisabledFileTeam < SlackError; end
|
103
105
|
class CanvasDisabledUserTeam < SlackError; end
|
106
|
+
class CanvasGloballyDisabled < SlackError; end
|
104
107
|
class ChannelArchived < SlackError; end
|
105
108
|
class ChannelCannotBeUnshared < SlackError; end
|
106
109
|
class ChannelCanvasDeleted < SlackError; end
|
@@ -133,6 +136,8 @@ module Slack
|
|
133
136
|
class CouldNotUnarchiveChannel < SlackError; end
|
134
137
|
class CustomIntegrationNotAllowedAtEnterprise < SlackError; end
|
135
138
|
class DataNotAvailable < SlackError; end
|
139
|
+
class DatastoreError < SlackError; end
|
140
|
+
class DatastoreMigrationInProgress < SlackError; end
|
136
141
|
class DefaultChannelRestricted < SlackError; end
|
137
142
|
class DefaultOrgWideChannel < SlackError; end
|
138
143
|
class DeleteNotAllowed < SlackError; end
|
@@ -146,6 +151,7 @@ module Slack
|
|
146
151
|
class EditWindowClosed < SlackError; end
|
147
152
|
class EkmAccessDenied < SlackError; end
|
148
153
|
class EmailDoesNotMatch < SlackError; end
|
154
|
+
class EmailNotVerified < SlackError; end
|
149
155
|
class EmailTaken < SlackError; end
|
150
156
|
class EmojiLimitReached < SlackError; end
|
151
157
|
class EmojiNotFound < SlackError; end
|
@@ -153,6 +159,7 @@ module Slack
|
|
153
159
|
class EnterpriseIsRestricted < SlackError; end
|
154
160
|
class EnterpriseNotFound < SlackError; end
|
155
161
|
class EntityNotFound < SlackError; end
|
162
|
+
class ErrorAddingCollaborators < SlackError; end
|
156
163
|
class ErrorBadFormat < SlackError; end
|
157
164
|
class ErrorBadNameI18n < SlackError; end
|
158
165
|
class ErrorBadUpload < SlackError; end
|
@@ -163,7 +170,9 @@ module Slack
|
|
163
170
|
class ErrorNameTaken < SlackError; end
|
164
171
|
class ErrorNameTakenI18n < SlackError; end
|
165
172
|
class ErrorNoImage < SlackError; end
|
173
|
+
class ErrorRemovingCollaborators < SlackError; end
|
166
174
|
class ErrorTooBig < SlackError; end
|
175
|
+
class ErrorUnpublishingWorkflows < SlackError; end
|
167
176
|
class ExchangedTriggerId < SlackError; end
|
168
177
|
class ExpiredTriggerId < SlackError; end
|
169
178
|
class ExternalChannelMigrating < SlackError; end
|
@@ -221,6 +230,8 @@ module Slack
|
|
221
230
|
class FileUploadsDisabled < SlackError; end
|
222
231
|
class ForbiddenHandle < SlackError; end
|
223
232
|
class ForbiddenTeam < SlackError; end
|
233
|
+
class FreeTeamNotAllowed < SlackError; end
|
234
|
+
class FunctionNotFound < SlackError; end
|
224
235
|
class GroupAlreadyLinkedToChannel < SlackError; end
|
225
236
|
class GroupMustNotBeEmpty < SlackError; end
|
226
237
|
class GroupNotFound < SlackError; end
|
@@ -256,7 +267,9 @@ module Slack
|
|
256
267
|
class InvalidCode < SlackError; end
|
257
268
|
class InvalidCreatedBy < SlackError; end
|
258
269
|
class InvalidCursor < SlackError; end
|
270
|
+
class InvalidDatastore < SlackError; end
|
259
271
|
class InvalidDate < SlackError; end
|
272
|
+
class InvalidDomains < SlackError; end
|
260
273
|
class InvalidDuration < SlackError; end
|
261
274
|
class InvalidEmail < SlackError; end
|
262
275
|
class InvalidEmoji < SlackError; end
|
@@ -300,6 +313,7 @@ module Slack
|
|
300
313
|
class InvalidScheduledMessageId < SlackError; end
|
301
314
|
class InvalidScopes < SlackError; end
|
302
315
|
class InvalidSearchChannelType < SlackError; end
|
316
|
+
class InvalidSetting < SlackError; end
|
303
317
|
class InvalidSort < SlackError; end
|
304
318
|
class InvalidSortDir < SlackError; end
|
305
319
|
class InvalidSource < SlackError; end
|
@@ -309,6 +323,7 @@ module Slack
|
|
309
323
|
class InvalidTeam < SlackError; end
|
310
324
|
class InvalidTeamId < SlackError; end
|
311
325
|
class InvalidTeamIds < SlackError; end
|
326
|
+
class InvalidThreadTs < SlackError; end
|
312
327
|
class InvalidTime < SlackError; end
|
313
328
|
class InvalidTimestamp < SlackError; end
|
314
329
|
class InvalidTitle < SlackError; end
|
@@ -327,6 +342,7 @@ module Slack
|
|
327
342
|
class InvalidUserId < SlackError; end
|
328
343
|
class InvalidUsers < SlackError; end
|
329
344
|
class InvalidValue < SlackError; end
|
345
|
+
class InvalidWorkflowAuthStrategy < SlackError; end
|
330
346
|
class InviteFromSameOrg < SlackError; end
|
331
347
|
class InviteLookupError < SlackError; end
|
332
348
|
class InviteNotFound < SlackError; end
|
@@ -337,6 +353,7 @@ module Slack
|
|
337
353
|
class InvitorCannotSeeChannel < SlackError; end
|
338
354
|
class IsArchived < SlackError; end
|
339
355
|
class IsBot < SlackError; end
|
356
|
+
class IsIdpManaged < SlackError; end
|
340
357
|
class IsInactive < SlackError; end
|
341
358
|
class IsPendingConnectedToOrg < SlackError; end
|
342
359
|
class LastMember < SlackError; end
|
@@ -350,6 +367,7 @@ module Slack
|
|
350
367
|
class ManagedChannelNotSupported < SlackError; end
|
351
368
|
class MemberAnalyticsDisabled < SlackError; end
|
352
369
|
class MemberLimitExceeded < SlackError; end
|
370
|
+
class MessageLimitExceeded < SlackError; end
|
353
371
|
class MessageNotFound < SlackError; end
|
354
372
|
class MessageTooLong < SlackError; end
|
355
373
|
class MessagesTabDisabled < SlackError; end
|
@@ -358,6 +376,7 @@ module Slack
|
|
358
376
|
class MetadataOnlyDoesNotSupportDate < SlackError; end
|
359
377
|
class MetadataTooLarge < SlackError; end
|
360
378
|
class MethodDeprecated < SlackError; end
|
379
|
+
class MethodNotSupported < SlackError; end
|
361
380
|
class MethodNotSupportedForChannelType < SlackError; end
|
362
381
|
class MigrationInProgress < SlackError; end
|
363
382
|
class MissingArgs < SlackError; end
|
@@ -384,6 +403,7 @@ module Slack
|
|
384
403
|
class MustProvideTeamName < SlackError; end
|
385
404
|
class MustRevokeAccess < SlackError; end
|
386
405
|
class NameAlreadyExists < SlackError; end
|
406
|
+
class NameNotAllowed < SlackError; end
|
387
407
|
class NameTaken < SlackError; end
|
388
408
|
class NameTakenInOrg < SlackError; end
|
389
409
|
class NameTooLong < SlackError; end
|
@@ -392,6 +412,7 @@ module Slack
|
|
392
412
|
class NoBotUserForApp < SlackError; end
|
393
413
|
class NoChannel < SlackError; end
|
394
414
|
class NoChannelMemberships < SlackError; end
|
415
|
+
class NoDomainsProvided < SlackError; end
|
395
416
|
class NoDualBroadcastContentUpdate < SlackError; end
|
396
417
|
class NoImageUploaded < SlackError; end
|
397
418
|
class NoItemSpecified < SlackError; end
|
@@ -399,12 +420,14 @@ module Slack
|
|
399
420
|
class NoPermission < SlackError; end
|
400
421
|
class NoPin < SlackError; end
|
401
422
|
class NoReaction < SlackError; end
|
423
|
+
class NoRefreshToken < SlackError; end
|
402
424
|
class NoResolutionFound < SlackError; end
|
403
425
|
class NoScopes < SlackError; end
|
404
426
|
class NoSuchSubteam < SlackError; end
|
405
427
|
class NoTeamIdsGiven < SlackError; end
|
406
428
|
class NoTeamsToDisconnect < SlackError; end
|
407
429
|
class NoText < SlackError; end
|
430
|
+
class NoTokensFound < SlackError; end
|
408
431
|
class NoUser < SlackError; end
|
409
432
|
class NoUsersProvided < SlackError; end
|
410
433
|
class NoValidChannels < SlackError; end
|
@@ -442,6 +465,7 @@ module Slack
|
|
442
465
|
class OrgLevelEmailDisplayDisabled < SlackError; end
|
443
466
|
class OrgLoginRequired < SlackError; end
|
444
467
|
class OrgNotFound < SlackError; end
|
468
|
+
class OrgResolutionRequired < SlackError; end
|
445
469
|
class OrgUserNotInTeam < SlackError; end
|
446
470
|
class OverMaxEntityLimit < SlackError; end
|
447
471
|
class OverPaginationLimit < SlackError; end
|
@@ -460,6 +484,7 @@ module Slack
|
|
460
484
|
class PreviewFeatureNotAvailable < SlackError; end
|
461
485
|
class PrimaryUsergroupNotFound < SlackError; end
|
462
486
|
class ProfileSetFailed < SlackError; end
|
487
|
+
class ProvidersNotFound < SlackError; end
|
463
488
|
class PublicVideoNotAllowed < SlackError; end
|
464
489
|
class PublishedAppOnly < SlackError; end
|
465
490
|
class PushLimitReached < SlackError; end
|
@@ -491,7 +516,6 @@ module Slack
|
|
491
516
|
class SlackConnectClipSharingBlocked < SlackError; end
|
492
517
|
class SlackConnectFileLinkSharingBlocked < SlackError; end
|
493
518
|
class SlackConnectFileUploadSharingBlocked < SlackError; end
|
494
|
-
class SlackConnectTeamBlocked < SlackError; end
|
495
519
|
class SnippetTooLarge < SlackError; end
|
496
520
|
class SnoozeEndFailed < SlackError; end
|
497
521
|
class SnoozeFailed < SlackError; end
|
@@ -508,13 +532,16 @@ module Slack
|
|
508
532
|
class TeamIdRequiredForEnterprise < SlackError; end
|
509
533
|
class TeamNotFound < SlackError; end
|
510
534
|
class TeamNotOnEnterprise < SlackError; end
|
535
|
+
class TeamQuotaExceeded < SlackError; end
|
511
536
|
class TeamsNotFound < SlackError; end
|
537
|
+
class TemplateNotVisible < SlackError; end
|
512
538
|
class ThreadLocked < SlackError; end
|
513
539
|
class ThreadNotFound < SlackError; end
|
514
540
|
class TimeInPast < SlackError; end
|
515
541
|
class TimeTooFar < SlackError; end
|
516
542
|
class TokenAlreadyExchanged < SlackError; end
|
517
543
|
class TokenExpired < SlackError; end
|
544
|
+
class TokenNotFound < SlackError; end
|
518
545
|
class TokenRevoked < SlackError; end
|
519
546
|
class TokenRotationNotEnabled < SlackError; end
|
520
547
|
class TooLarge < SlackError; end
|
@@ -524,6 +551,7 @@ module Slack
|
|
524
551
|
class TooManyContactCards < SlackError; end
|
525
552
|
class TooManyConvosForAppOnTeam < SlackError; end
|
526
553
|
class TooManyConvosForTeam < SlackError; end
|
554
|
+
class TooManyDomainsProvided < SlackError; end
|
527
555
|
class TooManyEmails < SlackError; end
|
528
556
|
class TooManyEmoji < SlackError; end
|
529
557
|
class TooManyEntities < SlackError; end
|
@@ -541,6 +569,7 @@ module Slack
|
|
541
569
|
class TriggerExchanged < SlackError; end
|
542
570
|
class TriggerExpired < SlackError; end
|
543
571
|
class TwoFactorSetupRequired < SlackError; end
|
572
|
+
class UnableToDelete < SlackError; end
|
544
573
|
class UnableToFetchCustomEmojis < SlackError; end
|
545
574
|
class UnableToLinkIdpGroupAndChannel < SlackError; end
|
546
575
|
class UnableToProcessPostRequest < SlackError; end
|
@@ -563,6 +592,7 @@ module Slack
|
|
563
592
|
class UpdateFailed < SlackError; end
|
564
593
|
class UraMaxChannels < SlackError; end
|
565
594
|
class UrlInMessage < SlackError; end
|
595
|
+
class UrlRestrictionNotSupported < SlackError; end
|
566
596
|
class UserAlreadyDeleted < SlackError; end
|
567
597
|
class UserAlreadyTeamMember < SlackError; end
|
568
598
|
class UserCannotCreateChannel < SlackError; end
|
@@ -587,9 +617,11 @@ module Slack
|
|
587
617
|
class UsersNotFound < SlackError; end
|
588
618
|
class ValidationErrors < SlackError; end
|
589
619
|
class ViewTooLarge < SlackError; end
|
620
|
+
class WorkflowsExportCsvNotEnabled < SlackError; end
|
590
621
|
|
591
622
|
ERROR_CLASSES = {
|
592
623
|
'access_denied' => AccessDenied,
|
624
|
+
'access_token_exchange_failed' => AccessTokenExchangeFailed,
|
593
625
|
'accesslimited' => Accesslimited,
|
594
626
|
'account_inactive' => AccountInactive,
|
595
627
|
'action_already_in_progress' => ActionAlreadyInProgress,
|
@@ -609,6 +641,7 @@ module Slack
|
|
609
641
|
'app_missing_action_url' => AppMissingActionUrl,
|
610
642
|
'app_not_eligible' => AppNotEligible,
|
611
643
|
'app_not_found' => AppNotFound,
|
644
|
+
'app_not_hosted' => AppNotHosted,
|
612
645
|
'app_restricted_org_wide' => AppRestrictedOrgWide,
|
613
646
|
'approval_inactive' => ApprovalInactive,
|
614
647
|
'approval_not_found' => ApprovalNotFound,
|
@@ -661,10 +694,10 @@ module Slack
|
|
661
694
|
'cannot_parse' => CannotParse,
|
662
695
|
'cannot_parse_attachment' => CannotParseAttachment,
|
663
696
|
'cannot_prompt' => CannotPrompt,
|
697
|
+
'cannot_reply_to_message' => CannotReplyToMessage,
|
664
698
|
'cannot_reset_bot' => CannotResetBot,
|
665
699
|
'cannot_reset_primary_owner' => CannotResetPrimaryOwner,
|
666
700
|
'cannot_resolve_alias' => CannotResolveAlias,
|
667
|
-
'cannot_set_both_num_minutes_and_is_indefinite' => CannotSetBothNumMinutesAndIsIndefinite,
|
668
701
|
'cannot_set_this_guest_to_regular_at_team_level' => CannotSetThisGuestToRegularAtTeamLevel,
|
669
702
|
'cannot_share_cross_workspace_channel' => CannotShareCrossWorkspaceChannel,
|
670
703
|
'cannot_share_mandatory_channel' => CannotShareMandatoryChannel,
|
@@ -685,6 +718,7 @@ module Slack
|
|
685
718
|
'cant_update_message' => CantUpdateMessage,
|
686
719
|
'canvas_disabled_file_team' => CanvasDisabledFileTeam,
|
687
720
|
'canvas_disabled_user_team' => CanvasDisabledUserTeam,
|
721
|
+
'canvas_globally_disabled' => CanvasGloballyDisabled,
|
688
722
|
'channel_archived' => ChannelArchived,
|
689
723
|
'channel_cannot_be_unshared' => ChannelCannotBeUnshared,
|
690
724
|
'channel_canvas_deleted' => ChannelCanvasDeleted,
|
@@ -717,6 +751,8 @@ module Slack
|
|
717
751
|
'could_not_unarchive_channel' => CouldNotUnarchiveChannel,
|
718
752
|
'custom_integration_not_allowed_at_enterprise' => CustomIntegrationNotAllowedAtEnterprise,
|
719
753
|
'data_not_available' => DataNotAvailable,
|
754
|
+
'datastore_error' => DatastoreError,
|
755
|
+
'datastore_migration_in_progress' => DatastoreMigrationInProgress,
|
720
756
|
'default_channel_restricted' => DefaultChannelRestricted,
|
721
757
|
'default_org_wide_channel' => DefaultOrgWideChannel,
|
722
758
|
'delete_not_allowed' => DeleteNotAllowed,
|
@@ -730,6 +766,7 @@ module Slack
|
|
730
766
|
'edit_window_closed' => EditWindowClosed,
|
731
767
|
'ekm_access_denied' => EkmAccessDenied,
|
732
768
|
'email_does_not_match' => EmailDoesNotMatch,
|
769
|
+
'email_not_verified' => EmailNotVerified,
|
733
770
|
'email_taken' => EmailTaken,
|
734
771
|
'emoji_limit_reached' => EmojiLimitReached,
|
735
772
|
'emoji_not_found' => EmojiNotFound,
|
@@ -737,6 +774,7 @@ module Slack
|
|
737
774
|
'enterprise_is_restricted' => EnterpriseIsRestricted,
|
738
775
|
'enterprise_not_found' => EnterpriseNotFound,
|
739
776
|
'entity_not_found' => EntityNotFound,
|
777
|
+
'error_adding_collaborators' => ErrorAddingCollaborators,
|
740
778
|
'error_bad_format' => ErrorBadFormat,
|
741
779
|
'error_bad_name_i18n' => ErrorBadNameI18n,
|
742
780
|
'error_bad_upload' => ErrorBadUpload,
|
@@ -747,7 +785,9 @@ module Slack
|
|
747
785
|
'error_name_taken' => ErrorNameTaken,
|
748
786
|
'error_name_taken_i18n' => ErrorNameTakenI18n,
|
749
787
|
'error_no_image' => ErrorNoImage,
|
788
|
+
'error_removing_collaborators' => ErrorRemovingCollaborators,
|
750
789
|
'error_too_big' => ErrorTooBig,
|
790
|
+
'error_unpublishing_workflows' => ErrorUnpublishingWorkflows,
|
751
791
|
'exchanged_trigger_id' => ExchangedTriggerId,
|
752
792
|
'expired_trigger_id' => ExpiredTriggerId,
|
753
793
|
'external_channel_migrating' => ExternalChannelMigrating,
|
@@ -805,6 +845,8 @@ module Slack
|
|
805
845
|
'file_uploads_disabled' => FileUploadsDisabled,
|
806
846
|
'forbidden_handle' => ForbiddenHandle,
|
807
847
|
'forbidden_team' => ForbiddenTeam,
|
848
|
+
'free_team_not_allowed' => FreeTeamNotAllowed,
|
849
|
+
'function_not_found' => FunctionNotFound,
|
808
850
|
'group_already_linked_to_channel' => GroupAlreadyLinkedToChannel,
|
809
851
|
'group_must_not_be_empty' => GroupMustNotBeEmpty,
|
810
852
|
'group_not_found' => GroupNotFound,
|
@@ -840,7 +882,9 @@ module Slack
|
|
840
882
|
'invalid_code' => InvalidCode,
|
841
883
|
'invalid_created_by' => InvalidCreatedBy,
|
842
884
|
'invalid_cursor' => InvalidCursor,
|
885
|
+
'invalid_datastore' => InvalidDatastore,
|
843
886
|
'invalid_date' => InvalidDate,
|
887
|
+
'invalid_domains' => InvalidDomains,
|
844
888
|
'invalid_duration' => InvalidDuration,
|
845
889
|
'invalid_email' => InvalidEmail,
|
846
890
|
'invalid_emoji' => InvalidEmoji,
|
@@ -884,6 +928,7 @@ module Slack
|
|
884
928
|
'invalid_scheduled_message_id' => InvalidScheduledMessageId,
|
885
929
|
'invalid_scopes' => InvalidScopes,
|
886
930
|
'invalid_search_channel_type' => InvalidSearchChannelType,
|
931
|
+
'invalid_setting' => InvalidSetting,
|
887
932
|
'invalid_sort' => InvalidSort,
|
888
933
|
'invalid_sort_dir' => InvalidSortDir,
|
889
934
|
'invalid_source' => InvalidSource,
|
@@ -893,6 +938,7 @@ module Slack
|
|
893
938
|
'invalid_team' => InvalidTeam,
|
894
939
|
'invalid_team_id' => InvalidTeamId,
|
895
940
|
'invalid_team_ids' => InvalidTeamIds,
|
941
|
+
'invalid_thread_ts' => InvalidThreadTs,
|
896
942
|
'invalid_time' => InvalidTime,
|
897
943
|
'invalid_timestamp' => InvalidTimestamp,
|
898
944
|
'invalid_title' => InvalidTitle,
|
@@ -911,6 +957,7 @@ module Slack
|
|
911
957
|
'invalid_user_id' => InvalidUserId,
|
912
958
|
'invalid_users' => InvalidUsers,
|
913
959
|
'invalid_value' => InvalidValue,
|
960
|
+
'invalid_workflow_auth_strategy' => InvalidWorkflowAuthStrategy,
|
914
961
|
'invite_from_same_org' => InviteFromSameOrg,
|
915
962
|
'invite_lookup_error' => InviteLookupError,
|
916
963
|
'invite_not_found' => InviteNotFound,
|
@@ -921,6 +968,7 @@ module Slack
|
|
921
968
|
'invitor_cannot_see_channel' => InvitorCannotSeeChannel,
|
922
969
|
'is_archived' => IsArchived,
|
923
970
|
'is_bot' => IsBot,
|
971
|
+
'is_idp_managed' => IsIdpManaged,
|
924
972
|
'is_inactive' => IsInactive,
|
925
973
|
'is_pending_connected_to_org' => IsPendingConnectedToOrg,
|
926
974
|
'last_member' => LastMember,
|
@@ -934,6 +982,7 @@ module Slack
|
|
934
982
|
'managed_channel_not_supported' => ManagedChannelNotSupported,
|
935
983
|
'member_analytics_disabled' => MemberAnalyticsDisabled,
|
936
984
|
'member_limit_exceeded' => MemberLimitExceeded,
|
985
|
+
'message_limit_exceeded' => MessageLimitExceeded,
|
937
986
|
'message_not_found' => MessageNotFound,
|
938
987
|
'message_too_long' => MessageTooLong,
|
939
988
|
'messages_tab_disabled' => MessagesTabDisabled,
|
@@ -942,6 +991,7 @@ module Slack
|
|
942
991
|
'metadata_only_does_not_support_date' => MetadataOnlyDoesNotSupportDate,
|
943
992
|
'metadata_too_large' => MetadataTooLarge,
|
944
993
|
'method_deprecated' => MethodDeprecated,
|
994
|
+
'method_not_supported' => MethodNotSupported,
|
945
995
|
'method_not_supported_for_channel_type' => MethodNotSupportedForChannelType,
|
946
996
|
'migration_in_progress' => MigrationInProgress,
|
947
997
|
'missing_args' => MissingArgs,
|
@@ -968,6 +1018,7 @@ module Slack
|
|
968
1018
|
'must_provide_team_name' => MustProvideTeamName,
|
969
1019
|
'must_revoke_access' => MustRevokeAccess,
|
970
1020
|
'name_already_exists' => NameAlreadyExists,
|
1021
|
+
'name_not_allowed' => NameNotAllowed,
|
971
1022
|
'name_taken' => NameTaken,
|
972
1023
|
'name_taken_in_org' => NameTakenInOrg,
|
973
1024
|
'name_too_long' => NameTooLong,
|
@@ -976,6 +1027,7 @@ module Slack
|
|
976
1027
|
'no_bot_user_for_app' => NoBotUserForApp,
|
977
1028
|
'no_channel' => NoChannel,
|
978
1029
|
'no_channel_memberships' => NoChannelMemberships,
|
1030
|
+
'no_domains_provided' => NoDomainsProvided,
|
979
1031
|
'no_dual_broadcast_content_update' => NoDualBroadcastContentUpdate,
|
980
1032
|
'no_image_uploaded' => NoImageUploaded,
|
981
1033
|
'no_item_specified' => NoItemSpecified,
|
@@ -983,12 +1035,14 @@ module Slack
|
|
983
1035
|
'no_permission' => NoPermission,
|
984
1036
|
'no_pin' => NoPin,
|
985
1037
|
'no_reaction' => NoReaction,
|
1038
|
+
'no_refresh_token' => NoRefreshToken,
|
986
1039
|
'no_resolution_found' => NoResolutionFound,
|
987
1040
|
'no_scopes' => NoScopes,
|
988
1041
|
'no_such_subteam' => NoSuchSubteam,
|
989
1042
|
'no_team_ids_given' => NoTeamIdsGiven,
|
990
1043
|
'no_teams_to_disconnect' => NoTeamsToDisconnect,
|
991
1044
|
'no_text' => NoText,
|
1045
|
+
'no_tokens_found' => NoTokensFound,
|
992
1046
|
'no_user' => NoUser,
|
993
1047
|
'no_users_provided' => NoUsersProvided,
|
994
1048
|
'no_valid_channels' => NoValidChannels,
|
@@ -1026,6 +1080,7 @@ module Slack
|
|
1026
1080
|
'org_level_email_display_disabled' => OrgLevelEmailDisplayDisabled,
|
1027
1081
|
'org_login_required' => OrgLoginRequired,
|
1028
1082
|
'org_not_found' => OrgNotFound,
|
1083
|
+
'org_resolution_required' => OrgResolutionRequired,
|
1029
1084
|
'org_user_not_in_team' => OrgUserNotInTeam,
|
1030
1085
|
'over_max_entity_limit' => OverMaxEntityLimit,
|
1031
1086
|
'over_pagination_limit' => OverPaginationLimit,
|
@@ -1044,6 +1099,7 @@ module Slack
|
|
1044
1099
|
'preview_feature_not_available' => PreviewFeatureNotAvailable,
|
1045
1100
|
'primary_usergroup_not_found' => PrimaryUsergroupNotFound,
|
1046
1101
|
'profile_set_failed' => ProfileSetFailed,
|
1102
|
+
'providers_not_found' => ProvidersNotFound,
|
1047
1103
|
'public_video_not_allowed' => PublicVideoNotAllowed,
|
1048
1104
|
'published_app_only' => PublishedAppOnly,
|
1049
1105
|
'push_limit_reached' => PushLimitReached,
|
@@ -1075,7 +1131,6 @@ module Slack
|
|
1075
1131
|
'slack_connect_clip_sharing_blocked' => SlackConnectClipSharingBlocked,
|
1076
1132
|
'slack_connect_file_link_sharing_blocked' => SlackConnectFileLinkSharingBlocked,
|
1077
1133
|
'slack_connect_file_upload_sharing_blocked' => SlackConnectFileUploadSharingBlocked,
|
1078
|
-
'slack_connect_team_blocked' => SlackConnectTeamBlocked,
|
1079
1134
|
'snippet_too_large' => SnippetTooLarge,
|
1080
1135
|
'snooze_end_failed' => SnoozeEndFailed,
|
1081
1136
|
'snooze_failed' => SnoozeFailed,
|
@@ -1092,13 +1147,16 @@ module Slack
|
|
1092
1147
|
'team_id_required_for_enterprise' => TeamIdRequiredForEnterprise,
|
1093
1148
|
'team_not_found' => TeamNotFound,
|
1094
1149
|
'team_not_on_enterprise' => TeamNotOnEnterprise,
|
1150
|
+
'team_quota_exceeded' => TeamQuotaExceeded,
|
1095
1151
|
'teams_not_found' => TeamsNotFound,
|
1152
|
+
'template_not_visible' => TemplateNotVisible,
|
1096
1153
|
'thread_locked' => ThreadLocked,
|
1097
1154
|
'thread_not_found' => ThreadNotFound,
|
1098
1155
|
'time_in_past' => TimeInPast,
|
1099
1156
|
'time_too_far' => TimeTooFar,
|
1100
1157
|
'token_already_exchanged' => TokenAlreadyExchanged,
|
1101
1158
|
'token_expired' => TokenExpired,
|
1159
|
+
'token_not_found' => TokenNotFound,
|
1102
1160
|
'token_revoked' => TokenRevoked,
|
1103
1161
|
'token_rotation_not_enabled' => TokenRotationNotEnabled,
|
1104
1162
|
'too_large' => TooLarge,
|
@@ -1108,6 +1166,7 @@ module Slack
|
|
1108
1166
|
'too_many_contact_cards' => TooManyContactCards,
|
1109
1167
|
'too_many_convos_for_app_on_team' => TooManyConvosForAppOnTeam,
|
1110
1168
|
'too_many_convos_for_team' => TooManyConvosForTeam,
|
1169
|
+
'too_many_domains_provided' => TooManyDomainsProvided,
|
1111
1170
|
'too_many_emails' => TooManyEmails,
|
1112
1171
|
'too_many_emoji' => TooManyEmoji,
|
1113
1172
|
'too_many_entities' => TooManyEntities,
|
@@ -1125,6 +1184,7 @@ module Slack
|
|
1125
1184
|
'trigger_exchanged' => TriggerExchanged,
|
1126
1185
|
'trigger_expired' => TriggerExpired,
|
1127
1186
|
'two_factor_setup_required' => TwoFactorSetupRequired,
|
1187
|
+
'unable_to_delete' => UnableToDelete,
|
1128
1188
|
'unable_to_fetch_custom_emojis' => UnableToFetchCustomEmojis,
|
1129
1189
|
'unable_to_link_idp_group_and_channel' => UnableToLinkIdpGroupAndChannel,
|
1130
1190
|
'unable_to_process_post_request' => UnableToProcessPostRequest,
|
@@ -1147,6 +1207,7 @@ module Slack
|
|
1147
1207
|
'update_failed' => UpdateFailed,
|
1148
1208
|
'ura_max_channels' => UraMaxChannels,
|
1149
1209
|
'url_in_message' => UrlInMessage,
|
1210
|
+
'url_restriction_not_supported' => UrlRestrictionNotSupported,
|
1150
1211
|
'user_already_deleted' => UserAlreadyDeleted,
|
1151
1212
|
'user_already_team_member' => UserAlreadyTeamMember,
|
1152
1213
|
'user_cannot_create_channel' => UserCannotCreateChannel,
|
@@ -1171,6 +1232,7 @@ module Slack
|
|
1171
1232
|
'users_not_found' => UsersNotFound,
|
1172
1233
|
'validation_errors' => ValidationErrors,
|
1173
1234
|
'view_too_large' => ViewTooLarge,
|
1235
|
+
'workflows_export_csv_not_enabled' => WorkflowsExportCsvNotEnabled,
|
1174
1236
|
}.freeze
|
1175
1237
|
end
|
1176
1238
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module Web
|
5
|
+
module Api
|
6
|
+
module Options
|
7
|
+
def encode_options_as_json(options, keys)
|
8
|
+
encoded_options = options.slice(*keys).transform_values do |value|
|
9
|
+
encode_json(value)
|
10
|
+
end
|
11
|
+
options.merge(encoded_options)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def encode_json(value)
|
17
|
+
if value.is_a?(String)
|
18
|
+
value
|
19
|
+
else
|
20
|
+
JSON.dump(value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,69 +1,21 @@
|
|
1
1
|
diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
|
2
|
-
index
|
2
|
+
index b49065a..bf202f1 100644
|
3
3
|
--- a/lib/slack/web/api/endpoints/chat.rb
|
4
4
|
+++ b/lib/slack/web/api/endpoints/chat.rb
|
5
|
-
@@ -122,
|
5
|
+
@@ -122,7 +122,7 @@ module Slack
|
6
6
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postEphemeral.json
|
7
7
|
def chat_postEphemeral(options = {})
|
8
8
|
raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
|
9
9
|
- raise ArgumentError, 'Required arguments :text missing' if options[:text].nil?
|
10
|
-
+ raise ArgumentError, '
|
10
|
+
+ raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?
|
11
11
|
raise ArgumentError, 'Required arguments :user missing' if options[:user].nil?
|
12
12
|
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
|
13
|
-
|
14
|
-
+
|
15
|
-
+ attachments = options[:attachments]
|
16
|
-
+ attachments = JSON.dump(attachments) unless attachments.is_a?(String)
|
17
|
-
+ options = options.merge(attachments: attachments)
|
18
|
-
+ end
|
19
|
-
+ # blocks must be passed as an encoded JSON string
|
20
|
-
+ if options.key?(:blocks)
|
21
|
-
+ blocks = options[:blocks]
|
22
|
-
+ blocks = JSON.dump(blocks) unless blocks.is_a?(String)
|
23
|
-
+ options = options.merge(blocks: blocks)
|
24
|
-
+ end
|
25
|
-
post('chat.postEphemeral', options)
|
26
|
-
end
|
27
|
-
|
28
|
-
@@ -167,6 +179,19 @@ module Slack
|
29
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postMessage.json
|
30
|
-
def chat_postMessage(options = {})
|
31
|
-
raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
|
32
|
-
+ raise ArgumentError, 'Required arguments :text, :attachments or :blocks missing' if options[:text].nil? && options[:attachments].nil? && options[:blocks].nil?
|
33
|
-
+ # attachments must be passed as an encoded JSON string
|
34
|
-
+ if options.key?(:attachments)
|
35
|
-
+ attachments = options[:attachments]
|
36
|
-
+ attachments = JSON.dump(attachments) unless attachments.is_a?(String)
|
37
|
-
+ options = options.merge(attachments: attachments)
|
38
|
-
+ end
|
39
|
-
+ # blocks must be passed as an encoded JSON string
|
40
|
-
+ if options.key?(:blocks)
|
41
|
-
+ blocks = options[:blocks]
|
42
|
-
+ blocks = JSON.dump(blocks) unless blocks.is_a?(String)
|
43
|
-
+ options = options.merge(blocks: blocks)
|
44
|
-
+ end
|
45
|
-
post('chat.postMessage', options)
|
46
|
-
end
|
47
|
-
|
48
|
-
@@ -268,8 +293,21 @@ module Slack
|
49
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.update.json
|
13
|
+
options = encode_options_as_json(options, %i[attachments blocks])
|
14
|
+
@@ -274,6 +274,7 @@ module Slack
|
50
15
|
def chat_update(options = {})
|
51
16
|
raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
|
52
|
-
+ raise ArgumentError, 'Required arguments :text, :attachments, :blocks or :reply_broadcast missing' if options[:text].nil? && options[:attachments].nil? && options[:blocks].nil? && options[:reply_broadcast].nil?
|
53
17
|
raise ArgumentError, 'Required arguments :ts missing' if options[:ts].nil?
|
18
|
+
+ raise ArgumentError, 'At least one of :attachments, :blocks, :text, :reply_broadcast is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil? && options[:reply_broadcast].nil?
|
54
19
|
options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
|
55
|
-
|
56
|
-
+ if options.key?(:attachments)
|
57
|
-
+ attachments = options[:attachments]
|
58
|
-
+ attachments = JSON.dump(attachments) unless attachments.is_a?(String)
|
59
|
-
+ options = options.merge(attachments: attachments)
|
60
|
-
+ end
|
61
|
-
+ # blocks must be passed as an encoded JSON string
|
62
|
-
+ if options.key?(:blocks)
|
63
|
-
+ blocks = options[:blocks]
|
64
|
-
+ blocks = JSON.dump(blocks) unless blocks.is_a?(String)
|
65
|
-
+ options = options.merge(blocks: blocks)
|
66
|
-
+ end
|
20
|
+
options = encode_options_as_json(options, %i[attachments blocks metadata])
|
67
21
|
post('chat.update', options)
|
68
|
-
end
|
69
|
-
end
|
@@ -37,6 +37,14 @@ module Slack
|
|
37
37
|
<% data['args'].select{ |k, v| v['required'] }.each do |arg_name, arg_v| %>
|
38
38
|
raise ArgumentError, 'Required arguments :<%= arg_name %> missing' if options[:<%= arg_name %>].nil?
|
39
39
|
<% end %>
|
40
|
+
<% data['arg_groups']&.each do |arg_group| %>
|
41
|
+
<% arg_string = arg_group['args'].map { |arg_name| ":#{arg_name}" }.join(', ') %>
|
42
|
+
<% if arg_group['mutually_exclusive'] %>
|
43
|
+
raise ArgumentError, 'Exactly one of <%= arg_string %> is required' unless <%= arg_group['args'].map { |arg_name| "options[:#{arg_name}].nil?" }.join(' ^ ') %>
|
44
|
+
<% else %>
|
45
|
+
raise ArgumentError, 'At least one of <%= arg_string %> is required' if <%= arg_group['args'].map { |arg_name| "options[:#{arg_name}].nil?"}.join(' && ') %>
|
46
|
+
<% end %>
|
47
|
+
<% end %>
|
40
48
|
<% if data['group'] == 'groups' && data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
|
41
49
|
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
|
42
50
|
<% elsif data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
|
@@ -51,6 +59,10 @@ module Slack
|
|
51
59
|
<% if data['deprecated'] %>
|
52
60
|
logger.warn('<%= group %>.<%= name %>: <%= data['deprecation']['deprecation_warning']%> Alternative methods: <%= data['deprecation']['alternative_methods'].join(', ')%>.')
|
53
61
|
<% end %>
|
62
|
+
<% json_args = data['args'].map { |arg_name, arg_v| arg_name if arg_v['format'] == 'json' }.compact %>
|
63
|
+
<% if json_args.any? %>
|
64
|
+
options = encode_options_as_json(options, %i[<%= json_args.join(' ') %>])
|
65
|
+
<% end %>
|
54
66
|
<% if data['args'].keys.include?('cursor') %>
|
55
67
|
if block_given?
|
56
68
|
Pagination::Cursor.new(self, :<%= group.gsub(".", "_") %>_<%= name %>, options).each do |page|
|
@@ -7,13 +7,49 @@ RSpec.describe Slack::Web::Api::Endpoints::<%= group.gsub(".", "_").camelize %>
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
8
|
<% names.sort.each_with_index do |(name, data), index| %>
|
9
9
|
<% next if data['mixin'] %>
|
10
|
-
<%
|
11
|
-
<%
|
10
|
+
<% group_required_params = data['arg_groups']&.map { |grp| grp['args'].first } || [] %>
|
11
|
+
<% required_params = data['args'].select{ |k, v| v['required'] || group_required_params.include?(k) } %>
|
12
|
+
<% json_params = data['args'].map { |arg_name, arg_v| arg_name if arg_v['format'] == 'json' }.compact %>
|
13
|
+
<% next if (required_params.none? || custom_spec_exists) && json_params.none? && data['arg_groups'].nil? %>
|
14
|
+
<% method_name = [group.gsub(".", "_"), name].join('_') %>
|
15
|
+
<% example_params = required_params.to_h { |var, opts| [var, opts['example']] } %>
|
12
16
|
context '<%= group %>_<%= name %>' do
|
17
|
+
<% unless custom_spec_exists %>
|
13
18
|
<% required_params.each do |arg_name, arg_v| %>
|
14
19
|
it 'requires <%= arg_name %>' do
|
15
|
-
<% params_except_required =
|
16
|
-
expect { client.<%=
|
20
|
+
<% params_except_required = example_params.reject { |name, _| name == arg_name }.map { |name, val| "#{name}: %q[#{val}]" }.join(', ') %>
|
21
|
+
expect { client.<%= method_name %><%= params_except_required.empty? ? '' : "(#{params_except_required})" %> }.to raise_error ArgumentError, /Required arguments :<%= arg_name %> missing/
|
22
|
+
end
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
<% data['arg_groups']&.each do |arg_group| %>
|
26
|
+
it 'requires one of <%= arg_group['args'].join(', ') %>' do
|
27
|
+
<% params_except_required = example_params.reject { |name, _| arg_group['args'].include?(name) }.map { |name, val| "#{name}: %q[#{val}]" }.join(', ') %>
|
28
|
+
<% error_message = arg_group['mutually_exclusive'] ? 'Exactly' : 'At least' %>
|
29
|
+
expect { client.<%= method_name %><%= params_except_required.empty? ? '' : "(#{params_except_required})" %> }.to raise_error ArgumentError, /<%= error_message %> one of/
|
30
|
+
<% (1..arg_group['args'].length).each do |n| %>
|
31
|
+
<% arg_group['args'].combination(n) do |names| %>
|
32
|
+
<% params = names.map { |name| "#{name}: %q[#{data['args'][name]['example']}]" }.join(', ') %>
|
33
|
+
<% params = "#{params}, #{params_except_required}" unless params_except_required.empty? %>
|
34
|
+
<% if n == 1 || !arg_group['mutually_exclusive'] %>
|
35
|
+
|
36
|
+
expect(client).to receive(:post).with('<%= group %>.<%= name %>', {<%= params %>})
|
37
|
+
client.<%= method_name %><%= "(#{params})" %>
|
38
|
+
<% else %>
|
39
|
+
|
40
|
+
expect { client.<%= method_name %><%= "(#{params})" %> }.to raise_error ArgumentError, /<%= error_message %> one of/
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
<% end %>
|
44
|
+
end
|
45
|
+
<% end %>
|
46
|
+
<% if json_params.any? %>
|
47
|
+
<% example_json_params = json_params.to_h { |name| [name, {data: ['data']}] } %>
|
48
|
+
<% params = example_params.merge(example_json_params).map { |name, val| val = val.is_a?(String) ? "%q[#{val}]" : val; "#{name}: #{val}" }.join(', ') %>
|
49
|
+
<% expected_params = example_params.merge(example_json_params.transform_values { |v| JSON.dump(v) }).map { |name, val| val = "%q[#{val}]"; "#{name}: #{val}" }.join(', ') %>
|
50
|
+
it 'encodes <%= json_params.join(', ') %> as json' do
|
51
|
+
expect(client).to receive(:post).with('<%= group %>.<%= name %>', {<%= expected_params %>})
|
52
|
+
client.<%= method_name %>(<%= params %>)
|
17
53
|
end
|
18
54
|
<% end %>
|
19
55
|
end
|