glia-errors 0.10.1 → 0.11.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 110bf7c1b2d1b5855f92c842563f59fe6b93157b5bee67af2e446b212dc2b108
4
- data.tar.gz: e99a9338aa7995f17865a25ac6dc4c60fbfc0aa883d507add47043b0ec9f448a
3
+ metadata.gz: 18b0771e4477d3bad79df4926e73e03178e12838a40d254ac24738ca208147d0
4
+ data.tar.gz: 8497c21a809704770feb7ee1c1bf687269a699b9419a49879a2abdab5fcf1396
5
5
  SHA512:
6
- metadata.gz: 74b6285d294a404baa2d59e3406d1f021c2319aab4bb73f7f4cda571dce46eb55250347bfd8c66dddab43404357c5e6a6c996a1bc936857498f3b148e50c185a
7
- data.tar.gz: 96ef53cbee527e3e64606223c81a0335954a40187bd830231fc0d07160ce82554894c2be1d38e51cc2f271c661affd301b0640ac4b3339045574c4c944d02170
6
+ metadata.gz: a1ba73e500036b0b18f240841d3c7fe33267e259954c0b12a61c08d3d511a770e3afa1b0644d972e302b1834a91f98654b3cdf178af11b474df564134de66114
7
+ data.tar.gz: 88f2d9b04a99d2d48e2faca49cdb830e75704133d1165c696534fe919713833e41577c7945e22d169fb3711b0bfdbffe4b5af725793fab0de34f77dd526a1bda
data/Appraisals CHANGED
@@ -5,5 +5,5 @@ appraise 'dry_validation_v0' do
5
5
  end
6
6
 
7
7
  appraise 'dry_validation_v1' do
8
- gem 'dry-validation', '~> 1.6'
8
+ gem 'dry-validation', '~> 1.6.0'
9
9
  end
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ task :install_test_deps do
25
25
  sh 'bundle exec appraisal install'
26
26
  end
27
27
 
28
- task test: %i[test_dry_validation_v1 test_dry_validation_v0]
28
+ task test: %i[test_dry_validation_v1]
29
29
 
30
30
  task test_dry_validation_v1: :install_test_deps do
31
31
  sh 'bundle exec appraisal dry_validation_v1 rspec'
@@ -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.6.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.10.1'
8
+ spec.version = '0.11.6'
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
@@ -12,7 +12,7 @@ module Glia
12
12
  def self.from_dry_validation_result(result, custom_error_map = {})
13
13
  dry_validation_version = Gem.loaded_specs['dry-validation'].version
14
14
  if dry_validation_version < Gem::Version.new('1.0')
15
- Mapper.from_dry_validation_result(result.output, result.messages, custom_error_map)
15
+ Mapper.from_dry_validation_result(result.output, result.errors, custom_error_map)
16
16
  elsif dry_validation_version <= Gem::Version.new('1.6')
17
17
  Mapper.from_dry_validation_result(result.to_h, result.errors.to_h, custom_error_map)
18
18
  else
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.10.1
4
+ version: 0.11.6
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-03-31 00:00:00.000000000 Z
11
+ date: 2022-01-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: