Sha256: a32fedb4dfde5ccc52549c72fe9343baab50e763dfb194d13f809b397fd1e308
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require_relative '../request' require_relative 'us_reverse_geo_response' module SmartyStreets module USReverseGeo # It is recommended to instantiate this class using ClientBuilder.build_us_reverse_geo_api_client() class Client def initialize(sender, serializer) @sender = sender @serializer = serializer end # Sends a Lookup object to the US Reverse Geo API and stores the result in the Lookup's response field. def send(lookup) request = build_request(lookup) response = @sender.send(request) raise response.error if response.error lookup.response = Response.new(@serializer.deserialize(response.payload)) end def build_request(lookup) request = SmartyStreets::Request.new add_parameter(request, 'latitude', lookup.latitude) add_parameter(request, 'longitude', lookup.longitude) add_parameter(request, 'source', lookup.source) for key in lookup.custom_param_hash.keys do add_parameter(request, key, lookup.custom_param_hash[key]) end request end def add_parameter(request, key, value) request.parameters[key] = value unless value.nil? or value.empty? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smartystreets_ruby_sdk-5.20.6 | lib/smartystreets_ruby_sdk/us_reverse_geo/client.rb |