Restructure omni services and add Chatwoot research snapshot
This commit is contained in:
45
research/chatwoot/lib/custom_exceptions/account.rb
Normal file
45
research/chatwoot/lib/custom_exceptions/account.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module CustomExceptions::Account
|
||||
class InvalidEmail < CustomExceptions::Base
|
||||
def message
|
||||
if @data[:domain_blocked]
|
||||
I18n.t 'errors.signup.blocked_domain'
|
||||
elsif @data[:disposable]
|
||||
I18n.t 'errors.signup.disposable_email'
|
||||
elsif !@data[:valid]
|
||||
I18n.t 'errors.signup.invalid_email'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class UserExists < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t('errors.signup.email_already_exists', email: @data[:email])
|
||||
end
|
||||
end
|
||||
|
||||
class InvalidParams < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t 'errors.signup.invalid_params'
|
||||
end
|
||||
end
|
||||
|
||||
class UserErrors < CustomExceptions::Base
|
||||
def message
|
||||
@data[:errors].full_messages.join(',')
|
||||
end
|
||||
end
|
||||
|
||||
class SignupFailed < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t 'errors.signup.failed'
|
||||
end
|
||||
end
|
||||
|
||||
class PlanUpgradeRequired < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t 'errors.plan_upgrade_required.failed'
|
||||
end
|
||||
end
|
||||
end
|
||||
18
research/chatwoot/lib/custom_exceptions/base.rb
Normal file
18
research/chatwoot/lib/custom_exceptions/base.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CustomExceptions::Base < StandardError
|
||||
def to_hash
|
||||
{
|
||||
message: message
|
||||
}
|
||||
end
|
||||
|
||||
def http_status
|
||||
403
|
||||
end
|
||||
|
||||
def initialize(data)
|
||||
@data = data
|
||||
super()
|
||||
end
|
||||
end
|
||||
25
research/chatwoot/lib/custom_exceptions/custom_filter.rb
Normal file
25
research/chatwoot/lib/custom_exceptions/custom_filter.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
module CustomExceptions::CustomFilter
|
||||
class InvalidAttribute < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t('errors.custom_filters.invalid_attribute', key: @data[:key], allowed_keys: @data[:allowed_keys].join(','))
|
||||
end
|
||||
end
|
||||
|
||||
class InvalidOperator < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t('errors.custom_filters.invalid_operator', attribute_name: @data[:attribute_name], allowed_keys: @data[:allowed_keys].join(','))
|
||||
end
|
||||
end
|
||||
|
||||
class InvalidQueryOperator < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t('errors.custom_filters.invalid_query_operator')
|
||||
end
|
||||
end
|
||||
|
||||
class InvalidValue < CustomExceptions::Base
|
||||
def message
|
||||
I18n.t('errors.custom_filters.invalid_value', attribute_name: @data[:attribute_name])
|
||||
end
|
||||
end
|
||||
end
|
||||
19
research/chatwoot/lib/custom_exceptions/pdf.rb
Normal file
19
research/chatwoot/lib/custom_exceptions/pdf.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module CustomExceptions::Pdf
|
||||
class UploadError < CustomExceptions::Base
|
||||
def initialize(message = 'PDF upload failed')
|
||||
super(message)
|
||||
end
|
||||
end
|
||||
|
||||
class ValidationError < CustomExceptions::Base
|
||||
def initialize(message = 'PDF validation failed')
|
||||
super(message)
|
||||
end
|
||||
end
|
||||
|
||||
class FaqGenerationError < CustomExceptions::Base
|
||||
def initialize(message = 'PDF FAQ generation failed')
|
||||
super(message)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user