Add request endpoint docs

pull/32/head
HardiReady 2018-03-31 12:05:37 +02:00
parent 053c9730ef
commit 08c9e2754e
13 changed files with 80 additions and 16 deletions

View File

@ -26,12 +26,14 @@ List all awardings
### Create Awarding [POST /awardings]
Create a new awarding which is immediatly assigned to the user (only for HL and above permission)
Create a new awarding which is immediatly assigned to the user
*Permission: 2*
+ Request (application/json)
+ Attributes
+ userId: `5ab68d42f547ed304064e5f7` (string, required) - display name of the user
+ userId: `5ab68d42f547ed304064e5f7` (string, required) - unique id of the army member to give award
+ decorationId: `5abd3dff6e6a0334d95b8ba0` (string, required) - unique id of the decoration
+ reason: `Good boy` (string, required) - reason for giving the awarding
+ proposer: `5ab68ceef547ed304064e5f6` (string, required) - app user id, who requested this awarding
@ -39,3 +41,20 @@ Create a new awarding which is immediatly assigned to the user (only for HL and
+ Response 201
+ Attributes (Awarding, fixed-type)
### Create Awarding Proposal [POST /request/award]
Create a new awarding proposal, that needs to be approved by higher permission level user to take effect
*Permission: 1*
+ Request (application/json)
+ Attributes
+ userId: `5ab68d42f547ed304064e5f7` (string, required) - unique id of the army member to give award
+ decorationId: `5abd3dff6e6a0334d95b8ba0` (string, required) - unique id of the decoration
+ reason: `Good boy` (string, required) - reason for giving the awarding
+ Response 201
+ Attributes (Awarding, fixed-type)

View File

@ -69,7 +69,7 @@ Create a new decoration
+ Attributes (Decoration, fixed-type)
### Update Decoration [PATCH /dcorations/{id}]
### Update Decoration [PATCH /decorations/{id}]
Update decoration, identified by its id

View File

@ -22,3 +22,44 @@ List all promotion requests
+ Response 200
+ Attributes (array[Promotion])
### Create Promotion Proposal [POST /request/promotion]
Create a new proposal for a promotion, that needs to be approved by higher permission level user to take effect
*Permission: 1*
+ Request (application/json)
+ Attributes
+ userId: `5ab68d42f547ed304064e5f7` (string, required) - id of the army member to promote
+ oldRankLvl: 0 (number, required) - previous rank level
+ newRankLvl: 5 (number, required) - new rank level to apply
+ Response 201
+ Attributes (Promotion, fixed-type)
### Update Promotion Proposal [PATCH /request/promotion/{id}]
Update the promotion proposal
*Permission: 2*
+ Parameters
+ id: `5abf50d9861d950f157c4a0a` (string, required) - unique id of the promotion
+ Request (application/json)
+ Attributes
+ _id: `5abf50d9861d950f157c4a0a` (string, optional) - id of the promotion proposal
+ userId: `5ab68d42f547ed304064e5f7` (string, optional) - id of the army member to promote
+ proposer: `5abf5064861d950f157c4a09` (string, optional) - id of the proposing app user
+ oldRankLvl: 0 (number, optional) - previous rank level
+ newRankLvl: 5 (number, optional) - new rank level to apply
+ confirmed: 1 (number, optional) confirmation status of the promotion (0 - in progress, 1 - approved & applied, 2 - rejected) \nThis automatically applies the *newRankLvl*value as new rank level to the target user when confirmed = 1
+ Response 200
+ Attributes (Promotion, fixed-type)

View File

@ -42,14 +42,14 @@ FORMAT: 1A
# Group Players
# Group Promotion
:[Gists](army-management/promotions.apib)
# Group Ranks
:[Gists](army-management/ranks.apib)
# Group Squad Lead Requests
:[Gists](army-management/promotions.apib)
# Group Squads
:[Gists](army-management/squads.apib)

View File

@ -1 +1,2 @@
{"_id":{"$oid":"5ab68ceef547ed304064e5f6"},"squad":{"$oid":"5aba54eaeadcce6332c6a774"},"permission":4,"activated":true,"username":"testuser","secret":"my secret","password":"$2a$10$wvgBbcckHrFu8Ctw8hSPNuFLoBy4sRubioyiK1NabOC0UgYD.KITi","timestamp":{"$date":"2018-03-24T17:37:50.668Z"},"updatedAt":{"$date":"2018-03-24T17:37:50.668Z"},"__v":0}
{"_id":{"$oid":"5abf5064861d950f157c4a09"},"squad":{"$oid":"5aba54eaeadcce6332c6a774"},"permission":1,"activated":true,"username":"some-squadlead","secret":"asd","password":"$2a$10$PGUw2F6HY.2Q3h0AL4Mea.3EKAGFO8S897z56CyU8q/5BC.5VEPAy","timestamp":{"$date":"2018-03-31T09:09:56.161Z"},"updatedAt":{"$date":"2018-03-31T09:09:56.161Z"},"__v":1}

View File

@ -0,0 +1 @@
{"_id":{"$oid":"5abf50e7861d950f157c4a0b"},"confirmed":0,"date":{"$date":"2018-03-31T09:12:07.861Z"},"userId":{"$oid":"5ab68d42f547ed304064e5f7"},"decorationId":{"$oid":"5abd3dff6e6a0334d95b8ba0"},"reason":"bester mann!","proposer":{"$oid":"5abf5064861d950f157c4a09"},"timestamp":{"$date":"2018-03-31T09:12:07.873Z"},"updatedAt":{"$date":"2018-03-31T09:12:07.873Z"},"__v":0}

View File

@ -1,2 +1,2 @@
{"_id":{"$oid":"5abd58989e30a76bfef747e6"},"title":"This Is The End","timestamp":{"$date":"2018-03-29T21:20:24.558Z"},"updatedAt":{"$date":"2018-03-29T21:20:24.558Z"},"__v":0}
{"_id":{"$oid":"5abd55ea9e30a76bfef747d6"},"title":"Ein Kessel Buntes","timestamp":{"$date":"2018-03-29T21:08:58.123Z"},"updatedAt":{"$date":"2018-03-29T21:08:58.123Z"},"__v":0}
{"_id":{"$oid":"5abd58989e30a76bfef747e6"},"title":"This Is The End","timestamp":{"$date":"2018-03-29T21:20:24.558Z"},"updatedAt":{"$date":"2018-03-29T21:20:24.558Z"},"__v":0}

View File

@ -1,3 +1,3 @@
{"_id":{"$oid":"5abd3dff6e6a0334d95b8ba0"},"sortingNumber":0,"name":"Orden der Tapferkeit","fraction":"BLUFOR","isMedal":true,"description":"Das ist ein Orden den tapfere Leute bekommen","timestamp":{"$date":"2018-03-29T19:26:55.387Z"},"updatedAt":{"$date":"2018-03-29T19:26:55.387Z"},"__v":0}
{"_id":{"$oid":"5abeb420b987672bb1ede643"},"sortingNumber":0,"name":"Teilnehmer der Kampagne X","fraction":"GLOBAL","isMedal":false,"description":"Dabei sein ist alles","timestamp":{"$date":"2018-03-30T22:03:12.228Z"},"updatedAt":{"$date":"2018-03-30T22:03:12.228Z"},"__v":0}
{"_id":{"$oid":"5abeb43cb987672bb1ede644"},"sortingNumber":0,"name":"Ehrenmedaille","fraction":"OPFOR","isMedal":true,"description":"Fuer die Ehre","timestamp":{"$date":"2018-03-30T22:03:40.560Z"},"updatedAt":{"$date":"2018-03-30T22:03:40.560Z"},"__v":0}
{"_id":{"$oid":"5abd3dff6e6a0334d95b8ba0"},"sortingNumber":0,"name":"Orden der Tapferkeit","fraction":"BLUFOR","isMedal":true,"description":"Das ist ein Orden den tapfere Leute bekommen","timestamp":{"$date":"2018-03-29T19:26:55.387Z"},"updatedAt":{"$date":"2018-03-29T19:26:55.387Z"},"__v":0}

View File

@ -0,0 +1 @@
{"_id":{"$oid":"5abf50d9861d950f157c4a0a"},"userId":{"$oid":"5ab68d42f547ed304064e5f7"},"oldRankLvl":0,"newRankLvl":10,"confirmed":0,"proposer":{"$oid":"5abf5064861d950f157c4a09"},"timestamp":{"$date":"2018-03-31T09:11:53.364Z"},"updatedAt":{"$date":"2018-03-31T09:11:53.364Z"},"__v":0}

View File

@ -1,3 +1,3 @@
{"_id":{"$oid":"5aba5504eadcce6332c6a775"},"name":"Gefreiter","fraction":"BLUFOR","level":0,"timestamp":{"$date":"2018-03-27T14:28:20.948Z"},"updatedAt":{"$date":"2018-03-27T14:28:20.948Z"},"__v":0}
{"_id":{"$oid":"5abeb1b995cf43205225710a"},"name":"General","fraction":"OPFOR","level":22,"timestamp":{"$date":"2018-03-30T21:52:57.204Z"},"updatedAt":{"$date":"2018-03-30T21:52:57.204Z"},"__v":0}
{"_id":{"$oid":"5abeb23995cf43205225710b"},"name":"Unteroffizier","fraction":"BLUFOR","level":10,"timestamp":{"$date":"2018-03-30T21:55:05.625Z"},"updatedAt":{"$date":"2018-03-30T21:55:05.625Z"},"__v":0}
{"_id":{"$oid":"5aba5504eadcce6332c6a775"},"name":"Gefreiter","fraction":"BLUFOR","level":0,"timestamp":{"$date":"2018-03-27T14:28:20.948Z"},"updatedAt":{"$date":"2018-03-27T14:28:20.948Z"},"__v":0}

View File

@ -1,3 +1,3 @@
{"_id":{"$oid":"5abe16f98b7488392a623f17"},"sortingNumber":4,"name":"Bravo","fraction":"BLUFOR","timestamp":{"$date":"2018-03-30T10:52:41.396Z"},"updatedAt":{"$date":"2018-03-30T10:52:41.396Z"},"__v":0}
{"_id":{"$oid":"5aba54eaeadcce6332c6a774"},"sortingNumber":0,"name":"Alpha","fraction":"BLUFOR","timestamp":{"$date":"2018-03-27T14:27:54.399Z"},"updatedAt":{"$date":"2018-03-27T14:27:54.399Z"},"__v":0}
{"_id":{"$oid":"5abe166f8b7488392a623f12"},"sortingNumber":0,"name":"Führungsstab","fraction":"OPFOR","timestamp":{"$date":"2018-03-30T10:50:23.121Z"},"updatedAt":{"$date":"2018-03-30T10:50:23.121Z"},"__v":0}
{"_id":{"$oid":"5abe16f98b7488392a623f17"},"sortingNumber":4,"name":"Bravo","fraction":"BLUFOR","timestamp":{"$date":"2018-03-30T10:52:41.396Z"},"updatedAt":{"$date":"2018-03-30T10:52:41.396Z"},"__v":0}

View File

@ -1,4 +1,4 @@
### Get User [GET /campaigns/{id}]
### Get Campaign [GET /campaigns/{id}]
Get single campaign information

View File

@ -110,7 +110,7 @@ decoration.route('/:id')
req.body.$inc = {__v: 1};
if (req.file) {
const file = resourceLocation + req.body._id + '.png';
const file = resourceLocation + req.params.id + '.png';
fs.unlink(file, (err) => {
if (err) next(err);
fs.appendFile(file, new Buffer(req.file.buffer), (err) => {
@ -135,7 +135,8 @@ decoration.route('/:id')
})
.delete(apiAuthenticationMiddleware, checkHl, (req, res, next) => {
DecorationModel.findByIdAndRemove(req.params.id, (err, item) => {
const id = req.params.id;
DecorationModel.findByIdAndRemove(id, (err, item) => {
if (err) {
err.status = codes.wrongrequest;
} else if (!item) {
@ -144,10 +145,10 @@ decoration.route('/:id')
}
// deleted all awardings linked to this decoration
AwardingsModel.find({decorationId: req.params.id}).remove().exec();
AwardingsModel.find({decorationId: id}).remove().exec();
// delete graphic
fs.unlink(resourceLocation + req.params.id + '.png',
fs.unlink(resourceLocation.concat(id).concat('.png'),
(err) => {
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
res.locals.processed = true;