Class: PostcodeValidation::UseCase::ValidateAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/postcode_validation/use_case/validate_address.rb

Instance Method Summary collapse

Constructor Details

#initialize(address_match_gateway:, logger: nil) ⇒ ValidateAddress

Returns a new instance of ValidateAddress.



4
5
6
7
# File 'lib/postcode_validation/use_case/validate_address.rb', line 4

def initialize(address_match_gateway:, logger: nil)
  @address_match_gateway = address_match_gateway
  @logger = logger
end

Instance Method Details

#execute(postcode:, country:) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/postcode_validation/use_case/validate_address.rb', line 9

def execute(postcode:, country:)
  @postcode = postcode
  @country = country
  { valid?: valid_postcode? }
rescue PostcodeValidation::Error::RequestError => e
  on_error(e)
  { valid?: true }
end