class FCP::DataApi
Attributes
Public Class Methods
# File lib/first-class-postcodes/api/data_api.rb, line 7 def initialize(api_client = ApiClient.default) @api_client = api_client end
Public Instance Methods
Geo Lookup Takes a valid latitude, longitude and radius (in km) and returns all matching postcodes within that area. This operation does not return full addresses (which must be queried for separately). @param latitude [Float] The latitude for the query @param longitude [Float] The latitude for the query @param [Hash] opts the optional parameters @option opts [Float] :radius The radius, in kilometers. (default to 1.0) @return [Array<Point>]
# File lib/first-class-postcodes/api/data_api.rb, line 17 def get_lookup(latitude, longitude, opts = {}) data, _status_code, _headers = get_lookup_with_http_info(latitude, longitude, opts) data end
Geo Lookup Takes a valid latitude, longitude and radius (in km) and returns all matching postcodes within that area. This operation does not return full addresses (which must be queried for separately). @param latitude [Float] The latitude for the query @param longitude [Float] The latitude for the query @param [Hash] opts the optional parameters @option opts [Float] :radius The radius, in kilometers. @return [Array<(Array<Point>, Integer, Hash)>] Array<Point> data, response status code and response headers
# File lib/first-class-postcodes/api/data_api.rb, line 29 def get_lookup_with_http_info(latitude, longitude, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DataApi.get_lookup ...' end # verify the required parameter 'latitude' is set if @api_client.config.client_side_validation && latitude.nil? fail ArgumentError, "Missing the required parameter 'latitude' when calling DataApi.get_lookup" end # verify the required parameter 'longitude' is set if @api_client.config.client_side_validation && longitude.nil? fail ArgumentError, "Missing the required parameter 'longitude' when calling DataApi.get_lookup" end if @api_client.config.client_side_validation && !opts[:'radius'].nil? && opts[:'radius'] > 5 fail ArgumentError, 'invalid value for "opts[:"radius"]" when calling DataApi.get_lookup, must be smaller than or equal to 5.' end if @api_client.config.client_side_validation && !opts[:'radius'].nil? && opts[:'radius'] < 0 fail ArgumentError, 'invalid value for "opts[:"radius"]" when calling DataApi.get_lookup, must be greater than or equal to 0.' end # resource path local_var_path = '/lookup' # query parameters query_params = opts[:query_params] || {} query_params[:'latitude'] = latitude query_params[:'longitude'] = longitude query_params[:'radius'] = opts[:'radius'] if !opts[:'radius'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'Array<Point>' # auth_names auth_names = opts[:auth_names] || ['Authorizer'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DataApi#get_lookup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Postcode Lookup Retrieves street numbers, address and location information for a specific postcode provided in the search query parameter. @param search [String] The postcode to retrieve address information for. @param [Hash] opts the optional parameters @return [Address]
# File lib/first-class-postcodes/api/data_api.rb, line 96 def get_postcode(search, opts = {}) data, _status_code, _headers = get_postcode_with_http_info(search, opts) data end
Postcode Lookup Retrieves street numbers, address and location information for a specific postcode provided in the search query parameter. @param search [String] The postcode to retrieve address information for. @param [Hash] opts the optional parameters @return [Array<(Address
, Integer, Hash)>] Address
data, response status code and response headers
# File lib/first-class-postcodes/api/data_api.rb, line 106 def get_postcode_with_http_info(search, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DataApi.get_postcode ...' end # verify the required parameter 'search' is set if @api_client.config.client_side_validation && search.nil? fail ArgumentError, "Missing the required parameter 'search' when calling DataApi.get_postcode" end # resource path local_var_path = '/postcode' # query parameters query_params = opts[:query_params] || {} query_params[:'search'] = search # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'Address' # auth_names auth_names = opts[:auth_names] || ['Authorizer'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DataApi#get_postcode\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Typeahead
Search Performs a typeahead search for an address, allowing the user to enter their address naturally.
@param search [String] The typeahead search query to return matching results for. @param [Hash] opts the optional parameters @return [Array<Typeahead>]
# File lib/first-class-postcodes/api/data_api.rb, line 159 def get_typeahead(search, opts = {}) data, _status_code, _headers = get_typeahead_with_http_info(search, opts) data end
Typeahead
Search Performs a typeahead search for an address, allowing the user to enter their address naturally.
@param search [String] The typeahead search query to return matching results for. @param [Hash] opts the optional parameters @return [Array<(Array<Typeahead>, Integer, Hash)>] Array<Typeahead> data, response status code and response headers
# File lib/first-class-postcodes/api/data_api.rb, line 169 def get_typeahead_with_http_info(search, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DataApi.get_typeahead ...' end # verify the required parameter 'search' is set if @api_client.config.client_side_validation && search.nil? fail ArgumentError, "Missing the required parameter 'search' when calling DataApi.get_typeahead" end # resource path local_var_path = '/typeahead' # query parameters query_params = opts[:query_params] || {} query_params[:'search'] = search # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'Array<Typeahead>' # auth_names auth_names = opts[:auth_names] || ['Authorizer'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DataApi#get_typeahead\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end