restforce 3.0.1 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +9 -9
  3. data/.github/ISSUE_TEMPLATE/unhandled-salesforce-error.md +17 -0
  4. data/.github/dependabot.yml +19 -0
  5. data/.rubocop.yml +13 -14
  6. data/.rubocop_todo.yml +128 -81
  7. data/CHANGELOG.md +107 -1
  8. data/CONTRIBUTING.md +21 -1
  9. data/Dockerfile +31 -0
  10. data/Gemfile +10 -6
  11. data/README.md +168 -31
  12. data/UPGRADING.md +38 -0
  13. data/docker-compose.yml +7 -0
  14. data/lib/restforce/abstract_client.rb +1 -0
  15. data/lib/restforce/attachment.rb +1 -0
  16. data/lib/restforce/collection.rb +7 -2
  17. data/lib/restforce/concerns/api.rb +10 -7
  18. data/lib/restforce/concerns/authentication.rb +10 -0
  19. data/lib/restforce/concerns/base.rb +4 -2
  20. data/lib/restforce/concerns/batch_api.rb +87 -0
  21. data/lib/restforce/concerns/caching.rb +7 -0
  22. data/lib/restforce/concerns/canvas.rb +1 -0
  23. data/lib/restforce/concerns/connection.rb +3 -3
  24. data/lib/restforce/concerns/picklists.rb +4 -3
  25. data/lib/restforce/concerns/streaming.rb +73 -3
  26. data/lib/restforce/config.rb +8 -1
  27. data/lib/restforce/document.rb +1 -0
  28. data/lib/restforce/error_code.rb +638 -0
  29. data/lib/restforce/file_part.rb +24 -0
  30. data/lib/restforce/mash.rb +8 -3
  31. data/lib/restforce/middleware/authentication/jwt_bearer.rb +38 -0
  32. data/lib/restforce/middleware/authentication.rb +7 -3
  33. data/lib/restforce/middleware/caching.rb +1 -1
  34. data/lib/restforce/middleware/instance_url.rb +1 -1
  35. data/lib/restforce/middleware/logger.rb +8 -7
  36. data/lib/restforce/middleware/multipart.rb +1 -0
  37. data/lib/restforce/middleware/raise_error.rb +24 -9
  38. data/lib/restforce/middleware.rb +2 -0
  39. data/lib/restforce/signed_request.rb +1 -0
  40. data/lib/restforce/sobject.rb +1 -0
  41. data/lib/restforce/tooling/client.rb +3 -3
  42. data/lib/restforce/version.rb +1 -1
  43. data/lib/restforce.rb +21 -3
  44. data/restforce.gemspec +11 -20
  45. data/spec/fixtures/test_private.key +27 -0
  46. data/spec/integration/abstract_client_spec.rb +83 -33
  47. data/spec/integration/data/client_spec.rb +6 -2
  48. data/spec/spec_helper.rb +24 -1
  49. data/spec/support/client_integration.rb +7 -7
  50. data/spec/support/concerns.rb +1 -1
  51. data/spec/support/fixture_helpers.rb +3 -5
  52. data/spec/support/middleware.rb +1 -2
  53. data/spec/unit/collection_spec.rb +20 -2
  54. data/spec/unit/concerns/api_spec.rb +12 -12
  55. data/spec/unit/concerns/authentication_spec.rb +39 -4
  56. data/spec/unit/concerns/batch_api_spec.rb +107 -0
  57. data/spec/unit/concerns/caching_spec.rb +26 -0
  58. data/spec/unit/concerns/connection_spec.rb +2 -2
  59. data/spec/unit/concerns/streaming_spec.rb +144 -4
  60. data/spec/unit/config_spec.rb +1 -1
  61. data/spec/unit/error_code_spec.rb +61 -0
  62. data/spec/unit/mash_spec.rb +5 -0
  63. data/spec/unit/middleware/authentication/jwt_bearer_spec.rb +62 -0
  64. data/spec/unit/middleware/authentication/password_spec.rb +2 -2
  65. data/spec/unit/middleware/authentication/token_spec.rb +2 -2
  66. data/spec/unit/middleware/authentication_spec.rb +31 -4
  67. data/spec/unit/middleware/gzip_spec.rb +2 -2
  68. data/spec/unit/middleware/raise_error_spec.rb +57 -17
  69. data/spec/unit/signed_request_spec.rb +1 -1
  70. data/spec/unit/sobject_spec.rb +2 -5
  71. metadata +39 -108
  72. data/lib/restforce/upload_io.rb +0 -9
@@ -0,0 +1,638 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Restforce
4
+ module ErrorCode
5
+ GITHUB_ISSUE_URL = "https://github.com/restforce/restforce/issues/new?template=" \
6
+ "unhandled-salesforce-error.md&title=Unhandled+Salesforce+error" \
7
+ "%3A+%3Cinsert+error+code+here%3E"
8
+
9
+ # We define all of the known errors returned by Salesforce based on the
10
+ # documentation at
11
+ # https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#statuscode
12
+ # Previously, these were defined dynamically at runtime using `Module.const_set`. Now
13
+ # we define them up-front.
14
+ # It is possible that we will be missing some errors, so we will handle this in
15
+ # at least a semi-graceful manner.
16
+ class AllOrNoneOperationRolledBack < ResponseError; end
17
+
18
+ class AlreadyInProcess < ResponseError; end
19
+
20
+ class ApexError < ResponseError; end
21
+
22
+ class ApiCurrentlyDisabled < ResponseError; end
23
+
24
+ class ApiDisabledForOrg < ResponseError; end
25
+
26
+ class AssigneeTypeRequired < ResponseError; end
27
+
28
+ class BadCustomEntityParentDomain < ResponseError; end
29
+
30
+ class BccNotAllowedIfBccComplianceEnabled < ResponseError; end
31
+
32
+ class BccSelfNotAllowedIfBccComplianceEnabled < ResponseError; end
33
+
34
+ class BigObjectUnsupportedOperation < ResponseError; end
35
+
36
+ class CannotCascadeProductActive < ResponseError; end
37
+
38
+ class CannotChangeFieldTypeOfApexReferencedField < ResponseError; end
39
+
40
+ class CannotCreateAnotherManagedPackage < ResponseError; end
41
+
42
+ class CannotDeactivateDivision < ResponseError; end
43
+
44
+ class CannotDeleteLastDatedConversionRate < ResponseError; end
45
+
46
+ class CannotDeleteManagedObject < ResponseError; end
47
+
48
+ class CannotDisableLastAdmin < ResponseError; end
49
+
50
+ class CannotEnableIpRestrictRequests < ResponseError; end
51
+
52
+ class CannotExecuteFlowTrigger < ResponseError; end
53
+
54
+ class CannotInsertUpdateActivateEntity < ResponseError; end
55
+
56
+ class CannotModifyManagedObject < ResponseError; end
57
+
58
+ class CannotRenameApexReferencedField < ResponseError; end
59
+
60
+ class CannotRenameApexReferencedObject < ResponseError; end
61
+
62
+ class CannotReparentRecord < ResponseError; end
63
+
64
+ class CannotResolveName < ResponseError; end
65
+
66
+ class CannotUpdateConvertedLead < ResponseError; end
67
+
68
+ class CantDisableCorpCurrency < ResponseError; end
69
+
70
+ class CantUnsetCorpCurrency < ResponseError; end
71
+
72
+ class ChildShareFailsParent < ResponseError; end
73
+
74
+ class CircularDependency < ResponseError; end
75
+
76
+ class CommunityNotAccessible < ResponseError; end
77
+
78
+ class CustomClobFieldLimitExceeded < ResponseError; end
79
+
80
+ class CustomEntityOrFieldLimit < ResponseError; end
81
+
82
+ class CustomFieldIndexLimitExceeded < ResponseError; end
83
+
84
+ class CustomIndexExists < ResponseError; end
85
+
86
+ class CustomLinkLimitExceeded < ResponseError; end
87
+
88
+ class CustomMetadataLimitExceeded < ResponseError; end
89
+
90
+ class CustomSettingsLimitExceeded < ResponseError; end
91
+
92
+ class CustomTabLimitExceeded < ResponseError; end
93
+
94
+ class DeleteFailed < ResponseError; end
95
+
96
+ class DependencyExists < ResponseError; end
97
+
98
+ class DuplicateCaseSolution < ResponseError; end
99
+
100
+ class DuplicateCustomEntityDefinition < ResponseError; end
101
+
102
+ class DuplicateCustomTabMotif < ResponseError; end
103
+
104
+ class DuplicateDeveloperName < ResponseError; end
105
+
106
+ class DuplicatesDetected < ResponseError; end
107
+
108
+ class DuplicateExternalId < ResponseError; end
109
+
110
+ class DuplicateMasterLabel < ResponseError; end
111
+
112
+ class DuplicateSenderDisplayName < ResponseError; end
113
+
114
+ class DuplicateUsername < ResponseError; end
115
+
116
+ class DuplicateValue < ResponseError; end
117
+
118
+ class EmailAddressBounced < ResponseError; end
119
+
120
+ class EmailNotProcessedDueToPriorError < ResponseError; end
121
+
122
+ class EmailOptedOut < ResponseError; end
123
+
124
+ class EmailTemplateFormulaError < ResponseError; end
125
+
126
+ class EmailTemplateMergefieldAccessError < ResponseError; end
127
+
128
+ class EmailTemplateMergefieldError < ResponseError; end
129
+
130
+ class EmailTemplateMergefieldValueError < ResponseError; end
131
+
132
+ class EmailTemplateProcessingError < ResponseError; end
133
+
134
+ class EmptyScontrolFileName < ResponseError; end
135
+
136
+ class EntityFailedIflastmodifiedOnUpdate < ResponseError; end
137
+
138
+ class EntityIsArchived < ResponseError; end
139
+
140
+ class EntityIsDeleted < ResponseError; end
141
+
142
+ class EntityIsLocked < ResponseError; end
143
+
144
+ class EnvironmentHubMembershipConflict < ResponseError; end
145
+
146
+ class ErrorInMailer < ResponseError; end
147
+
148
+ class ExceededMaxSemijoinSubselects < ResponseError; end
149
+
150
+ class FailedActivation < ResponseError; end
151
+
152
+ class FieldCustomValidationException < ResponseError; end
153
+
154
+ class FieldFilterValidationException < ResponseError; end
155
+
156
+ class FieldIntegrityException < ResponseError; end
157
+
158
+ class FilteredLookupLimitExceeded < ResponseError; end
159
+
160
+ class Forbidden < ResponseError; end
161
+
162
+ class HtmlFileUploadNotAllowed < ResponseError; end
163
+
164
+ class IllegalQueryParameterValue < ResponseError; end
165
+
166
+ class ImageTooLarge < ResponseError; end
167
+
168
+ class InactiveOwnerOrUser < ResponseError; end
169
+
170
+ class InsertUpdateDeleteNotAllowedDuringMaintenance < ResponseError; end
171
+
172
+ class InsufficientAccessOnCrossReferenceEntity < ResponseError; end
173
+
174
+ class InsufficientAccessOrReadonly < ResponseError; end
175
+
176
+ class InvalidAccessLevel < ResponseError; end
177
+
178
+ class InvalidArgumentType < ResponseError; end
179
+
180
+ class InvalidAssigneeType < ResponseError; end
181
+
182
+ class InvalidAssignmentRule < ResponseError; end
183
+
184
+ class InvalidBatchOperation < ResponseError; end
185
+
186
+ class InvalidContentType < ResponseError; end
187
+
188
+ class InvalidCreditCardInfo < ResponseError; end
189
+
190
+ class InvalidCrossReferenceKey < ResponseError; end
191
+
192
+ class InvalidCrossReferenceTypeForField < ResponseError; end
193
+
194
+ class InvalidCurrencyConvRate < ResponseError; end
195
+
196
+ class InvalidCurrencyCorpRate < ResponseError; end
197
+
198
+ class InvalidCurrencyIso < ResponseError; end
199
+
200
+ class InvalidEmailAddress < ResponseError; end
201
+
202
+ class InvalidEmptyKeyOwner < ResponseError; end
203
+
204
+ class InvalidEventSubscription < ResponseError; end
205
+
206
+ class InvalidField < ResponseError; end
207
+
208
+ class InvalidFieldForInsertUpdate < ResponseError; end
209
+
210
+ class InvalidFieldWhenUsingTemplate < ResponseError; end
211
+
212
+ class InvalidFilterAction < ResponseError; end
213
+
214
+ class InvalidIdField < ResponseError; end
215
+
216
+ class InvalidInetAddress < ResponseError; end
217
+
218
+ class InvalidLineitemCloneState < ResponseError; end
219
+
220
+ class InvalidMasterOrTranslatedSolution < ResponseError; end
221
+
222
+ class InvalidMessageIdReference < ResponseError; end
223
+
224
+ class InvalidOperation < ResponseError; end
225
+
226
+ class InvalidOperationWithExpiredPassword < ResponseError; end
227
+
228
+ class InvalidOperator < ResponseError; end
229
+
230
+ class InvalidOrNullForRestrictedPicklist < ResponseError; end
231
+
232
+ class InvalidQueryFilterOperator < ResponseError; end
233
+
234
+ class InvalidQueryLocator < ResponseError; end
235
+
236
+ class InvalidPartnerNetworkStatus < ResponseError; end
237
+
238
+ class InvalidPersonAccountOperation < ResponseError; end
239
+
240
+ class InvalidReadOnlyUserDml < ResponseError; end
241
+
242
+ class InvalidReplicationDate < ResponseError; end
243
+
244
+ class InvalidSaveAsActivityFlag < ResponseError; end
245
+
246
+ class InvalidSessionId < ResponseError; end
247
+
248
+ class InvalidStatus < ResponseError; end
249
+
250
+ class InvalidType < ResponseError; end
251
+
252
+ class InvalidTypeForOperation < ResponseError; end
253
+
254
+ class InvalidTypeOnFieldInRecord < ResponseError; end
255
+
256
+ class IpRangeLimitExceeded < ResponseError; end
257
+
258
+ class JigsawImportLimitExceeded < ResponseError; end
259
+
260
+ class JsonParserError < ResponseError; end
261
+
262
+ class LicenseLimitExceeded < ResponseError; end
263
+
264
+ class LightPortalUserException < ResponseError; end
265
+
266
+ class LimitExceeded < ResponseError; end
267
+
268
+ class LoginChallengeIssued < ResponseError; end
269
+
270
+ class LoginChallengePending < ResponseError; end
271
+
272
+ class LoginMustUseSecurityToken < ResponseError; end
273
+
274
+ class MalformedId < ResponseError; end
275
+
276
+ class MalformedQuery < ResponseError; end
277
+
278
+ class ManagerNotDefined < ResponseError; end
279
+
280
+ class MassmailRetryLimitExceeded < ResponseError; end
281
+
282
+ class MassMailLimitExceeded < ResponseError; end
283
+
284
+ class MaximumCcemailsExceeded < ResponseError; end
285
+
286
+ class MaximumDashboardComponentsExceeded < ResponseError; end
287
+
288
+ class MaximumHierarchyLevelsReached < ResponseError; end
289
+
290
+ class MaximumSizeOfAttachment < ResponseError; end
291
+
292
+ class MaximumSizeOfDocument < ResponseError; end
293
+
294
+ class MaxActionsPerRuleExceeded < ResponseError; end
295
+
296
+ class MaxActiveRulesExceeded < ResponseError; end
297
+
298
+ class MaxApprovalStepsExceeded < ResponseError; end
299
+
300
+ class MaxFormulasPerRuleExceeded < ResponseError; end
301
+
302
+ class MaxRulesExceeded < ResponseError; end
303
+
304
+ class MaxRuleEntriesExceeded < ResponseError; end
305
+
306
+ class MaxTaskDescriptionExceeded < ResponseError; end
307
+
308
+ class MaxTmRulesExceeded < ResponseError; end
309
+
310
+ class MaxTmRuleItemsExceeded < ResponseError; end
311
+
312
+ class MergeFailed < ResponseError; end
313
+
314
+ class MethodNotAllowed < ResponseError; end
315
+
316
+ class MissingArgument < ResponseError; end
317
+
318
+ class NonuniqueShippingAddress < ResponseError; end
319
+
320
+ class NoApplicableProcess < ResponseError; end
321
+
322
+ class NoAttachmentPermission < ResponseError; end
323
+
324
+ class NoInactiveDivisionMembers < ResponseError; end
325
+
326
+ class NoMassMailPermission < ResponseError; end
327
+
328
+ class NumberOutsideValidRange < ResponseError; end
329
+
330
+ class NumHistoryFieldsBySobjectExceeded < ResponseError; end
331
+
332
+ class OpWithInvalidUserTypeException < ResponseError; end
333
+
334
+ class OptedOutOfMassMail < ResponseError; end
335
+
336
+ class PackageLicenseRequired < ResponseError; end
337
+
338
+ class PlatformEventEncryptionError < ResponseError; end
339
+
340
+ class PlatformEventPublishingUnavailable < ResponseError; end
341
+
342
+ class PlatformEventPublishFailed < ResponseError; end
343
+
344
+ class PortalUserAlreadyExistsForContact < ResponseError; end
345
+
346
+ class PrivateContactOnAsset < ResponseError; end
347
+
348
+ class QueryTimeout < ResponseError; end
349
+
350
+ class RecordInUseByWorkflow < ResponseError; end
351
+
352
+ class RequestLimitExceeded < ResponseError; end
353
+
354
+ class RequestRunningTooLong < ResponseError; end
355
+
356
+ class RequiredFieldMissing < ResponseError; end
357
+
358
+ class SelfReferenceFromTrigger < ResponseError; end
359
+
360
+ class ServerUnavailable < ResponseError; end
361
+
362
+ class ShareNeededForChildOwner < ResponseError; end
363
+
364
+ class SingleEmailLimitExceeded < ResponseError; end
365
+
366
+ class StandardPriceNotDefined < ResponseError; end
367
+
368
+ class StorageLimitExceeded < ResponseError; end
369
+
370
+ class StringTooLong < ResponseError; end
371
+
372
+ class TabsetLimitExceeded < ResponseError; end
373
+
374
+ class TemplateNotActive < ResponseError; end
375
+
376
+ class TerritoryRealignInProgress < ResponseError; end
377
+
378
+ class TextDataOutsideSupportedCharset < ResponseError; end
379
+
380
+ class TooManyApexRequests < ResponseError; end
381
+
382
+ class TooManyEnumValue < ResponseError; end
383
+
384
+ class TransferRequiresRead < ResponseError; end
385
+
386
+ class UnableToLockRow < ResponseError; end
387
+
388
+ class UnavailableRecordtypeException < ResponseError; end
389
+
390
+ class UndeleteFailed < ResponseError; end
391
+
392
+ class UnknownException < ResponseError; end
393
+
394
+ class UnspecifiedEmailAddress < ResponseError; end
395
+
396
+ class UnsupportedApexTriggerOperation < ResponseError; end
397
+
398
+ class UnverifiedSenderAddress < ResponseError; end
399
+
400
+ class WeblinkSizeLimitExceeded < ResponseError; end
401
+
402
+ class WeblinkUrlInvalid < ResponseError; end
403
+
404
+ class WrongControllerType < ResponseError; end
405
+
406
+ # Maps `errorCode`s returned from Salesforce to the exception class
407
+ # to be used for these errors
408
+ ERROR_EXCEPTION_CLASSES = {
409
+ "ALL_OR_NONE_OPERATION_ROLLED_BACK" => AllOrNoneOperationRolledBack,
410
+ "ALREADY_IN_PROCESS" => AlreadyInProcess,
411
+ "APEX_ERROR" => ApexError,
412
+ "API_CURRENTLY_DISABLED" => ApiCurrentlyDisabled,
413
+ "API_DISABLED_FOR_ORG" => ApiDisabledForOrg,
414
+ "ASSIGNEE_TYPE_REQUIRED" => AssigneeTypeRequired,
415
+ "BAD_CUSTOM_ENTITY_PARENT_DOMAIN" => BadCustomEntityParentDomain,
416
+ "BCC_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED" =>
417
+ BccNotAllowedIfBccComplianceEnabled,
418
+ "BCC_SELF_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED" =>
419
+ BccSelfNotAllowedIfBccComplianceEnabled,
420
+ "BIG_OBJECT_UNSUPPORTED_OPERATION" => BigObjectUnsupportedOperation,
421
+ "CANNOT_CASCADE_PRODUCT_ACTIVE" => CannotCascadeProductActive,
422
+ "CANNOT_CHANGE_FIELD_TYPE_OF_APEX_REFERENCED_FIELD" =>
423
+ CannotChangeFieldTypeOfApexReferencedField,
424
+ "CANNOT_CREATE_ANOTHER_MANAGED_PACKAGE" => CannotCreateAnotherManagedPackage,
425
+ "CANNOT_DEACTIVATE_DIVISION" => CannotDeactivateDivision,
426
+ "CANNOT_DELETE_LAST_DATED_CONVERSION_RATE" =>
427
+ CannotDeleteLastDatedConversionRate,
428
+ "CANNOT_DELETE_MANAGED_OBJECT" => CannotDeleteManagedObject,
429
+ "CANNOT_DISABLE_LAST_ADMIN" => CannotDisableLastAdmin,
430
+ "CANNOT_ENABLE_IP_RESTRICT_REQUESTS" => CannotEnableIpRestrictRequests,
431
+ "CANNOT_EXECUTE_FLOW_TRIGGER" => CannotExecuteFlowTrigger,
432
+ "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" => CannotInsertUpdateActivateEntity,
433
+ "CANNOT_MODIFY_MANAGED_OBJECT" => CannotModifyManagedObject,
434
+ "CANNOT_RENAME_APEX_REFERENCED_FIELD" => CannotRenameApexReferencedField,
435
+ "CANNOT_RENAME_APEX_REFERENCED_OBJECT" => CannotRenameApexReferencedObject,
436
+ "CANNOT_REPARENT_RECORD" => CannotReparentRecord,
437
+ "CANNOT_RESOLVE_NAME" => CannotResolveName,
438
+ "CANNOT_UPDATE_CONVERTED_LEAD" => CannotUpdateConvertedLead,
439
+ "CANT_DISABLE_CORP_CURRENCY" => CantDisableCorpCurrency,
440
+ "CANT_UNSET_CORP_CURRENCY" => CantUnsetCorpCurrency,
441
+ "CHILD_SHARE_FAILS_PARENT" => ChildShareFailsParent,
442
+ "CIRCULAR_DEPENDENCY" => CircularDependency,
443
+ "COMMUNITY_NOT_ACCESSIBLE" => CommunityNotAccessible,
444
+ "CUSTOM_CLOB_FIELD_LIMIT_EXCEEDED" => CustomClobFieldLimitExceeded,
445
+ "CUSTOM_ENTITY_OR_FIELD_LIMIT" => CustomEntityOrFieldLimit,
446
+ "CUSTOM_FIELD_INDEX_LIMIT_EXCEEDED" => CustomFieldIndexLimitExceeded,
447
+ "CUSTOM_INDEX_EXISTS" => CustomIndexExists,
448
+ "CUSTOM_LINK_LIMIT_EXCEEDED" => CustomLinkLimitExceeded,
449
+ "CUSTOM_METADATA_LIMIT_EXCEEDED" => CustomMetadataLimitExceeded,
450
+ "CUSTOM_SETTINGS_LIMIT_EXCEEDED" => CustomSettingsLimitExceeded,
451
+ "CUSTOM_TAB_LIMIT_EXCEEDED" => CustomTabLimitExceeded,
452
+ "DELETE_FAILED" => DeleteFailed,
453
+ "DEPENDENCY_EXISTS" => DependencyExists,
454
+ "DUPLICATE_CASE_SOLUTION" => DuplicateCaseSolution,
455
+ "DUPLICATE_CUSTOM_ENTITY_DEFINITION" => DuplicateCustomEntityDefinition,
456
+ "DUPLICATE_CUSTOM_TAB_MOTIF" => DuplicateCustomTabMotif,
457
+ "DUPLICATE_DEVELOPER_NAME" => DuplicateDeveloperName,
458
+ "DUPLICATES_DETECTED" => DuplicatesDetected,
459
+ "DUPLICATE_EXTERNAL_ID" => DuplicateExternalId,
460
+ "DUPLICATE_MASTER_LABEL" => DuplicateMasterLabel,
461
+ "DUPLICATE_SENDER_DISPLAY_NAME" => DuplicateSenderDisplayName,
462
+ "DUPLICATE_USERNAME" => DuplicateUsername,
463
+ "DUPLICATE_VALUE" => DuplicateValue,
464
+ "EMAIL_ADDRESS_BOUNCED" => EmailAddressBounced,
465
+ "EMAIL_NOT_PROCESSED_DUE_TO_PRIOR_ERROR" => EmailNotProcessedDueToPriorError,
466
+ "EMAIL_OPTED_OUT" => EmailOptedOut,
467
+ "EMAIL_TEMPLATE_FORMULA_ERROR" => EmailTemplateFormulaError,
468
+ "EMAIL_TEMPLATE_MERGEFIELD_ACCESS_ERROR" =>
469
+ EmailTemplateMergefieldAccessError,
470
+ "EMAIL_TEMPLATE_MERGEFIELD_ERROR" => EmailTemplateMergefieldError,
471
+ "EMAIL_TEMPLATE_MERGEFIELD_VALUE_ERROR" => EmailTemplateMergefieldValueError,
472
+ "EMAIL_TEMPLATE_PROCESSING_ERROR" => EmailTemplateProcessingError,
473
+ "EMPTY_SCONTROL_FILE_NAME" => EmptyScontrolFileName,
474
+ "ENTITY_FAILED_IFLASTMODIFIED_ON_UPDATE" =>
475
+ EntityFailedIflastmodifiedOnUpdate,
476
+ "ENTITY_IS_ARCHIVED" => EntityIsArchived,
477
+ "ENTITY_IS_DELETED" => EntityIsDeleted,
478
+ "ENTITY_IS_LOCKED" => EntityIsLocked,
479
+ "ENVIRONMENT_HUB_MEMBERSHIP_CONFLICT" => EnvironmentHubMembershipConflict,
480
+ "ERROR_IN_MAILER" => ErrorInMailer,
481
+ "EXCEEDED_MAX_SEMIJOIN_SUBSELECTS" => ExceededMaxSemijoinSubselects,
482
+ "FAILED_ACTIVATION" => FailedActivation,
483
+ "FIELD_CUSTOM_VALIDATION_EXCEPTION" => FieldCustomValidationException,
484
+ "FIELD_FILTER_VALIDATION_EXCEPTION" => FieldFilterValidationException,
485
+ "FIELD_INTEGRITY_EXCEPTION" => FieldIntegrityException,
486
+ "FILTERED_LOOKUP_LIMIT_EXCEEDED" => FilteredLookupLimitExceeded,
487
+ "FORBIDDEN" => Forbidden,
488
+ "HTML_FILE_UPLOAD_NOT_ALLOWED" => HtmlFileUploadNotAllowed,
489
+ "ILLEGAL_QUERY_PARAMETER_VALUE" => IllegalQueryParameterValue,
490
+ "IMAGE_TOO_LARGE" => ImageTooLarge,
491
+ "INACTIVE_OWNER_OR_USER" => InactiveOwnerOrUser,
492
+ "INSERT_UPDATE_DELETE_NOT_ALLOWED_DURING_MAINTENANCE" =>
493
+ InsertUpdateDeleteNotAllowedDuringMaintenance,
494
+ "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY" =>
495
+ InsufficientAccessOnCrossReferenceEntity,
496
+ "INSUFFICIENT_ACCESS_OR_READONLY" => InsufficientAccessOrReadonly,
497
+ "INVALID_ACCESS_LEVEL" => InvalidAccessLevel,
498
+ "INVALID_ARGUMENT_TYPE" => InvalidArgumentType,
499
+ "INVALID_ASSIGNEE_TYPE" => InvalidAssigneeType,
500
+ "INVALID_ASSIGNMENT_RULE" => InvalidAssignmentRule,
501
+ "INVALID_BATCH_OPERATION" => InvalidBatchOperation,
502
+ "INVALID_CONTENT_TYPE" => InvalidContentType,
503
+ "INVALID_CREDIT_CARD_INFO" => InvalidCreditCardInfo,
504
+ "INVALID_CROSS_REFERENCE_KEY" => InvalidCrossReferenceKey,
505
+ "INVALID_CROSS_REFERENCE_TYPE_FOR_FIELD" => InvalidCrossReferenceTypeForField,
506
+ "INVALID_CURRENCY_CONV_RATE" => InvalidCurrencyConvRate,
507
+ "INVALID_CURRENCY_CORP_RATE" => InvalidCurrencyCorpRate,
508
+ "INVALID_CURRENCY_ISO" => InvalidCurrencyIso,
509
+ "INVALID_EMAIL_ADDRESS" => InvalidEmailAddress,
510
+ "INVALID_EMPTY_KEY_OWNER" => InvalidEmptyKeyOwner,
511
+ "INVALID_EVENT_SUBSCRIPTION" => InvalidEventSubscription,
512
+ "INVALID_FIELD" => InvalidField,
513
+ "INVALID_FIELD_FOR_INSERT_UPDATE" => InvalidFieldForInsertUpdate,
514
+ "INVALID_FIELD_WHEN_USING_TEMPLATE" => InvalidFieldWhenUsingTemplate,
515
+ "INVALID_FILTER_ACTION" => InvalidFilterAction,
516
+ "INVALID_ID_FIELD" => InvalidIdField,
517
+ "INVALID_INET_ADDRESS" => InvalidInetAddress,
518
+ "INVALID_LINEITEM_CLONE_STATE" => InvalidLineitemCloneState,
519
+ "INVALID_MASTER_OR_TRANSLATED_SOLUTION" => InvalidMasterOrTranslatedSolution,
520
+ "INVALID_MESSAGE_ID_REFERENCE" => InvalidMessageIdReference,
521
+ "INVALID_OPERATION" => InvalidOperation,
522
+ "INVALID_OPERATION_WITH_EXPIRED_PASSWORD" => InvalidOperationWithExpiredPassword,
523
+ "INVALID_OPERATOR" => InvalidOperator,
524
+ "INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST" =>
525
+ InvalidOrNullForRestrictedPicklist,
526
+ "INVALID_QUERY_FILTER_OPERATOR" => InvalidQueryFilterOperator,
527
+ "INVALID_QUERY_LOCATOR" => InvalidQueryLocator,
528
+ "INVALID_PARTNER_NETWORK_STATUS" => InvalidPartnerNetworkStatus,
529
+ "INVALID_PERSON_ACCOUNT_OPERATION" => InvalidPersonAccountOperation,
530
+ "INVALID_READ_ONLY_USER_DML" => InvalidReadOnlyUserDml,
531
+ "INVALID_REPLICATION_DATE" => InvalidReplicationDate,
532
+ "INVALID_SAVE_AS_ACTIVITY_FLAG" => InvalidSaveAsActivityFlag,
533
+ "INVALID_SESSION_ID" => InvalidSessionId,
534
+ "INVALID_STATUS" => InvalidStatus,
535
+ "INVALID_TYPE" => InvalidType,
536
+ "INVALID_TYPE_FOR_OPERATION" => InvalidTypeForOperation,
537
+ "INVALID_TYPE_ON_FIELD_IN_RECORD" => InvalidTypeOnFieldInRecord,
538
+ "IP_RANGE_LIMIT_EXCEEDED" => IpRangeLimitExceeded,
539
+ "JIGSAW_IMPORT_LIMIT_EXCEEDED" => JigsawImportLimitExceeded,
540
+ "JSON_PARSER_ERROR" => JsonParserError,
541
+ "LICENSE_LIMIT_EXCEEDED" => LicenseLimitExceeded,
542
+ "LIGHT_PORTAL_USER_EXCEPTION" => LightPortalUserException,
543
+ "LIMIT_EXCEEDED" => LimitExceeded,
544
+ "LOGIN_CHALLENGE_ISSUED" => LoginChallengeIssued,
545
+ "LOGIN_CHALLENGE_PENDING" => LoginChallengePending,
546
+ "LOGIN_MUST_USE_SECURITY_TOKEN" => LoginMustUseSecurityToken,
547
+ "MALFORMED_ID" => MalformedId,
548
+ "MALFORMED_QUERY" => MalformedQuery,
549
+ "MANAGER_NOT_DEFINED" => ManagerNotDefined,
550
+ "MASSMAIL_RETRY_LIMIT_EXCEEDED" => MassmailRetryLimitExceeded,
551
+ "MASS_MAIL_LIMIT_EXCEEDED" => MassMailLimitExceeded,
552
+ "MAXIMUM_CCEMAILS_EXCEEDED" => MaximumCcemailsExceeded,
553
+ "MAXIMUM_DASHBOARD_COMPONENTS_EXCEEDED" => MaximumDashboardComponentsExceeded,
554
+ "MAXIMUM_HIERARCHY_LEVELS_REACHED" => MaximumHierarchyLevelsReached,
555
+ "MAXIMUM_SIZE_OF_ATTACHMENT" => MaximumSizeOfAttachment,
556
+ "MAXIMUM_SIZE_OF_DOCUMENT" => MaximumSizeOfDocument,
557
+ "MAX_ACTIONS_PER_RULE_EXCEEDED" => MaxActionsPerRuleExceeded,
558
+ "MAX_ACTIVE_RULES_EXCEEDED" => MaxActiveRulesExceeded,
559
+ "MAX_APPROVAL_STEPS_EXCEEDED" => MaxApprovalStepsExceeded,
560
+ "MAX_FORMULAS_PER_RULE_EXCEEDED" => MaxFormulasPerRuleExceeded,
561
+ "MAX_RULES_EXCEEDED" => MaxRulesExceeded,
562
+ "MAX_RULE_ENTRIES_EXCEEDED" => MaxRuleEntriesExceeded,
563
+ "MAX_TASK_DESCRIPTION_EXCEEDED" => MaxTaskDescriptionExceeded,
564
+ "MAX_TM_RULES_EXCEEDED" => MaxTmRulesExceeded,
565
+ "MAX_TM_RULE_ITEMS_EXCEEDED" => MaxTmRuleItemsExceeded,
566
+ "MERGE_FAILED" => MergeFailed,
567
+ "METHOD_NOT_ALLOWED" => MethodNotAllowed,
568
+ "MISSING_ARGUMENT" => MissingArgument,
569
+ "NONUNIQUE_SHIPPING_ADDRESS" => NonuniqueShippingAddress,
570
+ "NO_APPLICABLE_PROCESS" => NoApplicableProcess,
571
+ "NO_ATTACHMENT_PERMISSION" => NoAttachmentPermission,
572
+ "NO_INACTIVE_DIVISION_MEMBERS" => NoInactiveDivisionMembers,
573
+ "NO_MASS_MAIL_PERMISSION" => NoMassMailPermission,
574
+ "NUMBER_OUTSIDE_VALID_RANGE" => NumberOutsideValidRange,
575
+ "NUM_HISTORY_FIELDS_BY_SOBJECT_EXCEEDED" => NumHistoryFieldsBySobjectExceeded,
576
+ "OP_WITH_INVALID_USER_TYPE_EXCEPTION" => OpWithInvalidUserTypeException,
577
+ "OPTED_OUT_OF_MASS_MAIL" => OptedOutOfMassMail,
578
+ "PACKAGE_LICENSE_REQUIRED" => PackageLicenseRequired,
579
+ "PLATFORM_EVENT_ENCRYPTION_ERROR" => PlatformEventEncryptionError,
580
+ "PLATFORM_EVENT_PUBLISHING_UNAVAILABLE" => PlatformEventPublishingUnavailable,
581
+ "PLATFORM_EVENT_PUBLISH_FAILED" => PlatformEventPublishFailed,
582
+ "PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT" => PortalUserAlreadyExistsForContact,
583
+ "PRIVATE_CONTACT_ON_ASSET" => PrivateContactOnAsset,
584
+ "QUERY_TIMEOUT" => QueryTimeout,
585
+ "RECORD_IN_USE_BY_WORKFLOW" => RecordInUseByWorkflow,
586
+ "REQUEST_LIMIT_EXCEEDED" => RequestLimitExceeded,
587
+ "REQUEST_RUNNING_TOO_LONG" => RequestRunningTooLong,
588
+ "REQUIRED_FIELD_MISSING" => RequiredFieldMissing,
589
+ "SELF_REFERENCE_FROM_TRIGGER" => SelfReferenceFromTrigger,
590
+ "SERVER_UNAVAILABLE" => ServerUnavailable,
591
+ "SHARE_NEEDED_FOR_CHILD_OWNER" => ShareNeededForChildOwner,
592
+ "SINGLE_EMAIL_LIMIT_EXCEEDED" => SingleEmailLimitExceeded,
593
+ "STANDARD_PRICE_NOT_DEFINED" => StandardPriceNotDefined,
594
+ "STORAGE_LIMIT_EXCEEDED" => StorageLimitExceeded,
595
+ "STRING_TOO_LONG" => StringTooLong,
596
+ "TABSET_LIMIT_EXCEEDED" => TabsetLimitExceeded,
597
+ "TEMPLATE_NOT_ACTIVE" => TemplateNotActive,
598
+ "TERRITORY_REALIGN_IN_PROGRESS" => TerritoryRealignInProgress,
599
+ "TEXT_DATA_OUTSIDE_SUPPORTED_CHARSET" => TextDataOutsideSupportedCharset,
600
+ "TOO_MANY_APEX_REQUESTS" => TooManyApexRequests,
601
+ "TOO_MANY_ENUM_VALUE" => TooManyEnumValue,
602
+ "TRANSFER_REQUIRES_READ" => TransferRequiresRead,
603
+ "UNABLE_TO_LOCK_ROW" => UnableToLockRow,
604
+ "UNAVAILABLE_RECORDTYPE_EXCEPTION" => UnavailableRecordtypeException,
605
+ "UNDELETE_FAILED" => UndeleteFailed,
606
+ "UNKNOWN_EXCEPTION" => UnknownException,
607
+ "UNSPECIFIED_EMAIL_ADDRESS" => UnspecifiedEmailAddress,
608
+ "UNSUPPORTED_APEX_TRIGGER_OPERATION" => UnsupportedApexTriggerOperation,
609
+ "UNVERIFIED_SENDER_ADDRESS" => UnverifiedSenderAddress,
610
+ "WEBLINK_SIZE_LIMIT_EXCEEDED" => WeblinkSizeLimitExceeded,
611
+ "WEBLINK_URL_INVALID" => WeblinkUrlInvalid,
612
+ "WRONG_CONTROLLER_TYPE" => WrongControllerType
613
+ }.freeze
614
+
615
+ def self.get_exception_class(error_code)
616
+ ERROR_EXCEPTION_CLASSES.fetch(error_code) do |_|
617
+ warn "[restforce] An unrecognised error code, `#{error_code}` has been " \
618
+ "received from Salesforce. Instead of raising an error-specific exception" \
619
+ ", we'll raise a generic `ResponseError`. Please report this missing " \
620
+ "error code on GitHub at <#{GITHUB_ISSUE_URL}>."
621
+
622
+ # If we've received an unexpected error where we don't have a specific
623
+ # class defined, we can return a generic ResponseError instead
624
+ ResponseError
625
+ end
626
+ end
627
+
628
+ def self.const_missing(constant_name)
629
+ warn "[restforce] You're referring to a Restforce error that isn't defined, " \
630
+ "`#{name}::#{constant_name}` (for example by trying to `rescue` it). This " \
631
+ "might be our fault - we've recently made some changes to how errors are " \
632
+ "defined. If you're sure that this is a valid Salesforce error, then " \
633
+ "please create an issue on GitHub at <#{GITHUB_ISSUE_URL}>."
634
+
635
+ super(constant_name)
636
+ end
637
+ end
638
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'faraday/file_part'
5
+ rescue LoadError
6
+ require 'faraday/upload_io'
7
+ end
8
+
9
+ module Restforce
10
+ if defined?(::Faraday::FilePart)
11
+ FilePart = Faraday::FilePart
12
+
13
+ # Deprecated
14
+ UploadIO = Faraday::FilePart
15
+ else
16
+ # Handle pre-1.0 versions of faraday
17
+ FilePart = Faraday::UploadIO
18
+ UploadIO = Faraday::UploadIO
19
+ end
20
+ end
21
+
22
+ # This patch is only needed with multipart-post < 2.0.0
23
+ # 2.0.0 was released in 2013.
24
+ require 'restforce/patches/parts' unless Parts::Part.method(:new).arity.abs == 4