-
Notifications
You must be signed in to change notification settings - Fork 0
Firebase Functions
- createPostRequestBody(params)
- getAllIssueCategories(city)
- getAllIssueCategoriesFromUrl(city)
- getAllAttributesForIssue(serviceId, city)
- replaceAddressStringsToId(params, mandatoryParams)
- checkSubmissionParams(params)
- submitIssueToCity(params, city)
- checkIfCityIsAccepted(city)
- findCityBasedOnLatAndLon(lat, long)
- cacheCategoriesForCity(city, categories)
- uploadIssueToFirebaseDatabase(params, cityResponse)
- handleFormUpload(req)
params: Plain Object that should look like the one below.
params = {
service_code: '2000031-1',
address_string: '50 laurier ave W',
attribute:
{
client_address_id_req: '___A6TJQ',
client_address_string_req: 'AS',
cmb_councillorcheckbox: 'Yes_No.Yes'
},
lat: '45.7204',
long: '-75.6896',
first_name: 'F',
last_name: 'S',
email: 'fs@gmail.com',
phone: '1231231234',
service_name: 'Disabled parking spaces',
user_id: 'BJ01n7HSp1ZDXuWd1IC8SYsho8d2',
description: 'parking spot not available',
category: 'Parking',
city: 'ottawa',
media_url: ''
}This function will make the body of the post request for the specific city. It currently only handles Ottawa otherwise only returns the plain Object itself.
This function returns a promise which resolves the body of the post request needed for the specific city. Given that it only handles Ottawa at this time, it makes the serializes the Object into a url append-able string.
| Param | Description | Supported values |
|---|---|---|
| city | String that identifies the current city the categories need to be fetched from. | "Ottawa" |
This function gathers the categories from the given city. It first checks if the city categories have been cached, if they have been, it then checks if the categories are outdated, if they are, it then refetches from the city itself then caches them. If the categories have not been cached, the function fetches them from the city and then caches them.
This function returns a promise which resolves an Object that contains the categories for the given city
| Param | Description | Supported values |
|---|---|---|
| city | String that identifies the current city the categories need to be fetched from. | "Ottawa" |
This function calls the correct endpoint() for the given city and molds the response into a category sorted object.
This function returns a promise which resolves the categories for the given city.
| Param | Description | Supported values |
|---|---|---|
| city | String that identifies the current city the categories need to be fetched from. | "Ottawa" |
| serviceId | String that identifies the service request ID. | ex: "2000031-1"
|
This function calls the correct city endpoint to gather all the necessary attributes for the given service request ID.
This function returns a promise which resolves the necessary attributes for the give service request ID and city.
| Params | Description |
|---|---|
| params | Plain Object that should look like the one below. |
| mandatoryParams | Array of mandatory attributes needed for the given request. |
params = {
service_code: '2000031-1',
address_string: '50 laurier ave W',
attribute:
{
client_address_id_req: '___A6TJQ',
client_address_string_req: 'AS',
cmb_councillorcheckbox: 'Yes_No.Yes'
},
lat: '45.7204',
long: '-75.6896',
first_name: 'f',
last_name: 's',
email: 'fs@gmail.com',
phone: '1231231234',
service_name: 'Disabled parking spaces',
user_id: 'BJ01n7HSp1ZDXuWd1IC8SYsho8d2',
description: 'parking spot not available',
category: 'Parking',
city: 'ottawa'
}
mandatoryParams = [
{
variable: true,
code: 'client_address_string_req',
datatype: 'string',
required: true,
datatypeDescription: null,
order: 6,
description: 'Client postal address',
values: [] },
{
variable: true,
code: 'client_address_id_req',
datatype: 'string',
required: true,
datatypeDescription: null,
order: 7,
description: 'Client address id',
values: [] },
{
variable: true,
code: 'cmb_councillorcheckbox',
datatype: 'singlevaluelist',
required: true,
datatypeDescription: null,
order: 12,
description: 'I consent to provide my personal information',
values: [ [Object], [Object] ]
}
]This function checks for attributes that need an ID version of the address and converts them by calling the appropriate city endpoint.
This function returns a promise which resolves nothing, it simply modifies the params object.
| Param | Description |
|---|---|
| params | Plain Object that should look like the one below. |
params = {
service_code: '2000031-1',
address_string: '50 laurier ave W',
attribute:
{
client_address_id_req: '___A6TJQ',
client_address_string_req: 'AS',
cmb_councillorcheckbox: 'Yes_No.Yes'
},
lat: '45.7204',
long: '-75.6896',
first_name: 'f',
last_name: 's',
email: 'fs@gmail.com',
phone: '1231231234',
service_name: 'Disabled parking spaces',
user_id: 'BJ01n7HSp1ZDXuWd1IC8SYsho8d2',
description: 'parking spot not available',
category: 'Parking',
city: 'ottawa'
}This function checks if the post request to the city contains all the necessary attributes for the given service request.
This function returns a promise which does not resolve anything, it simply modifies the params object as it may call replaceAddressStringsToId(params, mandatoryParams).
| Param | Description | Supported values |
|---|---|---|
| params | Plain Object that should look like the one below or serialized to a string by createPostRequestBody(params). | |
| city | String that identifies the current city where the request needs to be posted to. | "Ottawa" |
params = {
service_code: '2000031-1',
address_string: '50 laurier ave W',
attribute:
{
client_address_id_req: '___A6TJQ',
client_address_string_req: 'AS',
cmb_councillorcheckbox: 'Yes_No.Yes'
},
lat: '45.7204',
long: '-75.6896',
first_name: 'f',
last_name: 's',
email: 'fs@gmail.com',
phone: '1231231234',
service_name: 'Disabled parking spaces',
user_id: 'BJ01n7HSp1ZDXuWd1IC8SYsho8d2',
description: 'parking spot not available',
category: 'Parking',
city: 'ottawa'
}This function submits the service request to the given city.
This function returns a promise which resolves a response Object received from the city.
| Param | Description | Supported value |
|---|---|---|
| city | String that identifies the current city where the request needs to be posted to. | "Ottawa" |
This function checks if the city is in the Neappoli's offering.
This function returns a boolean based on the presence of the city in Neappoli.
| Param | Description | Example |
|---|---|---|
| lat | Float that represents the latitude of the pin. | 45.7204 |
| long | Float that represents the longitude of the pin. | -75.6896 |
This function gets the city of the pin created based on its geo-coordinates
This function returns a promise which resolves a String representing the city the pin is in.
| Param | Description | Supported values |
|---|---|---|
| city | String that represents the city to which the categories of services belong. | "Ottawa" |
| categories | Category Object which should be returned by the cache or getAllIssueCategories(city). |
This function caches the categories in the Firebase database with the city as the key.
This function returns a promise which resolves nothing.
| Param | Description |
|---|---|
| params | Plain Object that should look like the one below. |
| cityResponse | Object that the city returns. |
params = {
service_code: '2000031-1',
address_string: '50 laurier ave W',
attribute:
{
client_address_id_req: '___A6TJQ',
client_address_string_req: 'AS',
cmb_councillorcheckbox: 'Yes_No.Yes'
},
lat: '45.7204',
long: '-75.6896',
first_name: 'f',
last_name: 's',
email: 'fs@gmail.com',
phone: '1231231234',
service_name: 'Disabled parking spaces',
user_id: 'BJ01n7HSp1ZDXuWd1IC8SYsho8d2',
description: parking spot not available,
category: 'Parking',
city: 'ottawa',
media_url: ''
}This function uploads the service request issue to the Firebase database.
This function returns a promise which resolves nothing.
| Param | Description |
|---|---|
| req | The post request body received from any client device. |
This function parses the multiform data received from the POST request and creates the params object.
This function returns a promise which the parsed parameters.