glia-errors 0.11.0 → 0.11.7

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
  SHA256:
3
- metadata.gz: f3f1709fffc93f8968a42d643b4efc6fd300ab47de475c21f5632b804085d07d
4
- data.tar.gz: 1b93f359b7083f4a5c9a8776c89d4f7bb4bcac2f419ebec7abb4ef025d0e3573
3
+ metadata.gz: d71a904099bb9ddc69b22b6f8781ec5f73d30f15db34a117f92b0dde9700b2e3
4
+ data.tar.gz: 58dab077b61ebf6143d38afdcc3a8468a3ccdfe57586a099bf26633482d93526
5
5
  SHA512:
6
- metadata.gz: 3bddb2518cbaf055d1ad9dc75f44f7d4eab2ef6a43506af2c24d2a41fd239bf1790d14069f73895aedc04e3beebe8ec83272d318d254e5c6ecfff50e429bb40d
7
- data.tar.gz: c2b84141ccabb62b3da2a1875f83d679a60ee39d420bd77b222c508bd5f07234e31e2224855d3f2fdf9bb0535b173df58f19540cd63f37ba8f7e9e274c3547b1
6
+ metadata.gz: 5a8c8fc492018dbc59f262b3068c7e81b42a88b477e67698f52c8b70e35543ca73fa4281d721cecabaeda2084f7749157a33ce3e24ce97d28fa887dc0c210779
7
+ data.tar.gz: 72ce9907b06c59e05d5920a18bf00920dfca7ef49145509f949adf3bed8190a303896e7901b31dca542d64bd36efeefd041dcc8c00bb86a5cf1bc5ed91e3cbf9
data/Appraisals CHANGED
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  appraise 'dry_validation_v0' do
4
+ gem 'dry-core', '~> 0.5.0'
4
5
  gem 'dry-validation', '~> 0.13.0'
5
6
  end
6
7
 
7
8
  appraise 'dry_validation_v1' do
8
- gem 'dry-validation', '~> 1.6'
9
+ gem 'dry-validation', '~> 1.7.0'
9
10
  end
data/README.md CHANGED
@@ -33,7 +33,7 @@ glia_error = Glia::Errors::ResourceNotFoundError.new(resource: :engagement)
33
33
 
34
34
  Currently 2 `dry-validation` versions are supported:
35
35
  * `v0` up to `0.13`
36
- * `v1` up to `1.6`
36
+ * `v1` up to `1.7`
37
37
 
38
38
  ```ruby
39
39
  schema = Dry::Validation.Schema do
@@ -9,6 +9,7 @@ gem "rubocop", "~> 1.5"
9
9
  gem "rubocop-rake", "~> 0.5"
10
10
  gem "rubocop-rspec", "~> 2.0"
11
11
  gem "super_diff"
12
+ gem "dry-core", "~> 0.5.0"
12
13
  gem "dry-validation", "~> 0.13.0"
13
14
 
14
15
  group :test do
@@ -9,7 +9,7 @@ gem "rubocop", "~> 1.5"
9
9
  gem "rubocop-rake", "~> 0.5"
10
10
  gem "rubocop-rspec", "~> 2.0"
11
11
  gem "super_diff"
12
- gem "dry-validation", "~> 1.6"
12
+ gem "dry-validation", "~> 1.7.0"
13
13
 
14
14
  group :test do
15
15
  gem "appraisal"
data/glia-errors.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'glia-errors'
8
- spec.version = '0.11.0'
8
+ spec.version = '0.11.7'
9
9
  spec.authors = ['Glia TechMovers']
10
10
  spec.email = ['techmovers@glia.com']
11
11
 
@@ -56,6 +56,7 @@ module Glia
56
56
  DATE = 'date'
57
57
  TIME = 'time'
58
58
  UUID = 'uuid'
59
+ URL = 'url'
59
60
  end
60
61
 
61
62
  def initialize(field:, format: nil, message: nil)
@@ -84,6 +85,8 @@ module Glia
84
85
  'ISO-8601 date and time'
85
86
  when Formats::UUID
86
87
  'UUID'
88
+ when Formats::URL
89
+ 'URL'
87
90
  else
88
91
  raise 'Unexpected InvalidFormatError format'
89
92
  end
@@ -184,14 +187,27 @@ module Glia
184
187
  Naming.assert_snake_case(resource)
185
188
 
186
189
  super(
187
- type: LIMIT_EXCEEDED_ERROR,
188
- ref: create_ref(LIMIT_EXCEEDED_ERROR),
190
+ type: RESOURCE_LIMIT_EXCEEDED_ERROR,
191
+ ref: create_ref(RESOURCE_LIMIT_EXCEEDED_ERROR),
189
192
  message: message || "#{Naming.humanize(resource)} count must not exceed #{max}",
190
193
  error_details: { resource: resource, max: max }
191
194
  )
192
195
  end
193
196
  end
194
197
 
198
+ class ResourceMinimumNotReachedError < Error
199
+ def initialize(resource:, min:, message: nil)
200
+ Naming.assert_snake_case(resource)
201
+
202
+ super(
203
+ type: RESOURCE_MINIMUM_NOT_REACHED,
204
+ ref: create_ref(RESOURCE_MINIMUM_NOT_REACHED),
205
+ message: message || "#{Naming.humanize(resource)} count must reach at least #{min}",
206
+ error_details: { resource: resource, min: min }
207
+ )
208
+ end
209
+ end
210
+
195
211
  class ResourceAlreadyExistsError < Error
196
212
  def initialize(resource:, message: nil)
197
213
  Naming.assert_snake_case(resource)
@@ -347,6 +363,57 @@ module Glia
347
363
  )
348
364
  end
349
365
  end
366
+
367
+ class FacebookAccessTokenPermissionsError < Error
368
+ def initialize(message: nil)
369
+ super(
370
+ type: FACEBOOK_ACCESS_TOKEN_PERMISSIONS_ERROR,
371
+ ref: create_ref(FACEBOOK_ACCESS_TOKEN_PERMISSIONS_ERROR),
372
+ message: message || 'Access token does not have sufficient permissions'
373
+ )
374
+ end
375
+ end
376
+
377
+ class FacebookAccessTokenNotPermanentError < Error
378
+ def initialize(message: nil)
379
+ super(
380
+ type: FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR,
381
+ ref: create_ref(FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR),
382
+ message: message || 'Access token does not yield permanent access tokens'
383
+ )
384
+ end
385
+ end
386
+
387
+ class OAuthCodeExpiredError < Error
388
+ def initialize(message: nil)
389
+ super(
390
+ type: OAUTH_CODE_EXPIRED_ERROR,
391
+ ref: create_ref(OAUTH_CODE_EXPIRED_ERROR),
392
+ message: message || 'OAuth code has expired'
393
+ )
394
+ end
395
+ end
396
+
397
+ class OAuthCodeAlreadyUsedError < Error
398
+ def initialize(message: nil)
399
+ super(
400
+ type: OAUTH_CODE_ALREADY_USED_ERROR,
401
+ ref: create_ref(OAUTH_CODE_ALREADY_USED_ERROR),
402
+ message: message || 'OAuth code has already been used'
403
+ )
404
+ end
405
+ end
406
+
407
+ class AppleBusinessChatBusinessUsedByOtherSiteError < Error
408
+ def initialize(message: nil)
409
+ super(
410
+ type: APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR,
411
+ ref: create_ref(APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR),
412
+ message: message || 'Business is already used by a channel on another site'
413
+ )
414
+ end
415
+ end
416
+
350
417
  # rubocop:enable Style/Documentation
351
418
  end
352
419
  end
@@ -14,7 +14,8 @@ module Glia
14
14
  RESOURCE_NOT_FOUND_ERROR = 'resource_not_found_error'
15
15
  NOT_VERIFIED_ERROR = 'not_verified_error'
16
16
  REMAINING_ASSOCIATION_ERROR = 'remaining_association_error'
17
- LIMIT_EXCEEDED_ERROR = 'limit_exceeded_error'
17
+ RESOURCE_LIMIT_EXCEEDED_ERROR = 'resource_limit_exceeded_error'
18
+ RESOURCE_MINIMUM_NOT_REACHED = 'resource_minimum_not_reached'
18
19
  RESOURCE_ALREADY_EXISTS_ERROR = 'resource_already_exists_error'
19
20
  INVALID_RESOURCE_STATE_ERROR = 'invalid_resource_state_error'
20
21
  AUTHORIZATION_ERROR = 'authorization_error'
@@ -29,6 +30,12 @@ module Glia
29
30
  TWILIO_MESSAGING_SERVICE_CONFIGURATION_ERROR = 'twilio_messaging_service_configuration_error'
30
31
  UNREACHABLE_DESTINATION_ERROR = 'unreachable_destination_error'
31
32
  HEADERS_VALIDATION_ERROR = 'headers_validation_error'
33
+ FACEBOOK_ACCESS_TOKEN_PERMISSIONS_ERROR = 'facebook_access_token_permissions_error'
34
+ FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR = 'facebook_access_token_not_permanent_error'
35
+ OAUTH_CODE_EXPIRED_ERROR = 'oauth_code_expired_error'
36
+ OAUTH_CODE_ALREADY_USED_ERROR = 'oauth_code_already_used_error'
37
+ APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR =
38
+ 'apple_business_chat_business_used_by_other_site_error'
32
39
 
33
40
  # Server errors
34
41
  INTERNAL_SERVER_ERROR = 'internal_server_error'
@@ -125,7 +125,8 @@ module Glia
125
125
  'is missing' => MISSING_VALUE_ERROR,
126
126
  # Custom format errors
127
127
  'must be in E.164 format' => INVALID_FORMAT_ERROR,
128
- 'must be up to 7-digit string' => INVALID_FORMAT_ERROR,
128
+ 'must be up to 25 symbol string that contains only 1-7 digits and commas' =>
129
+ INVALID_FORMAT_ERROR,
129
130
  'must be a valid email' => INVALID_FORMAT_ERROR
130
131
  }.freeze
131
132
 
@@ -13,8 +13,8 @@ module Glia
13
13
  upcase_first(result)
14
14
  end
15
15
 
16
- ABBREVIATIONS = %w[id uuid saml sip sms mms].freeze
17
- PLURAL_ABBREVIATIONS = %w[ids uuids].freeze
16
+ ABBREVIATIONS = %w[id uuid saml sip sms mms uri url].freeze
17
+ PLURAL_ABBREVIATIONS = %w[ids uuids uris urls].freeze
18
18
 
19
19
  private_class_method def self.upcase_if_abbreviation(value)
20
20
  if ABBREVIATIONS.include?(value)
data/lib/glia/errors.rb CHANGED
@@ -13,7 +13,7 @@ module Glia
13
13
  dry_validation_version = Gem.loaded_specs['dry-validation'].version
14
14
  if dry_validation_version < Gem::Version.new('1.0')
15
15
  Mapper.from_dry_validation_result(result.output, result.errors, custom_error_map)
16
- elsif dry_validation_version <= Gem::Version.new('1.6')
16
+ elsif dry_validation_version <= Gem::Version.new('1.7')
17
17
  Mapper.from_dry_validation_result(result.to_h, result.errors.to_h, custom_error_map)
18
18
  else
19
19
  raise 'Unsupported dry-validation version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glia-errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-01 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: