From 4c64c462542400551954d3394ebb9af2cebbeeda Mon Sep 17 00:00:00 2001 From: xXEmilioXx <38227115+xXEmilioXx@users.noreply.github.com> Date: Mon, 13 Jan 2020 18:34:06 +0100 Subject: [PATCH] Update backend stub to version 8.2 --- backendStub/.swagger-codegen/VERSION | 2 +- backendStub/api/swagger.yaml | 1388 +++++++++++++++++++-- backendStub/controllers/Customer.js | 32 + backendStub/controllers/Emilio.js | 42 + backendStub/controllers/Frikk.js | 44 +- backendStub/controllers/Marin.js | 61 +- backendStub/controllers/Owner.js | 42 + backendStub/package-lock.json | 178 +-- backendStub/service/CustomerService.js | 91 +- backendStub/service/EmilioService.js | 92 +- backendStub/service/FrikkService.js | 91 +- backendStub/service/GenericUserService.js | 2 +- backendStub/service/MarinService.js | 218 +++- backendStub/service/MatejService.js | 2 +- backendStub/service/OwnerService.js | 102 +- 15 files changed, 2096 insertions(+), 291 deletions(-) diff --git a/backendStub/.swagger-codegen/VERSION b/backendStub/.swagger-codegen/VERSION index a6c4b4a2..e393c3c5 100644 --- a/backendStub/.swagger-codegen/VERSION +++ b/backendStub/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.10 \ No newline at end of file +2.4.11 \ No newline at end of file diff --git a/backendStub/api/swagger.yaml b/backendStub/api/swagger.yaml index bcf1e232..36659edf 100644 --- a/backendStub/api/swagger.yaml +++ b/backendStub/api/swagger.yaml @@ -12,13 +12,15 @@ info: \ to customers nor owners remain inside the default group.\n \n AUTHENTICATION/AUTHORIZATION:\ \ The json web token returned when the login is performed is supposed to be put\ \ into x-auth-token header in the endpoints that require authorization" - version: "6.4" + version: "8.2" title: "The Spoon API reference" tags: - name: "customer" description: "Operations about customers" - name: "owner" description: "Operations about owners" +- name: "consultant" + description: "Operations about consultants" paths: /api/user/customer/register: post: @@ -46,7 +48,16 @@ paths: schema: $ref: "#/definitions/UsernameAndToken" "400": - description: "Username or email already taken" + description: "A string describing the error. Could be for example 'Username\ + \ or email already taken.' or 'Invalid input.'" + schema: + type: "string" + example: "Username or email already taken." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." x-swagger-router-controller: "Customer" /api/user/owner/register: post: @@ -74,7 +85,16 @@ paths: schema: $ref: "#/definitions/UsernameAndToken" "400": - description: "Username or email already taken" + description: "A string describing the error. Could be for example 'Username\ + \ or email already taken.' or 'Invalid input.'" + schema: + type: "string" + example: "Username or email already taken." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." x-swagger-router-controller: "Owner" /api/user/login: post: @@ -96,7 +116,7 @@ paths: parameters: - in: "body" name: "body" - description: "User that needs to register" + description: "User that needs to login" required: true schema: $ref: "#/definitions/UserLogin" @@ -106,7 +126,16 @@ paths: schema: $ref: "#/definitions/Token" "400": - description: "Invalid username or password" + description: "A string describing the error. Could be for example 'Invalid\ + \ username or password.' or 'Invalid input.'" + schema: + type: "string" + example: "Invalid username or password." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." x-swagger-router-controller: "GenericUser" /api/user/owner/restaurant: get: @@ -127,6 +156,14 @@ paths: $ref: "#/definitions/RestaurantReceived" "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -138,21 +175,22 @@ paths: - "Matej" summary: "Configure data of the restaurant" description: "Save the data of the restaurant given by the owner. Authentication\ - \ is needed.\n One of the parameter to be passed is the imageID, this is the\ - \ flow:\n 1. The restaurant owner is in the page in which he can input the\ - \ restaurant data. He will upload the photo of the restaurant while he is\ - \ writing all the fields of the form.\n 2. The uploading of the photo is done\ - \ by sending the photo to the /api/image endpoint. While the restaurant owner\ - \ is still writing the fields of the form, the message to that endpoint is\ - \ sent and the imageID is received as a response.\n 3. When the restaurant\ - \ owner finishes writing the fields of the form and click the send button,\ - \ the photo was actually already been ent in the point 2 and he doesn't have\ - \ to wait for the upload (if he was fast compiling the form and the upload\ - \ isn't finished yet, at least he has to wait less because it was already\ - \ started). The imageID received as a response by the /api/image endpoint\ - \ will be sent to this endpoint with the data of the form in a json, because\ - \ the backend needs it in order to associate the json to the previously uploaded\ - \ photo." + \ is needed. A 400 will be sent if the owner already sent the data of his\ + \ restaurant (an owner can't have more than one restaurant).\n One of the\ + \ parameter to be passed is the imageID, this is the flow:\n 1. The restaurant\ + \ owner is in the page in which he can input the restaurant data. He will\ + \ upload the photo of the restaurant while he is writing all the fields of\ + \ the form.\n 2. The uploading of the photo is done by sending the photo to\ + \ the /api/image endpoint. While the restaurant owner is still writing the\ + \ fields of the form, the message to that endpoint is sent and the imageID\ + \ is received as a response.\n 3. When the restaurant owner finishes writing\ + \ the fields of the form and click the send button, the photo was actually\ + \ already been ent in the point 2 and he doesn't have to wait for the upload\ + \ (if he was fast compiling the form and the upload isn't finished yet, at\ + \ least he has to wait less because it was already started). The imageID received\ + \ as a response by the /api/image endpoint will be sent to this endpoint with\ + \ the data of the form in a json, because the backend needs it in order to\ + \ associate the json to the previously uploaded photo." operationId: "configureRestaurant" consumes: - "application/json" @@ -170,8 +208,22 @@ paths: description: "Successful operation" schema: $ref: "#/definitions/RestaurantID" + "400": + description: "A string describing the error. Could be for example 'Restaurant\ + \ already existing.' or 'Invalid input.'" + schema: + type: "string" + example: "Restaurant already existing." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -182,7 +234,9 @@ paths: - "owner" - "Emilio" summary: "Edit restaurant's information" - description: "Edit the information of the restaurant" + description: "Edit the information of the restaurant. It's needed that the restaurant\ + \ already exists, otherwise a 404 error will be sent. The POST endpoint should\ + \ be used to create it." operationId: "editRestaurant" consumes: - "application/json" @@ -200,8 +254,27 @@ paths: description: "Successful operation" schema: $ref: "#/definitions/RestaurantID" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "No restaurant associated to this account found" + schema: + type: "string" + example: "No restaurant associated to this account found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -215,7 +288,8 @@ paths: summary: "Return all the menus of the restaurant" description: "Return all the menus of the restaurant. Since authentication is\ \ required, the backend is able to get which restaurant is involved from the\ - \ authentication token." + \ authentication token. It's needed that the restaurant already exists, otherwise\ + \ a 404 error will be sent." operationId: "getOwnMenus" produces: - "application/json" @@ -229,6 +303,19 @@ paths: $ref: "#/definitions/MenuCompleteWithID" "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "No restaurant associated to this account found" + schema: + type: "string" + example: "No restaurant associated to this account found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -241,7 +328,9 @@ paths: summary: "Add an empty menu to a restaurant" description: "Add a menu to a restaurant of a restaurant owner, which needs\ \ to be logged in. The menuItems are not meant to be added to the menu through\ - \ this endpoint." + \ this endpoint. The tags of the menu must be valid, otherwise a 400 error\ + \ will be sent. It's needed that the restaurant already exists, otherwise\ + \ a 404 error will be sent." operationId: "addMenu" consumes: - "application/json" @@ -255,12 +344,31 @@ paths: schema: $ref: "#/definitions/MenuWithoutItems" responses: - "200": + "201": description: "Successful operation" schema: $ref: "#/definitions/MenuID" + "400": + description: "A string describing the error. Could be for example 'One or\ + \ more tags are not valid.' or 'Invalid input.'" + schema: + type: "string" + example: "One or more tags are not valid." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "No restaurant associated to this account found" + schema: + type: "string" + example: "No restaurant associated to this account found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -273,7 +381,9 @@ paths: - "Emilio" summary: "Edit a menu's information (not its items)" description: "Edit a given menu (but not its menuItems). To identify the menu,\ - \ the menuID needs to be given. Authentication is required." + \ the menuID needs to be given. Authentication is required. The tags of the\ + \ menu must be valid, otherwise a 400 error will be sent. It's needed that\ + \ the restaurant already exists, otherwise a 404 error will be sent." operationId: "editMenu" consumes: - "application/json" @@ -296,10 +406,27 @@ paths: description: "Successful operation" schema: $ref: "#/definitions/MenuID" + "400": + description: "A string describing the error. Could be for example 'One or\ + \ more tags are not valid.' or 'Invalid input.'" + schema: + type: "string" + example: "One or more tags are not valid." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." "404": - description: "Menu not found" + description: "Menu not found/No restaurant associated to this account found" + schema: + type: "string" + example: "Menu not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -310,7 +437,9 @@ paths: - "owner" - "Emilio" summary: "Delete a menu" - description: "Delete a menu of the restaurant. Authentication is required" + description: "Delete a menu of the restaurant. Authentication is required. It's\ + \ needed that the restaurant already exists, otherwise a 404 error will be\ + \ sent." operationId: "deleteMenu" parameters: - name: "menuID" @@ -321,8 +450,27 @@ paths: responses: "200": description: "Successful operation" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "Menu not found/No restaurant associated to this account found" + schema: + type: "string" + example: "Menu not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -339,7 +487,10 @@ paths: \ The menu items inside every menu are not returned. It will be needed to\ \ access the endpoint /api/user/customer/menu/{menuID} to get the menu items\ \ of a specific menu (the menuID passed can be obtained from the response\ - \ of this endpoint, since it returns the menuID of every menu)." + \ of this endpoint, since it returns the menuID of every menu).\n The customer\ + \ can be not logged in, if that is the case then the authentication token\ + \ must be sent with a null value. The authentication in this endpoint is necessary\ + \ to collect the search done by the customer and use it to collect statistics." operationId: "searchByMenuItem" produces: - "application/json" @@ -356,8 +507,31 @@ paths: type: "array" items: $ref: "#/definitions/MenuAndRestaurant" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." "404": description: "No menu item found" + schema: + type: "string" + example: "No matching Menus." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "customer" x-swagger-router-controller: "Customer" /api/user/customer/menu/{menuID}: get: @@ -384,6 +558,22 @@ paths: description: "Successful operation" schema: $ref: "#/definitions/MenuRetrievedToCustomer" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." + "404": + description: "Menu with given menuID not found" + schema: + type: "string" + example: "Menu with given menuID not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." x-swagger-router-controller: "Customer" /api/image: post: @@ -414,6 +604,14 @@ paths: $ref: "#/definitions/ImageID" "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "422": + description: "Image upload error" + schema: + type: "string" + example: "Image upload error." security: - Bearer: [] x-security-scopes: @@ -425,7 +623,10 @@ paths: - "owner" - "Marin" summary: "Add a menuItem to a menu" - description: "Add a menuItem to the menu with given menuID. Authentication required." + description: "Add a menuItem to the menu with given menuID. Authentication required.\ + \ The tags of the menu item must be valid, otherwise a 400 error will be sent.\ + \ It's needed that the restaurant already exists, otherwise a 404 error will\ + \ be sent." operationId: "addMenuItem" consumes: - "application/json" @@ -448,8 +649,27 @@ paths: description: "Successful operation" schema: $ref: "#/definitions/Menu" + "400": + description: "A string describing the error. Could be for example 'One or\ + \ more tags are not valid.' or 'Invalid input.'" + schema: + type: "string" + example: "One or more tags are not valid." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "Menu not found/No restaurant associated to this account found" + schema: + type: "string" + example: "Menu not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -462,7 +682,9 @@ paths: - "Marin" summary: "Edit a menuItem" description: "Edit the menuItem with given menuItemID of the menu with given\ - \ menuID. Authentication required." + \ menuID. Authentication required. The tags of the menu item must be valid,\ + \ otherwise a 400 error will be sent. It's needed that the restaurant already\ + \ exists, otherwise a 404 error will be sent." operationId: "editMenuItem" consumes: - "application/json" @@ -490,8 +712,28 @@ paths: description: "Successful operation" schema: $ref: "#/definitions/Menu" + "400": + description: "A string describing the error. Could be for example 'One or\ + \ more tags are not valid.' or 'Invalid input.'" + schema: + type: "string" + example: "One or more tags are not valid." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "Menu not found/Menu item not found/No restaurant associated\ + \ to this account found" + schema: + type: "string" + example: "Menu item not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -503,7 +745,8 @@ paths: - "Marin" summary: "Delete a menuItem" description: "Delete the menuItem with given menuItemID of the menu with given\ - \ menuID. Authentication required." + \ menuID. Authentication required. It's needed that the restaurant already\ + \ exists, otherwise a 404 error will be sent." operationId: "deleteMenuItem" parameters: - name: "menuID" @@ -519,8 +762,28 @@ paths: responses: "200": description: "Successful operation" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "Menu not found/Menu item not found/No restaurant associated\ + \ to this account found" + schema: + type: "string" + example: "Menu item not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -532,7 +795,12 @@ paths: - "customer" - "Emilio" summary: "Return all the restaurants" - description: "Return all the names of the restaurants and their restaurantIDs." + description: "Return all the names of the restaurants and their restaurantIDs.\ + \ Only the restaurants that actually contain menus are actually sent, because\ + \ a menu has to be reviewed, so it wouldn't make sense to send restaurant\ + \ with no menus. Moreover, at least one menu of the restaurant must have at\ + \ least one menu item inside.\n In case no restaurant is found, an empty array\ + \ is sent (with code 200, not 404)." operationId: "getRestaurants" produces: - "application/json" @@ -546,6 +814,14 @@ paths: $ref: "#/definitions/RestaurantIDAndName" "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -558,7 +834,8 @@ paths: - "Emilio" summary: "Return all the menus of given restaurant" description: "Return all the names of the menus of the restaurant and their\ - \ menuIDs." + \ menuIDs. Only menus that contain at least one menu item are actually sent.\n\ + \ In case no menu is found, an empty array is sent (with code 200, not 404). " operationId: "getMenusOfRestaurant" produces: - "application/json" @@ -575,10 +852,27 @@ paths: type: "array" items: $ref: "#/definitions/MenuIDAndName" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." "404": - description: "Restaurant with given restaurantID doesn't exist" + description: "Restaurant with given restaurantID not found" + schema: + type: "string" + example: "Restaurant with given restaurantID not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -590,7 +884,8 @@ paths: - "customer" - "Emilio" summary: "Return all the menu items of given menu" - description: "Return all the names of the restaurants and their restaurantIDs." + description: "Return all the menu items of given menu.\n In case no menu item\ + \ is found, an empty array is sent (with code 200, not 404)." operationId: "getItemsOfMenu" produces: - "application/json" @@ -607,10 +902,27 @@ paths: type: "array" items: $ref: "#/definitions/MenuItemIDAndName" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." "404": - description: "Menu with given menuID doesn't exist" + description: "Menu with given menuID not found" + schema: + type: "string" + example: "Menu with given menuID not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -620,7 +932,7 @@ paths: post: tags: - "customer" - - "Frikk" + - "Marin" summary: "Submit a review of the menu" description: "Submit a review of the menu with given menuID. The receiptImageID\ \ is obtained by the frontend when the photo of the receipt is uploaded through\ @@ -643,10 +955,27 @@ paths: responses: "201": description: "Successful operation" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." "404": - description: "Menu with given menuID doesn't exist" + description: "Menu with given menuID not found" + schema: + type: "string" + example: "Menu with given menuID not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -660,7 +989,7 @@ paths: summary: "Return all the reviews of the customer" description: "Return all the reviews of the customer, with their reviewIDs and\ \ their status (accepted/refused/pending). Returns an empty array if no review\ - \ is found." + \ is found (with code 200, not 404)." operationId: "getOwnReviews" produces: - "application/json" @@ -674,6 +1003,14 @@ paths: $ref: "#/definitions/MenuReviewWithIDAndStatus" "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -683,10 +1020,12 @@ paths: delete: tags: - "customer" - - "Marin" + - "Frikk" summary: "Delete a review" description: "Delete the review with the given reviewID. This will also delete\ - \ the reviews of the menu items associated to the review with given reviewID." + \ the reviews of the menu items associated to the review with given reviewID.\ + \ The review must belong to the authenticated customer, otherwise a 403 error\ + \ will be sent." operationId: "apiUserCustomerReviewReviewIDDELETE" parameters: - name: "reviewID" @@ -697,11 +1036,33 @@ paths: responses: "200": description: "Successful operation" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "403": + description: "The review doesn't belong to the authenticated customer, so\ + \ it can't be deleted" + schema: + type: "string" + example: "Forbidden request." "404": - description: "Review associated to the customer with given reviewID not\ - \ found" + description: "Review with given reviewID not found" + schema: + type: "string" + example: "Review with given reviewID not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -713,7 +1074,7 @@ paths: - "customer" - "Marin" summary: "Return profile data of the customer" - description: "Return own data of the logged in customer. This endpoints should\ + description: "Return own data of the logged in customer. This endpoint should\ \ be used when the frontend has to visualize the profile of the customer." operationId: "apiUserCustomerGET" produces: @@ -723,9 +1084,90 @@ paths: "200": description: "Successful operation" schema: - $ref: "#/definitions/CustomerUsernameAndEmail" + $ref: "#/definitions/CustomerData" + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "customer" + x-swagger-router-controller: "Customer" + put: + tags: + - "customer" + - "Frikk" + summary: "Edit profile data of the customer" + description: "Edit profile data of the logged in customer. All the customer\ + \ data must be sent with this endpoint, even if it's not changed (in that\ + \ case the fields must contain the current values). The password can't be\ + \ changed through this endpoint, but the dedicated one should be used instead.\n\ + \ Valid values for Gender are 'Male/Female/Other'.\n The username, the name\ + \ and the surname can't be changed.\n The age is a range, for example '24-34'." + operationId: "apiUserCustomerPUT" + consumes: + - "application/json" + parameters: + - in: "body" + name: "body" + description: "New data of the customer" + required: true + schema: + $ref: "#/definitions/CustomerEditData" + responses: + "200": + description: "Successful operation" + schema: + $ref: "#/definitions/CustomerData" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "customer" + x-swagger-router-controller: "Customer" + delete: + tags: + - "customer" + - "Frikk" + summary: "Delete profile of the customer" + description: "Delete profile of the logged in customer." + operationId: "apiUserCustomerDELETE" + parameters: [] + responses: + "200": + description: "Successful operation" + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -742,7 +1184,9 @@ paths: \ together with the name of the reviewed menu and the list of the reviewed\ \ menu items.The pending reviews are sent in an array, which will be empty\ \ in case there are no pending reviews. With a POST the restaurant owner will\ - \ approve or disapprove the review." + \ approve or disapprove the review.\n If there are no pending reviews, an\ + \ empty array is sent (with code 200, not 404).\n It's needed that the restaurant\ + \ already exists, otherwise a 404 error will be sent." operationId: "apiUserOwnerRestaurantReviewGET" produces: - "application/json" @@ -753,9 +1197,22 @@ paths: schema: type: "array" items: - $ref: "#/definitions/PendingReview" + $ref: "#/definitions/PendingReviewWithPhoto" "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "No restaurant associated to this account found" + schema: + type: "string" + example: "No restaurant associated to this account found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: @@ -764,106 +1221,505 @@ paths: /api/user/owner/restaurant/review/{reviewID}: post: tags: - - "owner" + - "owner" + - "Marin" + summary: "Approve or disapprove pending review" + description: "Submit the decision of the restaurant owner about the pending\ + \ review with given reviewID (approved or disapproved). In case of a successful\ + \ operation, an array containing all the pending reviews is sent, so that\ + \ the frontend is able to refresh the list (the array sent is like the array\ + \ sent with the GET endpoint). It's needed that the restaurant already exists,\ + \ otherwise a 404 error will be sent." + operationId: "apiUserOwnerRestaurantReviewReviewIDPOST" + consumes: + - "application/json" + parameters: + - name: "reviewID" + in: "path" + description: "ID of the pending review" + required: true + type: "integer" + - in: "body" + name: "body" + description: "Submitted status of pending review (approved or disapproved)" + required: true + schema: + $ref: "#/definitions/ApprovalStatus" + responses: + "201": + description: "Successful operation" + schema: + type: "array" + items: + $ref: "#/definitions/PendingReview" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "Review with given reviewID not found/No restaurant associated\ + \ to this account found" + schema: + type: "string" + example: "Review with given reviewID not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "owner" + x-swagger-router-controller: "Owner" + /api/user/customer/menu/{menuID}/menuItem/{menuItemID}/review: + get: + tags: + - "customer" + - "Frikk" + summary: "Return all the reviews of the menu item" + description: "Return all the reviews of the menu item with given menuItemID\ + \ contained in the menu with given menuID. If there are no reviews, an empty\ + \ array is sent (with code 200, not 404)." + operationId: "apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET" + produces: + - "application/json" + parameters: + - name: "menuID" + in: "path" + description: "ID of the menu" + required: true + type: "integer" + - name: "menuItemID" + in: "path" + description: "ID of the menu item" + required: true + type: "integer" + responses: + "200": + description: "Successful operation" + schema: + type: "array" + items: + $ref: "#/definitions/ReviewsOfMenuItemWithoutOverall" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." + "404": + description: "Menu not found/Menu item not found" + schema: + type: "string" + example: "Menu item not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + x-swagger-router-controller: "Customer" + /api/user/owner/tag: + get: + tags: + - "owner" + - "Emilio" + summary: "Return all the available tags" + description: "When a restaurant owner is creating a menu or a menu item, he/she\ + \ needs to know the list of the available tags. If there are no tags, an empty\ + \ array is sent (with code 200, not 404)." + operationId: "apiUserOwnerTagGET" + produces: + - "application/json" + parameters: [] + responses: + "200": + description: "Successful operation" + schema: + type: "array" + items: + type: "string" + example: + - "Italian" + - "Dinner" + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "owner" + x-swagger-router-controller: "Owner" + /api/user/owner: + get: + tags: + - "owner" + - "Emilio" + summary: "Return profile data of the owner" + description: "Return own data of logged in owner. This endpoint should be used\ + \ when the frontend has to visualize the profile of the owner." + operationId: "apiUserOwnerGET" + produces: + - "application/json" + parameters: [] + responses: + "200": + description: "Successful operation" + schema: + $ref: "#/definitions/OwnerData" + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "owner" + x-swagger-router-controller: "Owner" + put: + tags: + - "owner" + - "Emilio" + summary: "Edit profile data of the owner" + description: "Edit profile data of the logged in owner. The password can't be\ + \ changed through this endpoint, but the dedicated one should be used instead.\n\ + \ The username can't be changed." + operationId: "apiUserOwnerPUT" + consumes: + - "application/json" + parameters: + - in: "body" + name: "body" + description: "New data of the owner" + required: true + schema: + $ref: "#/definitions/OwnerEditData" + responses: + "200": + description: "Successful operation" + schema: + $ref: "#/definitions/OwnerData" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Invalid input." + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "owner" + x-swagger-router-controller: "Owner" + delete: + tags: + - "owner" + - "Emilio" + summary: "Delete profile of the owner" + description: "Delete profile of the logged in owner." + operationId: "apiUserOwnerDELETE" + parameters: [] + responses: + "200": + description: "Successful operation" + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "owner" + x-swagger-router-controller: "Owner" + /api/user/customer/password: + put: + tags: + - "customer" + - "Marin" + summary: "Change the password of the customer" + description: "Change the password of the logged in customer. The current password\ + \ must be provided, for security reasons. A 400 is sent back if the current\ + \ password provided doesn't match, and the password change is not performed." + operationId: "apiUserCustomerPasswordPUT" + consumes: + - "application/json" + produces: + - "application/json" + parameters: + - in: "body" + name: "body" + description: "New and current passwords" + required: true + schema: + $ref: "#/definitions/PasswordChange" + responses: + "200": + description: "Successful operation" + "400": + description: "A string describing the error. Could be for example 'Old password\ + \ doesn't match.' or 'Invalid input.'" + schema: + type: "string" + example: "Old password doesn't match." + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "customer" + x-swagger-router-controller: "Customer" + /api/user/owner/password: + put: + tags: + - "owner" + - "Emilio" + summary: "Change the password of the owner" + description: "Change the password of the logged in owner. The current password\ + \ must be provided, for security reasons. A 400 is sent back if the current\ + \ password provided doesn't match, and the password change is not performed." + operationId: "apiUserOwnerPasswordPUT" + consumes: + - "application/json" + produces: + - "application/json" + parameters: + - in: "body" + name: "body" + description: "New and current passwords" + required: true + schema: + $ref: "#/definitions/PasswordChange" + responses: + "200": + description: "Successful operation" + "400": + description: "A string describing the error. Could be for example 'Old password\ + \ doesn't match.' or 'Invalid input.'" + schema: + type: "string" + example: "Old password doesn't match." + "401": + description: "Access denied" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + security: + - Bearer: [] + x-security-scopes: + - "owner" + x-swagger-router-controller: "Owner" + /api/consultant/register: + post: + tags: + - "consultant" + - "Marin" + summary: "Creates consultant" + description: "Creates a new consultant profile. This endpoint is used only for\ + \ consultant registration. Since the consultant is a special user, it is required\ + \ that a secret word of the company is sent in order to register, that secred\ + \ word is stored in the backend as an environment variable.\n The endpoint,\ + \ if the registration succeeds, returns the username of the account as a confirmation." + operationId: "createConsultant" + consumes: + - "application/json" + produces: + - "application/json" + parameters: + - in: "body" + name: "body" + description: "Consultant that needs to register" + required: true + schema: + $ref: "#/definitions/Consultant" + responses: + "201": + description: "Successful operation" + schema: + $ref: "#/definitions/UsernameAndToken" + "400": + description: "A string describing the error. Could be for example 'Username\ + \ or email already taken.' or 'Wrong company secret word.' or 'Invalid\ + \ input.'" + schema: + type: "string" + example: "Wrong company secret word." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + x-swagger-router-controller: "Consultant" + /api/consultant/login: + post: + tags: + - "consultant" - "Marin" - summary: "Approve or disapprove pending review" - description: "Submit the decision of the restaurant owner about the pending\ - \ review with given reviewID (approved or disapproved). In case of a successful\ - \ operation, an array containing all the pending reviews is sent, so that\ - \ the frontend is able to refresh the list (the array sent is like the array\ - \ sent with the GET endpoint)." - operationId: "apiUserOwnerRestaurantReviewReviewIDPOST" + summary: "Logs consultant into the system" + description: "Logs consultant into the system. If the login succeeds, returns\ + \ the json web token." + operationId: "loginConsultant" consumes: - "application/json" + produces: + - "application/json" parameters: - - name: "reviewID" - in: "path" - description: "ID of the pending review" - required: true - type: "integer" - in: "body" name: "body" - description: "Submitted status of pending review (approved or disapproved)" + description: "Consultant that needs to login" required: true schema: - $ref: "#/definitions/ApprovalStatus" + $ref: "#/definitions/ConsultantLogin" responses: "201": description: "Successful operation" schema: - type: "array" - items: - $ref: "#/definitions/PendingReview" + $ref: "#/definitions/Token" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ username or password.' or 'Invalid input.'" + schema: + type: "string" + example: "Invalid username or password." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." + x-swagger-router-controller: "Consultant" + /api/consultant/statistics: + get: + tags: + - "consultant" + - "Marin" + summary: "Return the global statistics" + description: "Return the aggregate statistics of ALL the users/restaurants in\ + \ the application. The consultant must be logged in to access this endpoint\ + \ (reserved to him). To be more precise, this is what is sent: \n - The total\ + \ number of registered customers\n - For each nationality, the number of customers\n\ + \ - For each gender, the number of customers\n - For each age range, the number\ + \ of customers\n - For each searched word, the number of customers\n - List\ + \ of all the menu names with their ratings. It will be frontend's duty to\ + \ sort them and show the top 10 and the bottom 10" + operationId: "getStatistics" + produces: + - "application/json" + parameters: [] + responses: + "200": + description: "Successful operation" + schema: + $ref: "#/definitions/Statistics" "401": description: "Access denied" - "404": - description: "Review with given reviewID not found" + schema: + type: "string" + example: "Access denied." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: - - "owner" - x-swagger-router-controller: "Owner" - /api/user/customer/menu/{menuID}/menuItem/{menuItemID}/review: + - "consultant" + x-swagger-router-controller: "Consultant" + /api/consultant/statistics/{nationalityName}: get: tags: - - "customer" - - "Frikk" - summary: "Return all the reviews of the menu item" - description: "Return all the reviews of the menu item with given menuItemID\ - \ contained in the menu with given menuID." - operationId: "apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET" + - "consultant" + - "Marin" + summary: "Return statistics of a specific nationality" + description: "Return the statistics of the given nationality. The consultant\ + \ must be logged in to access this endpoint (reserved to him)." + operationId: "getStatisticOfNationality" produces: - "application/json" parameters: - - name: "menuID" - in: "path" - description: "ID of the menu" - required: true - type: "integer" - - name: "menuItemID" + - name: "nationalityName" in: "path" - description: "ID of the menu item" + description: "Nationality" required: true - type: "integer" + type: "string" responses: "200": description: "Successful operation" schema: - type: "array" - items: - $ref: "#/definitions/ReviewsOfMenuItemWithoutOverall" - "404": - description: "Menu or menu item not found" - x-swagger-router-controller: "Customer" - /api/user/owner/tag: - get: - tags: - - "owner" - - "Emilio" - summary: "Return all the available tags" - description: "When a restaurant owner is creating a menu or a menu item, he/she\ - \ needs to know the list of the available tags." - operationId: "apiUserOwnerTagGET" - produces: - - "application/json" - parameters: [] - responses: - "200": - description: "Successful operation" + $ref: "#/definitions/StatisticsOfNationality" + "400": + description: "A string describing the error. Could be for example 'Invalid\ + \ input.'" schema: - type: "array" - items: - type: "string" - example: - - "Italian" - - "Dinner" + type: "string" + example: "Invalid username or password." "401": description: "Access denied" + schema: + type: "string" + example: "Access denied." + "404": + description: "Nationality not found" + schema: + type: "string" + example: "Nationality not found." + "500": + description: "Internal server error" + schema: + type: "string" + example: "Internal server error." security: - Bearer: [] x-security-scopes: - - "owner" - x-swagger-router-controller: "Owner" + - "consultant" + x-swagger-router-controller: "Consultant" securityDefinitions: Bearer: type: "apiKey" @@ -1355,6 +2211,13 @@ definitions: country: "Italy" latitude: 45.46883460000000098943928605876863002777099609375 longitude: 9.223411399999999815690898685716092586517333984375 + openingHours: + - day: "Wednesday" + openTime: "12.30" + closeTime: "14.30" + - day: "Saturday" + openTime: "12.00" + closeTime: "15.00" menuName: "Emilio's menu of the day" description: "Our special menu of today" tags: @@ -1472,6 +2335,17 @@ definitions: type: "number" content: type: "string" + MenuItemReviewWithItemName: + type: "object" + properties: + menuItemID: + type: "integer" + menuItemName: + type: "string" + rating: + type: "number" + content: + type: "string" MenuReviewWithIDAndStatus: type: "object" properties: @@ -1496,7 +2370,7 @@ definitions: menuItemsReviews: type: "array" items: - $ref: "#/definitions/MenuItemReview" + $ref: "#/definitions/MenuItemReviewWithItemName" example: menuReviewID: 34342 menuID: 343 @@ -1509,27 +2383,38 @@ definitions: status: "accepted" menuItemsReviews: - menuItemID: 34 + menuItemName: "Pizza margherita" rating: 4.0999999999999996447286321199499070644378662109375 content: "That was delicious!" - menuItemID: 58 + menuItemName: "Pasta alla carbonara with cream" rating: 0.5 content: "It was an insult, I will never eat that trash again in my whole\ \ life" - CustomerUsernameAndEmail: + PendingReview: type: "object" properties: - username: - type: "string" - email: + reviewID: + type: "integer" + menuName: type: "string" + menuItemNames: + type: "array" + items: + $ref: "#/definitions/PendingReview_menuItemNames" example: - username: "emilio_imperiali" - email: "emilioimperiali@mail.it" - PendingReview: + reviewID: 988 + menuName: "Sea menu" + menuItemNames: + - menuItemName: "Spaghetti allo scoglio" + - menuItemName: "Sashimi" + PendingReviewWithPhoto: type: "object" properties: reviewID: type: "integer" + receiptPhotoLink: + type: "string" menuName: type: "string" menuItemNames: @@ -1538,6 +2423,7 @@ definitions: $ref: "#/definitions/PendingReview_menuItemNames" example: reviewID: 988 + receiptPhotoLink: "www.cloud.com/receiptPhoto" menuName: "Sea menu" menuItemNames: - menuItemName: "Spaghetti allo scoglio" @@ -1615,6 +2501,253 @@ definitions: type: "number" menuItemReviews: $ref: "#/definitions/ReviewsOfMenuItem" + CustomerEditData: + type: "object" + properties: + email: + type: "string" + gender: + type: "string" + ageRange: + type: "string" + nationality: + type: "string" + example: + email: "emilioimperiali@mail.it" + gender: "Male" + ageRange: "24-34" + nationality: "Italy" + OwnerEditData: + type: "object" + properties: + email: + type: "string" + name: + type: "string" + surname: + type: "string" + example: + email: "john.doe@gmail.com" + name: "John" + surname: "Doe" + CustomerData: + type: "object" + properties: + username: + type: "string" + email: + type: "string" + gender: + type: "string" + ageRange: + type: "string" + nationality: + type: "string" + example: + username: "emilio_imperiali" + email: "emilioimperiali@mail.it" + gender: "Male" + ageRange: "24-34" + nationality: "Italy" + OwnerData: + type: "object" + properties: + email: + type: "string" + username: + type: "string" + name: + type: "string" + surname: + type: "string" + example: + email: "john.doe@gmail.com" + username: "johndoe" + name: "John" + surname: "Doe" + PasswordChange: + type: "object" + properties: + oldPassword: + type: "string" + newPassword: + type: "string" + example: + oldPassword: "123456" + newPassword: "654321" + Consultant: + type: "object" + properties: + username: + type: "string" + name: + type: "string" + surname: + type: "string" + email: + type: "string" + companySecret: + type: "string" + password: + type: "string" + example: + username: "xXEmilioXx" + name: "Emilio" + surname: "Imperiali" + email: "consultant@mail.com" + companySecret: "OurCompanyRocks" + password: "123456" + ConsultantLogin: + type: "object" + properties: + username: + type: "string" + password: + type: "string" + example: + username: "xXEmilioXx" + password: "123456" + Statistics: + type: "object" + properties: + totalRegisteredCustomers: + type: "integer" + customersPerNationality: + type: "array" + items: + $ref: "#/definitions/CustomersPerNationality" + customersPerGender: + type: "array" + items: + $ref: "#/definitions/CustomersPerGender" + customersPerAgeRange: + type: "array" + items: + $ref: "#/definitions/CustomersPerAgeRange" + numberOfSearchesPerWord: + type: "array" + items: + $ref: "#/definitions/NumberOfSearchesPerWord" + menusWithRatings: + type: "array" + items: + $ref: "#/definitions/MenuForStatistics" + example: + totalRegisteredCustomers: 120 + customersPerNationality: + - nationality: "Italy" + numberOfCustomers: 10 + - nationality: "French" + numberOfCustomers: 8 + - nationality: "Croatian" + numberOfCustomers: 11 + customersPerGender: + - gender: "Male" + numberOfCustomers: 10 + - gender: "Female" + numberOfCustomers: 8 + - gender: "Other" + numberOfCustomers: 3 + customersPerAgeRange: + - ageRange: "18-25" + numberOfCustomers: 34 + - ageRange: "25-35" + numberOfCustomers: 28 + - ageRange: "35-50" + numberOfCustomers: 15 + numberOfSearchesPerWord: + - word: "Pasta" + numberOfSearches: 51 + - word: "Pizza" + numberOfSearches: 83 + - word: "Spaghetti" + numberOfSearches: 31 + menusWithRatings: + - menuName: "New menu" + rating: 3.399999999999999911182158029987476766109466552734375 + - menuName: "Dinner menu" + rating: 4.20000000000000017763568394002504646778106689453125 + - menuName: "Menu of the day" + rating: 5 + - menuName: "Launch menu" + rating: 2 + - menuName: "Exotic menu" + rating: 3.899999999999999911182158029987476766109466552734375 + CustomersPerNationality: + type: "object" + properties: + nationality: + type: "string" + numberOfCustomers: + type: "integer" + CustomersPerGender: + type: "object" + properties: + gender: + type: "string" + numberOfCustomers: + type: "integer" + CustomersPerAgeRange: + type: "object" + properties: + ageRange: + type: "string" + numberOfCustomers: + type: "integer" + NumberOfSearchesPerWord: + type: "object" + properties: + word: + type: "string" + numberOfSearches: + type: "integer" + MenuForStatistics: + type: "object" + properties: + menuName: + type: "string" + rating: + type: "number" + StatisticsOfNationality: + type: "object" + properties: + totalRegisteredCustomers: + type: "integer" + customersPerGender: + type: "array" + items: + $ref: "#/definitions/CustomersPerGender" + customersPerAgeRange: + type: "array" + items: + $ref: "#/definitions/CustomersPerAgeRange" + numberOfSearchesPerWord: + type: "array" + items: + $ref: "#/definitions/NumberOfSearchesPerWord" + example: + totalRegisteredCustomers: 120 + customersPerGender: + - gender: "Male" + numberOfCustomers: 10 + - gender: "Female" + numberOfCustomers: 8 + - gender: "Other" + numberOfCustomers: 3 + customersPerAgeRange: + - ageRange: "18-25" + numberOfCustomers: 34 + - ageRange: "25-35" + numberOfCustomers: 28 + - ageRange: "35-50" + numberOfCustomers: 15 + numberOfSearchesPerWord: + - word: "Pasta" + numberOfSearches: 51 + - word: "Pizza" + numberOfSearches: 83 + - word: "Spaghetti" + numberOfSearches: 31 MenuAndRestaurant_restaurantData: type: "object" properties: @@ -1624,6 +2757,15 @@ definitions: type: "string" distance: type: "number" + MenuRetrievedToCustomer_restaurant_openingHours: + type: "object" + properties: + day: + type: "string" + openTime: + type: "string" + closeTime: + type: "string" MenuRetrievedToCustomer_restaurant: type: "object" properties: @@ -1639,6 +2781,10 @@ definitions: type: "number" longitude: type: "number" + openingHours: + type: "array" + items: + $ref: "#/definitions/MenuRetrievedToCustomer_restaurant_openingHours" PendingReview_menuItemNames: type: "object" properties: diff --git a/backendStub/controllers/Customer.js b/backendStub/controllers/Customer.js index 6f90497d..ecde73e8 100644 --- a/backendStub/controllers/Customer.js +++ b/backendStub/controllers/Customer.js @@ -3,6 +3,16 @@ var utils = require('../utils/writer.js'); var Customer = require('../service/CustomerService'); +module.exports.apiUserCustomerDELETE = function apiUserCustomerDELETE (req, res, next) { + Customer.apiUserCustomerDELETE() + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.apiUserCustomerGET = function apiUserCustomerGET (req, res, next) { Customer.apiUserCustomerGET() .then(function (response) { @@ -25,6 +35,28 @@ module.exports.apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET = function a }); }; +module.exports.apiUserCustomerPUT = function apiUserCustomerPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Customer.apiUserCustomerPUT(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserCustomerPasswordPUT = function apiUserCustomerPasswordPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Customer.apiUserCustomerPasswordPUT(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.apiUserCustomerReviewReviewIDDELETE = function apiUserCustomerReviewReviewIDDELETE (req, res, next) { var reviewID = req.swagger.params['reviewID'].value; Customer.apiUserCustomerReviewReviewIDDELETE(reviewID) diff --git a/backendStub/controllers/Emilio.js b/backendStub/controllers/Emilio.js index 8226b5ce..ac2d2484 100644 --- a/backendStub/controllers/Emilio.js +++ b/backendStub/controllers/Emilio.js @@ -14,6 +14,48 @@ module.exports.addMenu = function addMenu (req, res, next) { }); }; +module.exports.apiUserOwnerDELETE = function apiUserOwnerDELETE (req, res, next) { + Emilio.apiUserOwnerDELETE() + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserOwnerGET = function apiUserOwnerGET (req, res, next) { + Emilio.apiUserOwnerGET() + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserOwnerPUT = function apiUserOwnerPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Emilio.apiUserOwnerPUT(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserOwnerPasswordPUT = function apiUserOwnerPasswordPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Emilio.apiUserOwnerPasswordPUT(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.apiUserOwnerTagGET = function apiUserOwnerTagGET (req, res, next) { Emilio.apiUserOwnerTagGET() .then(function (response) { diff --git a/backendStub/controllers/Frikk.js b/backendStub/controllers/Frikk.js index 3e79995a..04b695bb 100644 --- a/backendStub/controllers/Frikk.js +++ b/backendStub/controllers/Frikk.js @@ -3,6 +3,16 @@ var utils = require('../utils/writer.js'); var Frikk = require('../service/FrikkService'); +module.exports.apiUserCustomerDELETE = function apiUserCustomerDELETE (req, res, next) { + Frikk.apiUserCustomerDELETE() + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET = function apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET (req, res, next) { var menuID = req.swagger.params['menuID'].value; var menuItemID = req.swagger.params['menuItemID'].value; @@ -15,6 +25,28 @@ module.exports.apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET = function a }); }; +module.exports.apiUserCustomerPUT = function apiUserCustomerPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Frikk.apiUserCustomerPUT(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserCustomerReviewReviewIDDELETE = function apiUserCustomerReviewReviewIDDELETE (req, res, next) { + var reviewID = req.swagger.params['reviewID'].value; + Frikk.apiUserCustomerReviewReviewIDDELETE(reviewID) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.getMenuCustomer = function getMenuCustomer (req, res, next) { var menuID = req.swagger.params['menuID'].value; Frikk.getMenuCustomer(menuID) @@ -66,15 +98,3 @@ module.exports.searchByMenuItem = function searchByMenuItem (req, res, next) { utils.writeJson(res, response); }); }; - -module.exports.submitReview = function submitReview (req, res, next) { - var menuID = req.swagger.params['menuID'].value; - var body = req.swagger.params['body'].value; - Frikk.submitReview(menuID,body) - .then(function (response) { - utils.writeJson(res, response); - }) - .catch(function (response) { - utils.writeJson(res, response); - }); -}; diff --git a/backendStub/controllers/Marin.js b/backendStub/controllers/Marin.js index f9014248..26b38b07 100644 --- a/backendStub/controllers/Marin.js +++ b/backendStub/controllers/Marin.js @@ -25,9 +25,9 @@ module.exports.apiUserCustomerGET = function apiUserCustomerGET (req, res, next) }); }; -module.exports.apiUserCustomerReviewReviewIDDELETE = function apiUserCustomerReviewReviewIDDELETE (req, res, next) { - var reviewID = req.swagger.params['reviewID'].value; - Marin.apiUserCustomerReviewReviewIDDELETE(reviewID) +module.exports.apiUserCustomerPasswordPUT = function apiUserCustomerPasswordPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Marin.apiUserCustomerPasswordPUT(body) .then(function (response) { utils.writeJson(res, response); }) @@ -58,6 +58,17 @@ module.exports.apiUserOwnerRestaurantReviewReviewIDPOST = function apiUserOwnerR }); }; +module.exports.createConsultant = function createConsultant (req, res, next) { + var body = req.swagger.params['body'].value; + Marin.createConsultant(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.deleteMenuItem = function deleteMenuItem (req, res, next) { var menuID = req.swagger.params['menuID'].value; var menuItemID = req.swagger.params['menuItemID'].value; @@ -83,6 +94,50 @@ module.exports.editMenuItem = function editMenuItem (req, res, next) { }); }; +module.exports.getStatisticOfNationality = function getStatisticOfNationality (req, res, next) { + var nationalityName = req.swagger.params['nationalityName'].value; + Marin.getStatisticOfNationality(nationalityName) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.getStatistics = function getStatistics (req, res, next) { + Marin.getStatistics() + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.loginConsultant = function loginConsultant (req, res, next) { + var body = req.swagger.params['body'].value; + Marin.loginConsultant(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.submitReview = function submitReview (req, res, next) { + var menuID = req.swagger.params['menuID'].value; + var body = req.swagger.params['body'].value; + Marin.submitReview(menuID,body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.uploadImage = function uploadImage (req, res, next) { Marin.uploadImage() .then(function (response) { diff --git a/backendStub/controllers/Owner.js b/backendStub/controllers/Owner.js index 4d9a365a..3d37320d 100644 --- a/backendStub/controllers/Owner.js +++ b/backendStub/controllers/Owner.js @@ -26,6 +26,48 @@ module.exports.addMenuItem = function addMenuItem (req, res, next) { }); }; +module.exports.apiUserOwnerDELETE = function apiUserOwnerDELETE (req, res, next) { + Owner.apiUserOwnerDELETE() + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserOwnerGET = function apiUserOwnerGET (req, res, next) { + Owner.apiUserOwnerGET() + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserOwnerPUT = function apiUserOwnerPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Owner.apiUserOwnerPUT(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + +module.exports.apiUserOwnerPasswordPUT = function apiUserOwnerPasswordPUT (req, res, next) { + var body = req.swagger.params['body'].value; + Owner.apiUserOwnerPasswordPUT(body) + .then(function (response) { + utils.writeJson(res, response); + }) + .catch(function (response) { + utils.writeJson(res, response); + }); +}; + module.exports.apiUserOwnerRestaurantReviewGET = function apiUserOwnerRestaurantReviewGET (req, res, next) { Owner.apiUserOwnerRestaurantReviewGET() .then(function (response) { diff --git a/backendStub/package-lock.json b/backendStub/package-lock.json index ef65a88f..407212cc 100644 --- a/backendStub/package-lock.json +++ b/backendStub/package-lock.json @@ -5,25 +5,25 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", - "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.0.tgz", + "integrity": "sha512-AN2IR/wCUYsM+PdErq6Bp3RFTXl8W0p9Nmymm7zkpsCmh+r/YYcckaCGpU8Q/mEKmST19kkGRaG42A/jxOWwBA==", "requires": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.8.0" } }, "@babel/helper-module-imports": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.7.4.tgz", - "integrity": "sha512-dGcrX6K9l8258WFjyDLJwuVKxR4XZfU0/vTUgOQYWEnRD8mgr+p4d6fCUMq/ys0h4CCt/S5JhbvtyErjWouAUQ==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.8.0.tgz", + "integrity": "sha512-ylY9J6ZxEcjmJaJ4P6aVs/fZdrZVctCGnxxfYXwCnSMapqd544zT8lWK2qI/vBPjE5gS0o2jILnH+AkpsPauEQ==", "requires": { - "@babel/types": "^7.7.4" + "@babel/types": "^7.8.0" } }, "@babel/highlight": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", - "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.0.tgz", + "integrity": "sha512-OsdTJbHlPtIk2mmtwXItYrdmalJ8T0zpVzNAbKSkHshuywj7zb29Y09McV/jQsQunc/nEyHiPV2oy9llYMLqxw==", "requires": { "chalk": "^2.0.0", "esutils": "^2.0.2", @@ -31,17 +31,17 @@ } }, "@babel/runtime": { - "version": "7.7.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.6.tgz", - "integrity": "sha512-BWAJxpNVa0QlE5gZdWjSxXtemZyZ9RmrmVozxt3NUXeZhVIJ5ANyqmMc0JDrivBZyxUuQvFxlvH4OWWOogGfUw==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.0.tgz", + "integrity": "sha512-Z7ti+HB0puCcLmFE3x90kzaVgbx6TRrYIReaygW6EkBEnJh1ajS4/inhF7CypzWeDV3NFl1AfWj0eMtdihojxw==", "requires": { "regenerator-runtime": "^0.13.2" } }, "@babel/types": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.4.tgz", - "integrity": "sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.0.tgz", + "integrity": "sha512-1RF84ehyx9HH09dMMwGWl3UTWlVoCPtqqJPjGuC4JzMe1ZIVDJ2DT8mv3cPv/A7veLD6sgR7vi95lJqm+ZayIg==", "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -49,85 +49,85 @@ } }, "@emotion/cache": { - "version": "10.0.19", - "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-10.0.19.tgz", - "integrity": "sha512-BoiLlk4vEsGBg2dAqGSJu0vJl/PgVtCYLBFJaEO8RmQzPugXewQCXZJNXTDFaRlfCs0W+quesayav4fvaif5WQ==", + "version": "10.0.27", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-10.0.27.tgz", + "integrity": "sha512-Zp8BEpbMunFsTcqAK4D7YTm3MvCp1SekflSLJH8lze2fCcSZ/yMkXHo8kb3t1/1Tdd3hAqf3Fb7z9VZ+FMiC9w==", "requires": { - "@emotion/sheet": "0.9.3", - "@emotion/stylis": "0.8.4", - "@emotion/utils": "0.11.2", - "@emotion/weak-memoize": "0.2.4" + "@emotion/sheet": "0.9.4", + "@emotion/stylis": "0.8.5", + "@emotion/utils": "0.11.3", + "@emotion/weak-memoize": "0.2.5" } }, "@emotion/core": { - "version": "10.0.22", - "resolved": "https://registry.npmjs.org/@emotion/core/-/core-10.0.22.tgz", - "integrity": "sha512-7eoP6KQVUyOjAkE6y4fdlxbZRA4ILs7dqkkm6oZUJmihtHv0UBq98VgPirq9T8F9K2gKu0J/au/TpKryKMinaA==", + "version": "10.0.27", + "resolved": "https://registry.npmjs.org/@emotion/core/-/core-10.0.27.tgz", + "integrity": "sha512-XbD5R36pVbohQMnKfajHv43g8EbN4NHdF6Zh9zg/C0nr0jqwOw3gYnC07Xj3yG43OYSRyrGsoQ5qPwc8ycvLZw==", "requires": { "@babel/runtime": "^7.5.5", - "@emotion/cache": "^10.0.17", - "@emotion/css": "^10.0.22", - "@emotion/serialize": "^0.11.12", - "@emotion/sheet": "0.9.3", - "@emotion/utils": "0.11.2" + "@emotion/cache": "^10.0.27", + "@emotion/css": "^10.0.27", + "@emotion/serialize": "^0.11.15", + "@emotion/sheet": "0.9.4", + "@emotion/utils": "0.11.3" } }, "@emotion/css": { - "version": "10.0.22", - "resolved": "https://registry.npmjs.org/@emotion/css/-/css-10.0.22.tgz", - "integrity": "sha512-8phfa5mC/OadBTmGpMpwykIVH0gFCbUoO684LUkyixPq4F1Wwri7fK5Xlm8lURNBrd2TuvTbPUGxFsGxF9UacA==", + "version": "10.0.27", + "resolved": "https://registry.npmjs.org/@emotion/css/-/css-10.0.27.tgz", + "integrity": "sha512-6wZjsvYeBhyZQYNrGoR5yPMYbMBNEnanDrqmsqS1mzDm1cOTu12shvl2j4QHNS36UaTE0USIJawCH9C8oW34Zw==", "requires": { - "@emotion/serialize": "^0.11.12", - "@emotion/utils": "0.11.2", - "babel-plugin-emotion": "^10.0.22" + "@emotion/serialize": "^0.11.15", + "@emotion/utils": "0.11.3", + "babel-plugin-emotion": "^10.0.27" } }, "@emotion/hash": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.7.3.tgz", - "integrity": "sha512-14ZVlsB9akwvydAdaEnVnvqu6J2P6ySv39hYyl/aoB6w/V+bXX0tay8cF6paqbgZsN2n5Xh15uF4pE+GvE+itw==" + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.7.4.tgz", + "integrity": "sha512-fxfMSBMX3tlIbKUdtGKxqB1fyrH6gVrX39Gsv3y8lRYKUqlgDt3UMqQyGnR1bQMa2B8aGnhLZokZgg8vT0Le+A==" }, "@emotion/memoize": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.3.tgz", - "integrity": "sha512-2Md9mH6mvo+ygq1trTeVp2uzAKwE2P7In0cRpD/M9Q70aH8L+rxMLbb3JCN2JoSWsV2O+DdFjfbbXoMoLBczow==" + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", + "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==" }, "@emotion/serialize": { - "version": "0.11.14", - "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-0.11.14.tgz", - "integrity": "sha512-6hTsySIuQTbDbv00AnUO6O6Xafdwo5GswRlMZ5hHqiFx+4pZ7uGWXUQFW46Kc2taGhP89uXMXn/lWQkdyTosPA==", - "requires": { - "@emotion/hash": "0.7.3", - "@emotion/memoize": "0.7.3", - "@emotion/unitless": "0.7.4", - "@emotion/utils": "0.11.2", + "version": "0.11.15", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-0.11.15.tgz", + "integrity": "sha512-YE+qnrmGwyR+XB5j7Bi+0GT1JWsdcjM/d4POu+TXkcnrRs4RFCCsi3d/Ebf+wSStHqAlTT2+dfd+b9N9EO2KBg==", + "requires": { + "@emotion/hash": "0.7.4", + "@emotion/memoize": "0.7.4", + "@emotion/unitless": "0.7.5", + "@emotion/utils": "0.11.3", "csstype": "^2.5.7" } }, "@emotion/sheet": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-0.9.3.tgz", - "integrity": "sha512-c3Q6V7Df7jfwSq5AzQWbXHa5soeE4F5cbqi40xn0CzXxWW9/6Mxq48WJEtqfWzbZtW9odZdnRAkwCQwN12ob4A==" + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-0.9.4.tgz", + "integrity": "sha512-zM9PFmgVSqBw4zL101Q0HrBVTGmpAxFZH/pYx/cjJT5advXguvcgjHFTCaIO3enL/xr89vK2bh0Mfyj9aa0ANA==" }, "@emotion/stylis": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.4.tgz", - "integrity": "sha512-TLmkCVm8f8gH0oLv+HWKiu7e8xmBIaokhxcEKPh1m8pXiV/akCiq50FvYgOwY42rjejck8nsdQxZlXZ7pmyBUQ==" + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz", + "integrity": "sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==" }, "@emotion/unitless": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.4.tgz", - "integrity": "sha512-kBa+cDHOR9jpRJ+kcGMsysrls0leukrm68DmFQoMIWQcXdr2cZvyvypWuGYT7U+9kAExUE7+T7r6G3C3A6L8MQ==" + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz", + "integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==" }, "@emotion/utils": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-0.11.2.tgz", - "integrity": "sha512-UHX2XklLl3sIaP6oiMmlVzT0J+2ATTVpf0dHQVyPJHTkOITvXfaSqnRk6mdDhV9pR8T/tHc3cex78IKXssmzrA==" + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-0.11.3.tgz", + "integrity": "sha512-0o4l6pZC+hI88+bzuaX/6BgOvQVhbt2PfmxauVaYOGgbsAw14wdKyvMCZXnsnsHys94iadcF+RG/wZyx6+ZZBw==" }, "@emotion/weak-memoize": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.4.tgz", - "integrity": "sha512-6PYY5DVdAY1ifaQW6XYTnOMihmBVT27elqSjEoodchsGjzYlEsTQMcEhSud99kVawatyTZRTiVkJ/c6lwbQ7nA==" + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz", + "integrity": "sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==" }, "@types/parse-json": { "version": "4.0.0", @@ -169,14 +169,14 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "babel-plugin-emotion": { - "version": "10.0.23", - "resolved": "https://registry.npmjs.org/babel-plugin-emotion/-/babel-plugin-emotion-10.0.23.tgz", - "integrity": "sha512-1JiCyXU0t5S2xCbItejCduLGGcKmF3POT0Ujbexog2MI4IlRcIn/kWjkYwCUZlxpON0O5FC635yPl/3slr7cKQ==", + "version": "10.0.27", + "resolved": "https://registry.npmjs.org/babel-plugin-emotion/-/babel-plugin-emotion-10.0.27.tgz", + "integrity": "sha512-SUNYcT4FqhOqvwv0z1oeYhqgheU8qrceLojuHyX17ngo7WtWqN5I9l3IGHzf21Xraj465CVzF4IvOlAF+3ed0A==", "requires": { "@babel/helper-module-imports": "^7.0.0", - "@emotion/hash": "0.7.3", - "@emotion/memoize": "0.7.3", - "@emotion/serialize": "^0.11.14", + "@emotion/hash": "0.7.4", + "@emotion/memoize": "0.7.4", + "@emotion/serialize": "^0.11.15", "babel-plugin-macros": "^2.0.0", "babel-plugin-syntax-jsx": "^6.18.0", "convert-source-map": "^1.5.0", @@ -375,9 +375,9 @@ } }, "csstype": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.7.tgz", - "integrity": "sha512-9Mcn9sFbGBAdmimWb2gLVDtFJzeKtDGIr76TUqmjZrw9LFXBMSU70lcs+C0/7fyCd6iBDqmksUcCOUIkisPHsQ==" + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.8.tgz", + "integrity": "sha512-msVS9qTuMT5zwAGCVm4mxfrZ18BNc6Csd0oJAtiFMZ1FAx1CCvy2+5MDmYoix63LM/6NDbNtodCiGYGmFgO0dA==" }, "debug": { "version": "2.6.9", @@ -896,16 +896,16 @@ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.42.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", - "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==" + "version": "1.43.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" }, "mime-types": { - "version": "2.1.25", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", - "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", + "version": "2.1.26", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", + "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", "requires": { - "mime-db": "1.42.0" + "mime-db": "1.43.0" } }, "minimist": { @@ -1116,9 +1116,9 @@ } }, "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -1135,9 +1135,9 @@ "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==" }, "resolve": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz", - "integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==", + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.2.tgz", + "integrity": "sha512-EjlOBLBO1kxsUxsKjLt7TAECyKW6fOh1VRkykQkKGzcBbjjPIxBqGh0jf7GJ3k/f5mxMqW3htMD3WdTUVtW8HQ==", "requires": { "path-parse": "^1.0.6" } diff --git a/backendStub/service/CustomerService.js b/backendStub/service/CustomerService.js index f4e85187..be16308a 100644 --- a/backendStub/service/CustomerService.js +++ b/backendStub/service/CustomerService.js @@ -1,18 +1,34 @@ 'use strict'; +/** + * Delete profile of the customer + * Delete profile of the logged in customer. + * + * no response value expected for this operation + **/ +exports.apiUserCustomerDELETE = function() { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + /** * Return profile data of the customer - * Return own data of the logged in customer. This endpoints should be used when the frontend has to visualize the profile of the customer. + * Return own data of the logged in customer. This endpoint should be used when the frontend has to visualize the profile of the customer. * - * returns CustomerUsernameAndEmail + * returns CustomerData **/ exports.apiUserCustomerGET = function() { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { "username" : "emilio_imperiali", - "email" : "emilioimperiali@mail.it" + "email" : "emilioimperiali@mail.it", + "gender" : "Male", + "ageRange" : "24-34", + "nationality" : "Italy" }; if (Object.keys(examples).length > 0) { resolve(examples[Object.keys(examples)[0]]); @@ -25,7 +41,7 @@ exports.apiUserCustomerGET = function() { /** * Return all the reviews of the menu item - * Return all the reviews of the menu item with given menuItemID contained in the menu with given menuID. + * Return all the reviews of the menu item with given menuItemID contained in the menu with given menuID. If there are no reviews, an empty array is sent (with code 200, not 404). * * menuID Integer ID of the menu * menuItemID Integer ID of the menu item @@ -54,9 +70,49 @@ exports.apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET = function(menuID,m } +/** + * Edit profile data of the customer + * Edit profile data of the logged in customer. All the customer data must be sent with this endpoint, even if it's not changed (in that case the fields must contain the current values). The password can't be changed through this endpoint, but the dedicated one should be used instead. Valid values for Gender are 'Male/Female/Other'. The username, the name and the surname can't be changed. The age is a range, for example '24-34'. + * + * body CustomerEditData New data of the customer + * returns CustomerData + **/ +exports.apiUserCustomerPUT = function(body) { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "username" : "emilio_imperiali", + "email" : "emilioimperiali@mail.it", + "gender" : "Male", + "ageRange" : "24-34", + "nationality" : "Italy" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Change the password of the customer + * Change the password of the logged in customer. The current password must be provided, for security reasons. A 400 is sent back if the current password provided doesn't match, and the password change is not performed. + * + * body PasswordChange New and current passwords + * no response value expected for this operation + **/ +exports.apiUserCustomerPasswordPUT = function(body) { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + /** * Delete a review - * Delete the review with the given reviewID. This will also delete the reviews of the menu items associated to the review with given reviewID. + * Delete the review with the given reviewID. This will also delete the reviews of the menu items associated to the review with given reviewID. The review must belong to the authenticated customer, otherwise a 403 error will be sent. * * reviewID Integer ID of the review * no response value expected for this operation @@ -93,7 +149,7 @@ exports.createCustomer = function(body) { /** * Return all the menu items of given menu - * Return all the names of the restaurants and their restaurantIDs. + * Return all the menu items of given menu. In case no menu item is found, an empty array is sent (with code 200, not 404). * * menuID Integer ID of the menu * returns List @@ -134,7 +190,16 @@ exports.getMenuCustomer = function(menuID) { "city" : "Milan", "country" : "Italy", "latitude" : 45.4688346, - "longitude" : 9.2234114 + "longitude" : 9.2234114, + "openingHours" : [ { + "day" : "Wednesday", + "openTime" : "12.30", + "closeTime" : "14.30" + }, { + "day" : "Saturday", + "openTime" : "12.00", + "closeTime" : "15.00" + } ] }, "menuName" : "Emilio's menu of the day", "description" : "Our special menu of today", @@ -198,7 +263,7 @@ exports.getMenuCustomer = function(menuID) { /** * Return all the menus of given restaurant - * Return all the names of the menus of the restaurant and their menuIDs. + * Return all the names of the menus of the restaurant and their menuIDs. Only menus that contain at least one menu item are actually sent. In case no menu is found, an empty array is sent (with code 200, not 404). * * restaurantID Integer ID of the restaurant * returns List @@ -224,7 +289,7 @@ exports.getMenusOfRestaurant = function(restaurantID) { /** * Return all the reviews of the customer - * Return all the reviews of the customer, with their reviewIDs and their status (accepted/refused/pending). Returns an empty array if no review is found. + * Return all the reviews of the customer, with their reviewIDs and their status (accepted/refused/pending). Returns an empty array if no review is found (with code 200, not 404). * * returns List **/ @@ -243,10 +308,12 @@ exports.getOwnReviews = function() { "status" : "accepted", "menuItemsReviews" : [ { "menuItemID" : 34, + "menuItemName" : "Pizza margherita", "rating" : 4.1, "content" : "That was delicious!" }, { "menuItemID" : 58, + "menuItemName" : "Pasta alla carbonara with cream", "rating" : 0.5, "content" : "It was an insult, I will never eat that trash again in my whole life" } ] @@ -262,10 +329,12 @@ exports.getOwnReviews = function() { "status" : "accepted", "menuItemsReviews" : [ { "menuItemID" : 35, + "menuItemName" : "Pizza margherita", "rating" : 4.1, "content" : "That was delicious!" }, { "menuItemID" : 59, + "menuItemName" : "Pasta alla carbonara with cream", "rating" : 0.5, "content" : "It was an insult, I will never eat that trash again in my whole life" } ] @@ -281,7 +350,7 @@ exports.getOwnReviews = function() { /** * Return all the restaurants - * Return all the names of the restaurants and their restaurantIDs. + * Return all the names of the restaurants and their restaurantIDs. Only the restaurants that actually contain menus are actually sent, because a menu has to be reviewed, so it wouldn't make sense to send restaurant with no menus. Moreover, at least one menu of the restaurant must have at least one menu item inside. In case no restaurant is found, an empty array is sent (with code 200, not 404). * * returns List **/ @@ -306,7 +375,7 @@ exports.getRestaurants = function() { /** * Search by menu item - * Returns all the menus with given menu item (dish/drink) with menuID. It also returns the names of the associated restaurants with restaurantID. The menu items inside every menu are not returned. It will be needed to access the endpoint /api/user/customer/menu/{menuID} to get the menu items of a specific menu (the menuID passed can be obtained from the response of this endpoint, since it returns the menuID of every menu). + * Returns all the menus with given menu item (dish/drink) with menuID. It also returns the names of the associated restaurants with restaurantID. The menu items inside every menu are not returned. It will be needed to access the endpoint /api/user/customer/menu/{menuID} to get the menu items of a specific menu (the menuID passed can be obtained from the response of this endpoint, since it returns the menuID of every menu). The customer can be not logged in, if that is the case then the authentication token must be sent with a null value. The authentication in this endpoint is necessary to collect the search done by the customer and use it to collect statistics. * * menuItemName String Name of the desired menu item * returns List diff --git a/backendStub/service/EmilioService.js b/backendStub/service/EmilioService.js index 2f146f6a..dbf83a8b 100644 --- a/backendStub/service/EmilioService.js +++ b/backendStub/service/EmilioService.js @@ -3,7 +3,7 @@ /** * Add an empty menu to a restaurant - * Add a menu to a restaurant of a restaurant owner, which needs to be logged in. The menuItems are not meant to be added to the menu through this endpoint. + * Add a menu to a restaurant of a restaurant owner, which needs to be logged in. The menuItems are not meant to be added to the menu through this endpoint. The tags of the menu must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * body MenuWithoutItems Menu data * returns MenuID @@ -23,9 +23,85 @@ exports.addMenu = function(body) { } +/** + * Delete profile of the owner + * Delete profile of the logged in owner. + * + * no response value expected for this operation + **/ +exports.apiUserOwnerDELETE = function() { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + +/** + * Return profile data of the owner + * Return own data of logged in owner. This endpoint should be used when the frontend has to visualize the profile of the owner. + * + * returns OwnerData + **/ +exports.apiUserOwnerGET = function() { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "email" : "john.doe@gmail.com", + "username" : "johndoe", + "name" : "John", + "surname" : "Doe" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Edit profile data of the owner + * Edit profile data of the logged in owner. The password can't be changed through this endpoint, but the dedicated one should be used instead. The username can't be changed. + * + * body OwnerEditData New data of the owner + * returns OwnerData + **/ +exports.apiUserOwnerPUT = function(body) { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "email" : "john.doe@gmail.com", + "username" : "johndoe", + "name" : "John", + "surname" : "Doe" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Change the password of the owner + * Change the password of the logged in owner. The current password must be provided, for security reasons. A 400 is sent back if the current password provided doesn't match, and the password change is not performed. + * + * body PasswordChange New and current passwords + * no response value expected for this operation + **/ +exports.apiUserOwnerPasswordPUT = function(body) { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + /** * Return all the available tags - * When a restaurant owner is creating a menu or a menu item, he/she needs to know the list of the available tags. + * When a restaurant owner is creating a menu or a menu item, he/she needs to know the list of the available tags. If there are no tags, an empty array is sent (with code 200, not 404). * * returns List **/ @@ -44,7 +120,7 @@ exports.apiUserOwnerTagGET = function() { /** * Delete a menu - * Delete a menu of the restaurant. Authentication is required + * Delete a menu of the restaurant. Authentication is required. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu to be edited * no response value expected for this operation @@ -58,7 +134,7 @@ exports.deleteMenu = function(menuID) { /** * Edit a menu's information (not its items) - * Edit a given menu (but not its menuItems). To identify the menu, the menuID needs to be given. Authentication is required. + * Edit a given menu (but not its menuItems). To identify the menu, the menuID needs to be given. Authentication is required. The tags of the menu must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu to be edited * body MenuWithoutItems Data of the menu to be saved @@ -81,7 +157,7 @@ exports.editMenu = function(menuID,body) { /** * Edit restaurant's information - * Edit the information of the restaurant + * Edit the information of the restaurant. It's needed that the restaurant already exists, otherwise a 404 error will be sent. The POST endpoint should be used to create it. * * body Restaurant Restaurant data * returns RestaurantID @@ -103,7 +179,7 @@ exports.editRestaurant = function(body) { /** * Return all the menu items of given menu - * Return all the names of the restaurants and their restaurantIDs. + * Return all the menu items of given menu. In case no menu item is found, an empty array is sent (with code 200, not 404). * * menuID Integer ID of the menu * returns List @@ -129,7 +205,7 @@ exports.getItemsOfMenu = function(menuID) { /** * Return all the menus of given restaurant - * Return all the names of the menus of the restaurant and their menuIDs. + * Return all the names of the menus of the restaurant and their menuIDs. Only menus that contain at least one menu item are actually sent. In case no menu is found, an empty array is sent (with code 200, not 404). * * restaurantID Integer ID of the restaurant * returns List @@ -155,7 +231,7 @@ exports.getMenusOfRestaurant = function(restaurantID) { /** * Return all the restaurants - * Return all the names of the restaurants and their restaurantIDs. + * Return all the names of the restaurants and their restaurantIDs. Only the restaurants that actually contain menus are actually sent, because a menu has to be reviewed, so it wouldn't make sense to send restaurant with no menus. Moreover, at least one menu of the restaurant must have at least one menu item inside. In case no restaurant is found, an empty array is sent (with code 200, not 404). * * returns List **/ diff --git a/backendStub/service/FrikkService.js b/backendStub/service/FrikkService.js index 1110b037..a399ac0e 100644 --- a/backendStub/service/FrikkService.js +++ b/backendStub/service/FrikkService.js @@ -1,9 +1,22 @@ 'use strict'; +/** + * Delete profile of the customer + * Delete profile of the logged in customer. + * + * no response value expected for this operation + **/ +exports.apiUserCustomerDELETE = function() { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + /** * Return all the reviews of the menu item - * Return all the reviews of the menu item with given menuItemID contained in the menu with given menuID. + * Return all the reviews of the menu item with given menuItemID contained in the menu with given menuID. If there are no reviews, an empty array is sent (with code 200, not 404). * * menuID Integer ID of the menu * menuItemID Integer ID of the menu item @@ -32,6 +45,46 @@ exports.apiUserCustomerMenuMenuIDMenuItemMenuItemIDReviewGET = function(menuID,m } +/** + * Edit profile data of the customer + * Edit profile data of the logged in customer. All the customer data must be sent with this endpoint, even if it's not changed (in that case the fields must contain the current values). The password can't be changed through this endpoint, but the dedicated one should be used instead. Valid values for Gender are 'Male/Female/Other'. The username, the name and the surname can't be changed. The age is a range, for example '24-34'. + * + * body CustomerEditData New data of the customer + * returns CustomerData + **/ +exports.apiUserCustomerPUT = function(body) { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "username" : "emilio_imperiali", + "email" : "emilioimperiali@mail.it", + "gender" : "Male", + "ageRange" : "24-34", + "nationality" : "Italy" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Delete a review + * Delete the review with the given reviewID. This will also delete the reviews of the menu items associated to the review with given reviewID. The review must belong to the authenticated customer, otherwise a 403 error will be sent. + * + * reviewID Integer ID of the review + * no response value expected for this operation + **/ +exports.apiUserCustomerReviewReviewIDDELETE = function(reviewID) { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + /** * Return data of a specific menu * Returns all the data about the menu with given menuID, even the menu items inside it. The photos of the menu items are saved in the Amazon s3 storage, so the links to the cloud storage are also returned. The frontend will directly download them from the cloud storage, they won't be sent by the backend with this endpoint. @@ -49,7 +102,16 @@ exports.getMenuCustomer = function(menuID) { "city" : "Milan", "country" : "Italy", "latitude" : 45.4688346, - "longitude" : 9.2234114 + "longitude" : 9.2234114, + "openingHours" : [ { + "day" : "Wednesday", + "openTime" : "12.30", + "closeTime" : "14.30" + }, { + "day" : "Saturday", + "openTime" : "12.00", + "closeTime" : "15.00" + } ] }, "menuName" : "Emilio's menu of the day", "description" : "Our special menu of today", @@ -113,7 +175,7 @@ exports.getMenuCustomer = function(menuID) { /** * Return all the menus of the restaurant - * Return all the menus of the restaurant. Since authentication is required, the backend is able to get which restaurant is involved from the authentication token. + * Return all the menus of the restaurant. Since authentication is required, the backend is able to get which restaurant is involved from the authentication token. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * returns List **/ @@ -282,7 +344,7 @@ exports.getOwnMenus = function() { /** * Return all the reviews of the customer - * Return all the reviews of the customer, with their reviewIDs and their status (accepted/refused/pending). Returns an empty array if no review is found. + * Return all the reviews of the customer, with their reviewIDs and their status (accepted/refused/pending). Returns an empty array if no review is found (with code 200, not 404). * * returns List **/ @@ -301,10 +363,12 @@ exports.getOwnReviews = function() { "status" : "accepted", "menuItemsReviews" : [ { "menuItemID" : 34, + "menuItemName" : "Pizza margherita", "rating" : 4.1, "content" : "That was delicious!" }, { "menuItemID" : 58, + "menuItemName" : "Pasta alla carbonara with cream", "rating" : 0.5, "content" : "It was an insult, I will never eat that trash again in my whole life" } ] @@ -320,10 +384,12 @@ exports.getOwnReviews = function() { "status" : "accepted", "menuItemsReviews" : [ { "menuItemID" : 34, + "menuItemName" : "Pizza margherita", "rating" : 4.1, "content" : "That was delicious!" }, { "menuItemID" : 58, + "menuItemName" : "Pasta alla carbonara with cream", "rating" : 0.5, "content" : "It was an insult, I will never eat that trash again in my whole life" } ] @@ -373,7 +439,7 @@ exports.getRestaurant = function() { /** * Search by menu item - * Returns all the menus with given menu item (dish/drink) with menuID. It also returns the names of the associated restaurants with restaurantID. The menu items inside every menu are not returned. It will be needed to access the endpoint /api/user/customer/menu/{menuID} to get the menu items of a specific menu (the menuID passed can be obtained from the response of this endpoint, since it returns the menuID of every menu). + * Returns all the menus with given menu item (dish/drink) with menuID. It also returns the names of the associated restaurants with restaurantID. The menu items inside every menu are not returned. It will be needed to access the endpoint /api/user/customer/menu/{menuID} to get the menu items of a specific menu (the menuID passed can be obtained from the response of this endpoint, since it returns the menuID of every menu). The customer can be not logged in, if that is the case then the authentication token must be sent with a null value. The authentication in this endpoint is necessary to collect the search done by the customer and use it to collect statistics. * * menuItemName String Name of the desired menu item * returns List @@ -430,18 +496,3 @@ exports.searchByMenuItem = function(menuItemName) { }); } - -/** - * Submit a review of the menu - * Submit a review of the menu with given menuID. The receiptImageID is obtained by the frontend when the photo of the receipt is uploaded through the dedicated endpoint. - * - * menuID Integer ID of the menu - * body MenuReview Review - * no response value expected for this operation - **/ -exports.submitReview = function(menuID,body) { - return new Promise(function(resolve, reject) { - resolve(); - }); -} - diff --git a/backendStub/service/GenericUserService.js b/backendStub/service/GenericUserService.js index 3d10ab4b..3ea85396 100644 --- a/backendStub/service/GenericUserService.js +++ b/backendStub/service/GenericUserService.js @@ -5,7 +5,7 @@ * Logs user into the system * Logs user into the system. This endpoint is used both for restaurant owner and customer login. In order to distinguish them, in the request json there's the flag ''isRestaurantOwner''. If the login succeeds, returns the json web token that is supposed to be stored on the frontend application (for example in the local storage of the web browser). Each time the frontend application needs to access an endpoint that requires authentication, that token will be put in the header of the request. * - * body UserLogin User that needs to register + * body UserLogin User that needs to login * returns Token **/ exports.loginUser = function(body) { diff --git a/backendStub/service/MarinService.js b/backendStub/service/MarinService.js index b4ef24c1..5e166437 100644 --- a/backendStub/service/MarinService.js +++ b/backendStub/service/MarinService.js @@ -3,7 +3,7 @@ /** * Add a menuItem to a menu - * Add a menuItem to the menu with given menuID. Authentication required. + * Add a menuItem to the menu with given menuID. Authentication required. The tags of the menu item must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu * body MenuItemWithoutColors Menu data @@ -67,16 +67,19 @@ exports.addMenuItem = function(menuID,body) { /** * Return profile data of the customer - * Return own data of the logged in customer. This endpoints should be used when the frontend has to visualize the profile of the customer. + * Return own data of the logged in customer. This endpoint should be used when the frontend has to visualize the profile of the customer. * - * returns CustomerUsernameAndEmail + * returns CustomerData **/ exports.apiUserCustomerGET = function() { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { "username" : "emilio_imperiali", - "email" : "emilioimperiali@mail.it" + "email" : "emilioimperiali@mail.it", + "gender" : "Male", + "ageRange" : "24-34", + "nationality" : "Italy" }; if (Object.keys(examples).length > 0) { resolve(examples[Object.keys(examples)[0]]); @@ -88,13 +91,13 @@ exports.apiUserCustomerGET = function() { /** - * Delete a review - * Delete the review with the given reviewID. This will also delete the reviews of the menu items associated to the review with given reviewID. + * Change the password of the customer + * Change the password of the logged in customer. The current password must be provided, for security reasons. A 400 is sent back if the current password provided doesn't match, and the password change is not performed. * - * reviewID Integer ID of the review + * body PasswordChange New and current passwords * no response value expected for this operation **/ -exports.apiUserCustomerReviewReviewIDDELETE = function(reviewID) { +exports.apiUserCustomerPasswordPUT = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -103,7 +106,7 @@ exports.apiUserCustomerReviewReviewIDDELETE = function(reviewID) { /** * Return pending reviews - * Return all the pending reviews of the owner's restaurant. Only the image of the receipt is sent (the link to download it from the cloud), together with the name of the reviewed menu and the list of the reviewed menu items.The pending reviews are sent in an array, which will be empty in case there are no pending reviews. With a POST the restaurant owner will approve or disapprove the review. + * Return all the pending reviews of the owner's restaurant. Only the image of the receipt is sent (the link to download it from the cloud), together with the name of the reviewed menu and the list of the reviewed menu items.The pending reviews are sent in an array, which will be empty in case there are no pending reviews. With a POST the restaurant owner will approve or disapprove the review. If there are no pending reviews, an empty array is sent (with code 200, not 404). It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * returns List **/ @@ -112,6 +115,7 @@ exports.apiUserOwnerRestaurantReviewGET = function() { var examples = {}; examples['application/json'] = [ { "reviewID" : 988, + "receiptPhotoLink" : "www.cloud.com/receiptPhoto", "menuName" : "Sea menu", "menuItemNames" : [ { "menuItemName" : "Spaghetti allo scoglio" @@ -120,6 +124,7 @@ exports.apiUserOwnerRestaurantReviewGET = function() { } ] }, { "reviewID" : 988, + "receiptPhotoLink" : "www.cloud.com/receiptPhoto", "menuName" : "Sea menu", "menuItemNames" : [ { "menuItemName" : "Spaghetti allo scoglio" @@ -138,7 +143,7 @@ exports.apiUserOwnerRestaurantReviewGET = function() { /** * Approve or disapprove pending review - * Submit the decision of the restaurant owner about the pending review with given reviewID (approved or disapproved). In case of a successful operation, an array containing all the pending reviews is sent, so that the frontend is able to refresh the list (the array sent is like the array sent with the GET endpoint). + * Submit the decision of the restaurant owner about the pending review with given reviewID (approved or disapproved). In case of a successful operation, an array containing all the pending reviews is sent, so that the frontend is able to refresh the list (the array sent is like the array sent with the GET endpoint). It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * reviewID Integer ID of the pending review * body ApprovalStatus Submitted status of pending review (approved or disapproved) @@ -173,9 +178,32 @@ exports.apiUserOwnerRestaurantReviewReviewIDPOST = function(reviewID,body) { } +/** + * Creates consultant + * Creates a new consultant profile. This endpoint is used only for consultant registration. Since the consultant is a special user, it is required that a secret word of the company is sent in order to register, that secred word is stored in the backend as an environment variable. The endpoint, if the registration succeeds, returns the username of the account as a confirmation. + * + * body Consultant Consultant that needs to register + * returns UsernameAndToken + **/ +exports.createConsultant = function(body) { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "username" : "xXEmilioXx", + "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOjI5LCJpYXQiOjE1NjE5OTg2NjB9.SWYMJXTTM8pe6NQw1QwS-d8Btt6Isuzzk5JtH775uV0" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + /** * Delete a menuItem - * Delete the menuItem with given menuItemID of the menu with given menuID. Authentication required. + * Delete the menuItem with given menuItemID of the menu with given menuID. Authentication required. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu * menuItemID Integer ID of the menuItem @@ -190,7 +218,7 @@ exports.deleteMenuItem = function(menuID,menuItemID) { /** * Edit a menuItem - * Edit the menuItem with given menuItemID of the menu with given menuID. Authentication required. + * Edit the menuItem with given menuItemID of the menu with given menuID. Authentication required. The tags of the menu item must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu * menuItemID Integer ID of the menuItem @@ -253,6 +281,172 @@ exports.editMenuItem = function(menuID,menuItemID,body) { } +/** + * Return statistics of a specific nationality + * Return the statistics of the given nationality. The consultant must be logged in to access this endpoint (reserved to him). + * + * nationalityName String Nationality + * returns StatisticsOfNationality + **/ +exports.getStatisticOfNationality = function(nationalityName) { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "totalRegisteredCustomers" : 120, + "customersPerGender" : [ { + "gender" : "Male", + "numberOfCustomers" : 10 + }, { + "gender" : "Female", + "numberOfCustomers" : 8 + }, { + "gender" : "Other", + "numberOfCustomers" : 3 + } ], + "customersPerAgeRange" : [ { + "ageRange" : "18-25", + "numberOfCustomers" : 34 + }, { + "ageRange" : "25-35", + "numberOfCustomers" : 28 + }, { + "ageRange" : "35-50", + "numberOfCustomers" : 15 + } ], + "numberOfSearchesPerWord" : [ { + "word" : "Pasta", + "numberOfSearches" : 51 + }, { + "word" : "Pizza", + "numberOfSearches" : 83 + }, { + "word" : "Spaghetti", + "numberOfSearches" : 31 + } ] +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Return the global statistics + * Return the aggregate statistics of ALL the users/restaurants in the application. The consultant must be logged in to access this endpoint (reserved to him). To be more precise, this is what is sent: - The total number of registered customers - For each nationality, the number of customers - For each gender, the number of customers - For each age range, the number of customers - For each searched word, the number of customers - List of all the menu names with their ratings. It will be frontend's duty to sort them and show the top 10 and the bottom 10 + * + * returns Statistics + **/ +exports.getStatistics = function() { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "totalRegisteredCustomers" : 120, + "customersPerNationality" : [ { + "nationality" : "Italy", + "numberOfCustomers" : 10 + }, { + "nationality" : "French", + "numberOfCustomers" : 8 + }, { + "nationality" : "Croatian", + "numberOfCustomers" : 11 + } ], + "customersPerGender" : [ { + "gender" : "Male", + "numberOfCustomers" : 10 + }, { + "gender" : "Female", + "numberOfCustomers" : 8 + }, { + "gender" : "Other", + "numberOfCustomers" : 3 + } ], + "customersPerAgeRange" : [ { + "ageRange" : "18-25", + "numberOfCustomers" : 34 + }, { + "ageRange" : "25-35", + "numberOfCustomers" : 28 + }, { + "ageRange" : "35-50", + "numberOfCustomers" : 15 + } ], + "numberOfSearchesPerWord" : [ { + "word" : "Pasta", + "numberOfSearches" : 51 + }, { + "word" : "Pizza", + "numberOfSearches" : 83 + }, { + "word" : "Spaghetti", + "numberOfSearches" : 31 + } ], + "menusWithRatings" : [ { + "menuName" : "New menu", + "rating" : 3.4 + }, { + "menuName" : "Dinner menu", + "rating" : 4.2 + }, { + "menuName" : "Menu of the day", + "rating" : 5 + }, { + "menuName" : "Launch menu", + "rating" : 2 + }, { + "menuName" : "Exotic menu", + "rating" : 3.9 + } ] +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Logs consultant into the system + * Logs consultant into the system. If the login succeeds, returns the json web token. + * + * body ConsultantLogin Consultant that needs to login + * returns Token + **/ +exports.loginConsultant = function(body) { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOjI5LCJpYXQiOjE1NjE5OTg2NjB9.SWYMJXTTM8pe6NQw1QwS-d8Btt6Isuzzk5JtH775uV0" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Submit a review of the menu + * Submit a review of the menu with given menuID. The receiptImageID is obtained by the frontend when the photo of the receipt is uploaded through the dedicated endpoint. + * + * menuID Integer ID of the menu + * body MenuReview Review + * no response value expected for this operation + **/ +exports.submitReview = function(menuID,body) { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + /** * Upload an image * This endpoint is used in order to upload EVERY image. For example, when a restaurant owner is registering his restaurant data, he will need to upload an image. Both this endpoint and the dedicated endpoint (POST /api/user/owner/restaurant) will be used. This endpoint to upload the image, the other one to upload all the other textual data (with a json). The images will be stored using Amazon s3. The ID of the image is returned. For more information, this is used as a reference: https://stackoverflow.com/questions/33279153/rest-api-file-ie-images-processing-best-practices This endpoint requires authentication: we don't want anyone to update images but only authenticated users. diff --git a/backendStub/service/MatejService.js b/backendStub/service/MatejService.js index 3ae322c5..010f9f6f 100644 --- a/backendStub/service/MatejService.js +++ b/backendStub/service/MatejService.js @@ -3,7 +3,7 @@ /** * Configure data of the restaurant - * Save the data of the restaurant given by the owner. Authentication is needed. One of the parameter to be passed is the imageID, this is the flow: 1. The restaurant owner is in the page in which he can input the restaurant data. He will upload the photo of the restaurant while he is writing all the fields of the form. 2. The uploading of the photo is done by sending the photo to the /api/image endpoint. While the restaurant owner is still writing the fields of the form, the message to that endpoint is sent and the imageID is received as a response. 3. When the restaurant owner finishes writing the fields of the form and click the send button, the photo was actually already been ent in the point 2 and he doesn't have to wait for the upload (if he was fast compiling the form and the upload isn't finished yet, at least he has to wait less because it was already started). The imageID received as a response by the /api/image endpoint will be sent to this endpoint with the data of the form in a json, because the backend needs it in order to associate the json to the previously uploaded photo. + * Save the data of the restaurant given by the owner. Authentication is needed. A 400 will be sent if the owner already sent the data of his restaurant (an owner can't have more than one restaurant). One of the parameter to be passed is the imageID, this is the flow: 1. The restaurant owner is in the page in which he can input the restaurant data. He will upload the photo of the restaurant while he is writing all the fields of the form. 2. The uploading of the photo is done by sending the photo to the /api/image endpoint. While the restaurant owner is still writing the fields of the form, the message to that endpoint is sent and the imageID is received as a response. 3. When the restaurant owner finishes writing the fields of the form and click the send button, the photo was actually already been ent in the point 2 and he doesn't have to wait for the upload (if he was fast compiling the form and the upload isn't finished yet, at least he has to wait less because it was already started). The imageID received as a response by the /api/image endpoint will be sent to this endpoint with the data of the form in a json, because the backend needs it in order to associate the json to the previously uploaded photo. * * body Restaurant Restaurant data * returns RestaurantID diff --git a/backendStub/service/OwnerService.js b/backendStub/service/OwnerService.js index c9fc3017..897cc528 100644 --- a/backendStub/service/OwnerService.js +++ b/backendStub/service/OwnerService.js @@ -3,7 +3,7 @@ /** * Add an empty menu to a restaurant - * Add a menu to a restaurant of a restaurant owner, which needs to be logged in. The menuItems are not meant to be added to the menu through this endpoint. + * Add a menu to a restaurant of a restaurant owner, which needs to be logged in. The menuItems are not meant to be added to the menu through this endpoint. The tags of the menu must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * body MenuWithoutItems Menu data * returns MenuID @@ -25,7 +25,7 @@ exports.addMenu = function(body) { /** * Add a menuItem to a menu - * Add a menuItem to the menu with given menuID. Authentication required. + * Add a menuItem to the menu with given menuID. Authentication required. The tags of the menu item must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu * body MenuItemWithoutColors Menu data @@ -87,9 +87,85 @@ exports.addMenuItem = function(menuID,body) { } +/** + * Delete profile of the owner + * Delete profile of the logged in owner. + * + * no response value expected for this operation + **/ +exports.apiUserOwnerDELETE = function() { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + +/** + * Return profile data of the owner + * Return own data of logged in owner. This endpoint should be used when the frontend has to visualize the profile of the owner. + * + * returns OwnerData + **/ +exports.apiUserOwnerGET = function() { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "email" : "john.doe@gmail.com", + "username" : "johndoe", + "name" : "John", + "surname" : "Doe" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Edit profile data of the owner + * Edit profile data of the logged in owner. The password can't be changed through this endpoint, but the dedicated one should be used instead. The username can't be changed. + * + * body OwnerEditData New data of the owner + * returns OwnerData + **/ +exports.apiUserOwnerPUT = function(body) { + return new Promise(function(resolve, reject) { + var examples = {}; + examples['application/json'] = { + "email" : "john.doe@gmail.com", + "username" : "johndoe", + "name" : "John", + "surname" : "Doe" +}; + if (Object.keys(examples).length > 0) { + resolve(examples[Object.keys(examples)[0]]); + } else { + resolve(); + } + }); +} + + +/** + * Change the password of the owner + * Change the password of the logged in owner. The current password must be provided, for security reasons. A 400 is sent back if the current password provided doesn't match, and the password change is not performed. + * + * body PasswordChange New and current passwords + * no response value expected for this operation + **/ +exports.apiUserOwnerPasswordPUT = function(body) { + return new Promise(function(resolve, reject) { + resolve(); + }); +} + + /** * Return pending reviews - * Return all the pending reviews of the owner's restaurant. Only the image of the receipt is sent (the link to download it from the cloud), together with the name of the reviewed menu and the list of the reviewed menu items.The pending reviews are sent in an array, which will be empty in case there are no pending reviews. With a POST the restaurant owner will approve or disapprove the review. + * Return all the pending reviews of the owner's restaurant. Only the image of the receipt is sent (the link to download it from the cloud), together with the name of the reviewed menu and the list of the reviewed menu items.The pending reviews are sent in an array, which will be empty in case there are no pending reviews. With a POST the restaurant owner will approve or disapprove the review. If there are no pending reviews, an empty array is sent (with code 200, not 404). It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * returns List **/ @@ -98,6 +174,7 @@ exports.apiUserOwnerRestaurantReviewGET = function() { var examples = {}; examples['application/json'] = [ { "reviewID" : 988, + "receiptPhotoLink" : "www.cloud.com/receiptPhoto", "menuName" : "Sea menu", "menuItemNames" : [ { "menuItemName" : "Spaghetti allo scoglio" @@ -106,6 +183,7 @@ exports.apiUserOwnerRestaurantReviewGET = function() { } ] }, { "reviewID" : 989, + "receiptPhotoLink" : "www.cloud.com/receiptPhoto", "menuName" : "Mountain menu", "menuItemNames" : [ { "menuItemName" : "Polenta" @@ -124,7 +202,7 @@ exports.apiUserOwnerRestaurantReviewGET = function() { /** * Approve or disapprove pending review - * Submit the decision of the restaurant owner about the pending review with given reviewID (approved or disapproved). In case of a successful operation, an array containing all the pending reviews is sent, so that the frontend is able to refresh the list (the array sent is like the array sent with the GET endpoint). + * Submit the decision of the restaurant owner about the pending review with given reviewID (approved or disapproved). In case of a successful operation, an array containing all the pending reviews is sent, so that the frontend is able to refresh the list (the array sent is like the array sent with the GET endpoint). It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * reviewID Integer ID of the pending review * body ApprovalStatus Submitted status of pending review (approved or disapproved) @@ -161,7 +239,7 @@ exports.apiUserOwnerRestaurantReviewReviewIDPOST = function(reviewID,body) { /** * Return all the available tags - * When a restaurant owner is creating a menu or a menu item, he/she needs to know the list of the available tags. + * When a restaurant owner is creating a menu or a menu item, he/she needs to know the list of the available tags. If there are no tags, an empty array is sent (with code 200, not 404). * * returns List **/ @@ -180,7 +258,7 @@ exports.apiUserOwnerTagGET = function() { /** * Configure data of the restaurant - * Save the data of the restaurant given by the owner. Authentication is needed. One of the parameter to be passed is the imageID, this is the flow: 1. The restaurant owner is in the page in which he can input the restaurant data. He will upload the photo of the restaurant while he is writing all the fields of the form. 2. The uploading of the photo is done by sending the photo to the /api/image endpoint. While the restaurant owner is still writing the fields of the form, the message to that endpoint is sent and the imageID is received as a response. 3. When the restaurant owner finishes writing the fields of the form and click the send button, the photo was actually already been ent in the point 2 and he doesn't have to wait for the upload (if he was fast compiling the form and the upload isn't finished yet, at least he has to wait less because it was already started). The imageID received as a response by the /api/image endpoint will be sent to this endpoint with the data of the form in a json, because the backend needs it in order to associate the json to the previously uploaded photo. + * Save the data of the restaurant given by the owner. Authentication is needed. A 400 will be sent if the owner already sent the data of his restaurant (an owner can't have more than one restaurant). One of the parameter to be passed is the imageID, this is the flow: 1. The restaurant owner is in the page in which he can input the restaurant data. He will upload the photo of the restaurant while he is writing all the fields of the form. 2. The uploading of the photo is done by sending the photo to the /api/image endpoint. While the restaurant owner is still writing the fields of the form, the message to that endpoint is sent and the imageID is received as a response. 3. When the restaurant owner finishes writing the fields of the form and click the send button, the photo was actually already been ent in the point 2 and he doesn't have to wait for the upload (if he was fast compiling the form and the upload isn't finished yet, at least he has to wait less because it was already started). The imageID received as a response by the /api/image endpoint will be sent to this endpoint with the data of the form in a json, because the backend needs it in order to associate the json to the previously uploaded photo. * * body Restaurant Restaurant data * returns RestaurantID @@ -225,7 +303,7 @@ exports.createOwner = function(body) { /** * Delete a menu - * Delete a menu of the restaurant. Authentication is required + * Delete a menu of the restaurant. Authentication is required. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu to be edited * no response value expected for this operation @@ -239,7 +317,7 @@ exports.deleteMenu = function(menuID) { /** * Delete a menuItem - * Delete the menuItem with given menuItemID of the menu with given menuID. Authentication required. + * Delete the menuItem with given menuItemID of the menu with given menuID. Authentication required. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu * menuItemID Integer ID of the menuItem @@ -254,7 +332,7 @@ exports.deleteMenuItem = function(menuID,menuItemID) { /** * Edit a menu's information (not its items) - * Edit a given menu (but not its menuItems). To identify the menu, the menuID needs to be given. Authentication is required. + * Edit a given menu (but not its menuItems). To identify the menu, the menuID needs to be given. Authentication is required. The tags of the menu must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu to be edited * body MenuWithoutItems Data of the menu to be saved @@ -277,7 +355,7 @@ exports.editMenu = function(menuID,body) { /** * Edit a menuItem - * Edit the menuItem with given menuItemID of the menu with given menuID. Authentication required. + * Edit the menuItem with given menuItemID of the menu with given menuID. Authentication required. The tags of the menu item must be valid, otherwise a 400 error will be sent. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * menuID Integer ID of the menu * menuItemID Integer ID of the menuItem @@ -342,7 +420,7 @@ exports.editMenuItem = function(menuID,menuItemID,body) { /** * Edit restaurant's information - * Edit the information of the restaurant + * Edit the information of the restaurant. It's needed that the restaurant already exists, otherwise a 404 error will be sent. The POST endpoint should be used to create it. * * body Restaurant Restaurant data * returns RestaurantID @@ -364,7 +442,7 @@ exports.editRestaurant = function(body) { /** * Return all the menus of the restaurant - * Return all the menus of the restaurant. Since authentication is required, the backend is able to get which restaurant is involved from the authentication token. + * Return all the menus of the restaurant. Since authentication is required, the backend is able to get which restaurant is involved from the authentication token. It's needed that the restaurant already exists, otherwise a 404 error will be sent. * * returns List **/