Class: FCP::DataApi

Inherits:
Object
  • Object
show all
Defined in:
lib/first-class-postcodes/api/data_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DataApi

Returns a new instance of DataApi.



7
8
9
# File 'lib/first-class-postcodes/api/data_api.rb', line 7

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



5
6
7
# File 'lib/first-class-postcodes/api/data_api.rb', line 5

def api_client
  @api_client
end

Instance Method Details

#get_lookup(latitude, longitude, opts = {}) ⇒ Array<Point>

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).

Parameters:

  • latitude (Float)

    The latitude for the query

  • longitude (Float)

    The latitude for the query

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :radius (Float)

    The radius, in kilometers. (default to 1.0)

Returns:



17
18
19
20
# 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

#get_lookup_with_http_info(latitude, longitude, opts = {}) ⇒ Array<(Array<Point>, Integer, Hash)>

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).

Parameters:

  • latitude (Float)

    The latitude for the query

  • longitude (Float)

    The latitude for the query

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :radius (Float)

    The radius, in kilometers.

Returns:

  • (Array<(Array<Point>, Integer, Hash)>)

    Array<Point> data, response status code and response headers



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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

#get_postcode(search, opts = {}) ⇒ Address

Postcode Lookup Retrieves street numbers, address and location information for a specific postcode provided in the search query parameter.

Parameters:

  • search (String)

    The postcode to retrieve address information for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



96
97
98
99
# 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

#get_postcode_with_http_info(search, opts = {}) ⇒ Array<(Address, Integer, Hash)>

Postcode Lookup Retrieves street numbers, address and location information for a specific postcode provided in the search query parameter.

Parameters:

  • search (String)

    The postcode to retrieve address information for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Address, Integer, Hash)>)

    Address data, response status code and response headers



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# 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

#get_typeahead(search, opts = {}) ⇒ Array<Typeahead>

Typeahead Search Performs a typeahead search for an address, allowing the user to enter their address naturally.

Parameters:

  • search (String)

    The typeahead search query to return matching results for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



159
160
161
162
# 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

#get_typeahead_with_http_info(search, opts = {}) ⇒ Array<(Array<Typeahead>, Integer, Hash)>

Typeahead Search Performs a typeahead search for an address, allowing the user to enter their address naturally.

Parameters:

  • search (String)

    The typeahead search query to return matching results for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Array<Typeahead>, Integer, Hash)>)

    Array<Typeahead> data, response status code and response headers



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# 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