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:) ⇒ ValidateAddress

Returns a new instance of ValidateAddress.



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

def initialize(address_match_gateway:)
  @address_match_gateway = address_match_gateway
end

Instance Method Details

#execute(postcode:, country:) ⇒ Object



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

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