FORK_backend_docs

User API

Table of Contents


GET : get users by query

URL

/api/users

Request Format

Location Field Name Data Type Required Description
query accountId string - the account id of the user. (not to be confused with id which is an integer unique identifier)
query type int - type is one of - 0: admin, 1: KAIST user, 2: Facility user

Response Format

Key Description
status success
data array of user rows

GET : get user by ID

URL

/api/users/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user

Response Format

Key Description
status success
data the returned user object

POST : create a new user

URL

/api/users/create

Request Format

Location Field Name Data Type Required Description
body userId string O the account id of the new user. must satisfy account id constraints, or insert will fail
body password string O the password of the new user. must satisfy password constraints or insert will fail
body userType string O type is one of - 0: admin, 1: KAIST user, 2: Facility user
body email string O email address of the new user. insert will fail if its not a valid email

Response Format

Key Description
status success
data the created user object

PUT : update user profile

URL

/api/users/profile/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user
body password string O the new password of the user, or the existing one if its not to be updated
body email string O the new email of the user, or the existing one if its not to be updated
body preferences array - integer array containing preference id

Response Format

Key Description
status success
data the updated user object

DELETE : delete a user

URL

/api/users/delete/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user

Response Format

Key Description
status success
data the deleted user object

GET : get user preferences

URL

/api/users/preference/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user

Response Format

Key Description
status success
data the array of preference rows

PUT : add a user preference

URL

/api/users/preference/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user
body preferenceId int O the unique id of the preference

Response Format

Key Description
status success
data the created junction object which has keys {"user_id", "preference_id"}

Notes


DELETE : delete a user preference

URL

/api/users/preference/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user
body preferenceId int O the unique id of the preference

Response Format

Key Description
status success
data the deleted junction object which has keys {"user_id", "preference_id"}

GET : get user favorites

URL

/api/users/favorite/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user

Response Format

Key Description
status success
data the array of facility rows

GET : check if a facility is user’s favorite

URL

/api/users/favorite/:user/has/:facility

Request Format

Location Field Name Data Type Required Description
param user int O the unique id of the user
param facility int O the unique id of the facility

Response Format

Key Description
status success
data boolean True : the user has the facility favorite-d, False : otherwise

PUT : add a user favorite

URL

/api/users/favorite/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user
body facilityId int O the unique id of the facility to be added as a favorite

Response Format

Key Description
status success
data the created junction object which has keys {"user_id", "facility_id"}

Notes


DELETE : delete a user favorite

URL

/api/users/favorite/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user
body facilityId int O the unique id of the facility

Response Format

Key Description
status success
data the deleted junction object which has keys {"user_id", "facility_id"}

POST : upload a user profile image

URL

/api/users/profile/image/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user
body - FormData image file O image file to be uploaded

Response Format

Key Description
status success
data the updated user object

DELETE : delete a user profile image

URL

/api/users/profile/image/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user

Response Format

Key Description
status success
data the updated user object

GET : Get My Facilities

URL

/api/users/:id/myfacility

Request Format

Location Field Name Data Type Required Description
param id int O unique ID of the user account

Response Format

Key Description
status success
data the returned facility object

POST : Update My Facility

URL

/api/users/:user/myfacility/:facility

Request Format

Location Field Name Data Type Required Description
param user int O unique ID of the user account
param facility int O unique ID of the facility
body name string O name of the facility
body englishName string O English name of the facility
body businessId string O business ID of the facility
body type string O type of the facility
body description string O description of the facility
body url string O URL of the facility
body phone string O phone number of the facility
body email string O email of the facility
body address object - optional address of the facility
body openingHours array - optional opening hours of the facility
body menu array - optional menu of the facility
body preferences array - optional preferences of the facility
body stampRuleset object - optional stamp ruleset of the facility
body stampRuleset.rewards array - optional rewards in the stamp ruleset

Response Format

Key Description
status success
data the updated facility object

Example Request

{
  "name": "Restaurant_01",
  "type": "restaurant",
  "businessId": "B00001",
  "phone": "02-1234-5678",
  "email": "fork350@foodies.com",
  "url": "www.restaurant.com",
  "description": "We serve great foods.",
  "address": {
    "postNumber": "12345",
    "country": "Korea",
    "city": "Seoul",
    "roadAddress": "도로명 주소 01",
    "englishAddress": "eng address 01",
    "lat": 100,
    "lng": 100
  },
  "openingHours": [
    {
      "day": 1,
      "openTime": "09:00",
      "closeTime": "17:00"
    },
    {
      "day": 2,
      "openTime": "09:00",
      "closeTime": "17:00"
    },
    {
      "day": 3,
      "openTime": "09:00",
      "closeTime": "17:00"
    }
  ],
  "menu": [
    {
      "name": "menu_01",
      "description": "menuDesc_01",
      "price": 20000,
      "quantity": "100g"
    },
    {
      "name": "menu_02",
      "description": "menuDesc_02",
      "price": 20000,
      "quantity": "100g"
    }
  ],
  "preferences": [
    1,
    2
  ],
  "stampRuleset": {
    "totalCnt": 100,
    "rewards": [
      {
        "name": "reward_001",
        "cnt": 10
      }
    ]
  }
}

DELETE : Delete My Facility

URL

/api/users/:id/myfacility/:facilityId

Request Format

Location Field Name Data Type Required Description
param id int O unique ID of the user account
param facilityId int O unique ID of the facility

Response Format

Key Description
status success
data array of the deleted facility objects or an empty array if none

GET : get posts of all user’s favorite facilities

URL

/api/users/favorite/:id/updates

Permissions

userType Guest 0 (Admin) 1 (KAIST) 2 (Facility)
Permission X O O O

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the user

Response Format

Key Description
status success
data array of post rows from all favorite facilities of the user

Preference Methods


GET : get all preferences from the system

URL

/api/preferences

Request Format

Location Field Name Data Type Required Description
. . . . .

Response Format

Key Description
status success
data array of preference rows

GET : get preference by preference ID

URL

/api/preferences/:id

Request Format

Location Field Name Data Type Required Description
param id int O the unique id of the preference

Response Format

Key Description
status success
data array of preference rows