Class: Loqate::Address::Gateway
- Inherits:
-
Object
- Object
- Loqate::Address::Gateway
- Includes:
- Result::Mixin
- Defined in:
- lib/loqate/address/gateway.rb
Overview
Address Verification consists of two main API requests: a Find request is used to narrow down a possible list of addresses; and a Retrieve request is used to retrieve a fully formatted address.
A typical address search is made up of a series of Find requests, followed by a Retrieve based on the user selection. Choose a service below to find out how to use each request.
Constant Summary collapse
- FIND_ENDPOINT =
'/Capture/Interactive/Find/v1.00/json3.ws'.freeze
- RETRIEVE_ENDPOINT =
'/Capture/Interactive/Retrieve/v1.00/json3.ws'.freeze
Constants included from Result::Mixin
Result::Mixin::Failure, Result::Mixin::Success
Instance Method Summary collapse
-
#find(options) ⇒ Result
Find addresses and places.
-
#find!(options) ⇒ Array<Address>
Find addresses and places.
-
#initialize(client) ⇒ Gateway
constructor
Creates an address gateway.
-
#retrieve(options) ⇒ Result
Returns the full address details based on the id.
-
#retrieve!(options) ⇒ DetailedAddress
Returns the full address details based on the id.
Methods included from Result::Mixin
#Failure, #Success, #unwrap_result_or_raise
Constructor Details
#initialize(client) ⇒ Gateway
Creates an address gateway
27 28 29 30 31 |
# File 'lib/loqate/address/gateway.rb', line 27 def initialize(client) @client = client @mapper = Mappers::GenericMapper.new @error_mapper = Mappers::ErrorMapper.new end |
Instance Method Details
#find(options) ⇒ Result
Find addresses and places.
52 53 54 55 56 |
# File 'lib/loqate/address/gateway.rb', line 52 def find() response = client.get(FIND_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_addresses_from(response.items) end |
#find!(options) ⇒ Array<Address>
Find addresses and places.
100 101 102 |
# File 'lib/loqate/address/gateway.rb', line 100 def find!() unwrap_result_or_raise { find() } end |
#retrieve(options) ⇒ Result
Returns the full address details based on the id.
73 74 75 76 77 |
# File 'lib/loqate/address/gateway.rb', line 73 def retrieve() response = client.get(RETRIEVE_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_detailed_address_from(response.items.first) end |
#retrieve!(options) ⇒ DetailedAddress
Returns the full address details based on the id.
121 122 123 |
# File 'lib/loqate/address/gateway.rb', line 121 def retrieve!() unwrap_result_or_raise { retrieve() } end |