diff --git a/API.md b/API.md new file mode 100644 index 0000000..0316e76 --- /dev/null +++ b/API.md @@ -0,0 +1,152 @@ + +# API Documentation + +### /api/map/get_floor/ID/REPRESENTATION + > Return a list of place composing floor _ID_ + > _REPRESENTATION_ is the representation' type to consider for every places in {'Cylinder', 'PolySurface'}. The default is 'Cylinder' + > Other representations should be added later, and it should become a priority order instead of a strict selection (actually if a place doesn't have Cylinder representation, it will return an empty list, even if the place has a PolySurface representation). + +__Each place is a dict :__ +```json +{ + 'id': int, //unique id + 'names' : string[] //possibly empty, + 'type': string //in {'C'(orridor), 'S'(tairs), 'E'(levator), 'R'(oom)} , + 'surface' : list of [int, int] //list of every points composing the room, projected on the floor surface +} +``` +__Errors :__ +- If _ID_ doesn't correspond to any registered floor : Return Error 404 "NotFoundHttpError". +- If _ID_ has many occurence in the FloorRepository : Return Error 500 > The Database is corrupted. + +--------------------- + +### /api/map/find_place_by_name/NAME +>Return a dict representing the place with NAME. + +__Format of the dict :__ +```json +{ + 'idPlace':int, //unique id of the place + 'idFloors': int[] // list of every floorID the place is in +} +``` +__Errors :__ +- If _NAME_ doesn't correspond to any registered place : Return Error 404 "NotFoundHttpError". +- If _NAME_ has many occurence in the PlaceNameRepository : Return Error 500 "UnprocessableEntityHttpException" > The API can't decide which place should be provided. +--------------------- + +### /api/map/show_place_info/ID + +> Return a dict with main pieces of informations of the place ID. + +__Format of the dict :__ +```json +{ + 'idPlace': int, + 'names': string[] // list of names for this place + 'users': string[] // list of users' name (professors, etc) +} +``` +__Errors :__ +- If _ID_ doesn't correspond to any registered place : Return Error 404 "NotFoundHttpError". +- If _ID_ has many occurence in the PlaceRepository : Return Error 500 > The Database is corrupted. + +--------------------- +### /api/map/get_all_editions + + > Return a list of all editions currently pending. + +__Each place is a dict :__ +```json +{ + 'id': int // id of the edition, + 'mode': string // should be AddName, RemoveName, AddUser or RemoveUser + 'placeNames': string[] // list of names of the place + 'placeId': string // id of the place + 'editorValue': string // the value to add or remove +} +``` +__Errors :__ +- If there is no pending edition : Return Error 404 "NotFoundHttpError" > It's a Warning that is not fatal (but I didn't manage to raise a warning with symfony so it's still an error) +--------------------- + +### /api/map/create_edition/MODE/PLACEID/VALUE + +> Add an edition to the BDD +> MODE should be in {AddPlaceName ; DelPlaceName ; AddRoomUserName ; DelRoomUserName}. In fact it is transparent to the API and the mode is set by the frontend when it creates an edition. + +Return 'added' if successful. + +__Errors :__ +- If _PLACEID_ doesn't correspond to any registered place : Return Error 404 "NotFoundHttpError". +- If _PLACEID_ has many occurence in the PlaceRepository : Return Error 500 > The Database is corrupted. + +--------------------- +### /api/map/remove_edition/ID + +> Remove the edition with _ID_ from the Database. +> It should be called after successfully treating any edition to remove it from the pending editions. +> Warning: The edition proposal is lost as there is no log for now. + +Return 'removed' if successful. + +__Errors :__ +- If _ID_ doesn't correspond to any registered edition : Return Error 404 "NotFoundHttpError". +- If _ID_ has many occurence in the EditionRepository : Return Error 500 > The Database is corrupted. + +--------------------- +### /api/map/del_place_name/PLACEID/NAME +> Remove _NAME_ from the place _PLACEID_. +> Warning: The name is lost as there is no log for now. + +Return 'removed' if successful. + +__Errors :__ +- If (_PLACEID_,_NAME_) doesn't match any line of PlaceNameRepository +_ie the_ NAME _is not registered for place_ PLACEID _or this place doesn't exists_ : Return Error 404 "NotFoundHttpError". + +__Note :__ +- If (_PLACEID_,_NAME_) has many match in the PlaceNameRepository, it will only remove one of them. But it shouldn't happen as the API asset that the name isn't registered for this place when adding it. + +--------------------- + +### /api/map/add_place_name/PLACEID/NAME + +> Add _NAME_ to the place _PLACEID_. + +Return 'added' if successful. + +__Errors :__ +- If _PLACEID_ doesn't correspond to any registered place : Return Error 404 "NotFoundHttpError". +- If _PLACEID_ has many occurence in the PlaceRepository : Return Error 500 > The Database is corrupted. +- If _NAME_ is already registered as a name of place _PLACEID_ : Return Error 500 "ValueError" > It's a Warning that is not fatal (but I didn't manage to raise a warning with symfony so it's still an error) + +--------------------- + +### /api/map/del_room_user_name/PLACEID/NAME + +> Remove _NAME_ from the usernames using the place _PLACEID_. +> Warning: The name is lost as there is no log for now. + +Return 'removed' if successful. + +__Errors :__ +- If (_PLACEID_,_NAME_) doesn't match any line of RoomUserNameRepository +_ie the_ NAME _is not registered as a user for place_ PLACEID _or this place doesn't exists_ : Return Error 404 "NotFoundHttpError". + +__Note :__ +- If (_PLACEID_,_NAME_) has many match in the RoomUserNameRepository, it will only remove one of them. But it shouldn't happen as the API asset that the username isn't registered for this place when adding it. + +--------------------- + +### /api/map/add_room_user_name/PLACEID/NAME + +> Add _NAME_ to the usernames using the place _PLACEID_. + +Return 'added' if successful. + +__Errors :__ +- If _PLACEID_ doesn't correspond to any registered place : Return Error 404 "NotFoundHttpError". +- If _PLACEID_ has many occurence in the PlaceRepository : Return Error 500 > The Database is corrupted. +- If _NAME_ is already registered as a username of place _PLACEID_ : Return Error 500 "ValueError" > It's a Warning that is not fatal (but I didn't manage to raise a warning with symfony so it's still an error)