Class: AtlasEngine::Types::QueryType

Inherits:
BaseObject
  • Object
show all
Includes:
LogHelper
Defined in:
app/graphql/atlas_engine/types/query_type.rb

Instance Method Summary collapse

Methods included from LogHelper

#log_error, #log_info, #log_warn

Instance Method Details

#validation(address:, locale: "en", matching_strategy: nil, message_format: nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/graphql/atlas_engine/types/query_type.rb', line 16

def validation(address:, locale: "en", matching_strategy: nil, message_format: nil)
  raise build_graphql_error(AtlasEngine::AddressValidation::Errors::MISSING_PARAMETER) if address.blank?

  locale = LocaleFormatHelper.format_locale(locale)

  country_code = address.country_code
  tags = ["country:#{country_code}", "matching_strategy:#{matching_strategy}"]
  measure("validation", tags) do
    I18n.with_locale(locale) do
      Services::Validation.validate_address(
        AtlasEngine::AddressValidation::Request.new(
          address: address,
          locale: locale,
          matching_strategy: matching_strategy,
          message_format: message_format,
        ),
      )
    end
  end
end