Class: ApiGeoClient::CommunesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/api_geo_client/api/communes_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CommunesApi

Returns a new instance of CommunesApi.



19
20
21
# File 'lib/api_geo_client/api/communes_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/api_geo_client/api/communes_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#communes_code_get(code, opts = {}) ⇒ Commune

Récupérer les informations concernant une commune

Parameters:

  • code

    Code INSEE de la commune

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

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    Liste des champs souhaités dans la réponse (default to [“nom”,“code”,“codesPostaux”,“codeDepartement”,“codeRegion”,“population”])

  • :format (String)

    Format de réponse attendu (default to json)

  • :geometry (String)

    Géométrie à utiliser pour la sortie géographique (default to centre)

Returns:



29
30
31
32
# File 'lib/api_geo_client/api/communes_api.rb', line 29

def communes_code_get(code, opts = {})
  data, _status_code, _headers = communes_code_get_with_http_info(code, opts)
  data
end

#communes_code_get_with_http_info(code, opts = {}) ⇒ Array<(Commune, Fixnum, Hash)>

Récupérer les informations concernant une commune

Parameters:

  • code

    Code INSEE de la commune

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

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    Liste des champs souhaités dans la réponse

  • :format (String)

    Format de réponse attendu

  • :geometry (String)

    Géométrie à utiliser pour la sortie géographique

Returns:

  • (Array<(Commune, Fixnum, Hash)>)

    Commune data, response status code and response headers



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/api_geo_client/api/communes_api.rb', line 41

def communes_code_get_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CommunesApi.communes_code_get ...'
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CommunesApi.communes_code_get"
  end
  if @api_client.config.client_side_validation && opts[:'fields'] && !opts[:'fields'].all? { |item| ['nom', 'code', 'codesPostaux', 'centre', 'surface', 'contour', 'codeDepartement', 'departement', 'codeRegion', 'region', 'population'].include?(item) }
    fail ArgumentError, 'invalid value for "fields", must include one of nom, code, codesPostaux, centre, surface, contour, codeDepartement, departement, codeRegion, region, population'
  end
  if @api_client.config.client_side_validation && opts[:'format'] && !['json', 'geojson'].include?(opts[:'format'])
    fail ArgumentError, 'invalid value for "format", must be one of json, geojson'
  end
  if @api_client.config.client_side_validation && opts[:'geometry'] && !['centre', 'contour'].include?(opts[:'geometry'])
    fail ArgumentError, 'invalid value for "geometry", must be one of centre, contour'
  end
  # resource path
  local_var_path = '/communes/{code}'.sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}
  query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
  query_params[:'format'] = opts[:'format'] if !opts[:'format'].nil?
  query_params[:'geometry'] = opts[:'geometry'] if !opts[:'geometry'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Commune')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CommunesApi#communes_code_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#communes_get(opts = {}) ⇒ Array<Commune>

Recherche des communes

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :code_postal (String)

    Code postal associé

  • :lat (Float)

    Latitude (en degrés)

  • :lon (Float)

    Longitude (en degrés)

  • :nom (String)

    Nom de la commune

  • :boost (String)

    Mode de boost de la recherche par nom

  • :code (String)

    Code de la commune

  • :code_departement (String)

    Code du département associé

  • :code_region (String)

    Code de la région associée

  • :fields (Array<String>)

    Liste des champs souhaités dans la réponse (default to [“nom”,“code”,“codesPostaux”,“codeDepartement”,“codeRegion”,“population”])

  • :format (String)

    Format de réponse attendu (default to json)

  • :geometry (String)

    Géométrie à utiliser pour la sortie géographique (default to centre)

Returns:



104
105
106
107
# File 'lib/api_geo_client/api/communes_api.rb', line 104

def communes_get(opts = {})
  data, _status_code, _headers = communes_get_with_http_info(opts)
  data
end

#communes_get_with_http_info(opts = {}) ⇒ Array<(Array<Commune>, Fixnum, Hash)>

Recherche des communes

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :code_postal (String)

    Code postal associé

  • :lat (Float)

    Latitude (en degrés)

  • :lon (Float)

    Longitude (en degrés)

  • :nom (String)

    Nom de la commune

  • :boost (String)

    Mode de boost de la recherche par nom

  • :code (String)

    Code de la commune

  • :code_departement (String)

    Code du département associé

  • :code_region (String)

    Code de la région associée

  • :fields (Array<String>)

    Liste des champs souhaités dans la réponse

  • :format (String)

    Format de réponse attendu

  • :geometry (String)

    Géométrie à utiliser pour la sortie géographique

Returns:

  • (Array<(Array<Commune>, Fixnum, Hash)>)

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



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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/api_geo_client/api/communes_api.rb', line 123

def communes_get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CommunesApi.communes_get ...'
  end
  if @api_client.config.client_side_validation && opts[:'fields'] && !opts[:'fields'].all? { |item| ['nom', 'code', 'codesPostaux', 'centre', 'surface', 'contour', 'codeDepartement', 'departement', 'codeRegion', 'region', 'population'].include?(item) }
    fail ArgumentError, 'invalid value for "fields", must include one of nom, code, codesPostaux, centre, surface, contour, codeDepartement, departement, codeRegion, region, population'
  end
  if @api_client.config.client_side_validation && opts[:'format'] && !['json', 'geojson'].include?(opts[:'format'])
    fail ArgumentError, 'invalid value for "format", must be one of json, geojson'
  end
  if @api_client.config.client_side_validation && opts[:'geometry'] && !['centre', 'contour'].include?(opts[:'geometry'])
    fail ArgumentError, 'invalid value for "geometry", must be one of centre, contour'
  end
  # resource path
  local_var_path = '/communes'

  # query parameters
  query_params = {}
  query_params[:'codePostal'] = opts[:'code_postal'] if !opts[:'code_postal'].nil?
  query_params[:'lat'] = opts[:'lat'] if !opts[:'lat'].nil?
  query_params[:'lon'] = opts[:'lon'] if !opts[:'lon'].nil?
  query_params[:'nom'] = opts[:'nom'] if !opts[:'nom'].nil?
  query_params[:'boost'] = opts[:'boost'] if !opts[:'boost'].nil?
  query_params[:'code'] = opts[:'code'] if !opts[:'code'].nil?
  query_params[:'codeDepartement'] = opts[:'code_departement'] if !opts[:'code_departement'].nil?
  query_params[:'codeRegion'] = opts[:'code_region'] if !opts[:'code_region'].nil?
  query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
  query_params[:'format'] = opts[:'format'] if !opts[:'format'].nil?
  query_params[:'geometry'] = opts[:'geometry'] if !opts[:'geometry'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Array<Commune>')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CommunesApi#communes_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#departements_code_communes_get(code, opts = {}) ⇒ Commune

Renvoi les communes d’un département

Parameters:

  • code

    Code du département

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

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    Liste des champs souhaités dans la réponse (default to [“nom”,“code”,“codesPostaux”,“codeDepartement”,“codeRegion”,“population”])

  • :format (String)

    Format de réponse attendu (default to json)

  • :geometry (String)

    Géométrie à utiliser pour la sortie géographique (default to centre)

Returns:



183
184
185
186
# File 'lib/api_geo_client/api/communes_api.rb', line 183

def departements_code_communes_get(code, opts = {})
  data, _status_code, _headers = departements_code_communes_get_with_http_info(code, opts)
  data
end

#departements_code_communes_get_with_http_info(code, opts = {}) ⇒ Array<(Commune, Fixnum, Hash)>

Renvoi les communes d&#39;un département

Parameters:

  • code

    Code du département

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

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    Liste des champs souhaités dans la réponse

  • :format (String)

    Format de réponse attendu

  • :geometry (String)

    Géométrie à utiliser pour la sortie géographique

Returns:

  • (Array<(Commune, Fixnum, Hash)>)

    Commune data, response status code and response headers



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/api_geo_client/api/communes_api.rb', line 195

def departements_code_communes_get_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CommunesApi.departements_code_communes_get ...'
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CommunesApi.departements_code_communes_get"
  end
  if @api_client.config.client_side_validation && opts[:'fields'] && !opts[:'fields'].all? { |item| ['nom', 'code', 'codesPostaux', 'centre', 'surface', 'contour', 'codeDepartement', 'departement', 'codeRegion', 'region', 'population'].include?(item) }
    fail ArgumentError, 'invalid value for "fields", must include one of nom, code, codesPostaux, centre, surface, contour, codeDepartement, departement, codeRegion, region, population'
  end
  if @api_client.config.client_side_validation && opts[:'format'] && !['json', 'geojson'].include?(opts[:'format'])
    fail ArgumentError, 'invalid value for "format", must be one of json, geojson'
  end
  if @api_client.config.client_side_validation && opts[:'geometry'] && !['centre', 'contour'].include?(opts[:'geometry'])
    fail ArgumentError, 'invalid value for "geometry", must be one of centre, contour'
  end
  # resource path
  local_var_path = '/departements/{code}/communes'.sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}
  query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?
  query_params[:'format'] = opts[:'format'] if !opts[:'format'].nil?
  query_params[:'geometry'] = opts[:'geometry'] if !opts[:'geometry'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Commune')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CommunesApi#departements_code_communes_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end