Skip to content

Commit

Permalink
Merge pull request #192 from tcet-opensource/172-update_get_Accredita…
Browse files Browse the repository at this point in the history
…tion_apidoc

172 update get accreditation apidoc
  • Loading branch information
Hitansh159 authored Jul 9, 2023
2 parents 6365cd9 + bcaa917 commit 2b9d280
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
17 changes: 17 additions & 0 deletions _apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,20 @@
* "err": "Error while inserting in DB"
* }
*/

/**
* @api {get} accreditation/list Get Accreditation List
* @apiName GetAccreditation
* @apiGroup Accreditation
*
* @apiQuery {String} [name] Name of accreditation .
* @apiQuery {String} [agencyName] Name of agency that issued the accreditation.
* @apiQuery {Date} [dateofAccreditation] Date on which accreditation was issued.
* @apiQuery {Date} [dateofExpiry] Date till which accreditation is valid.
*
* @apiSuccess {accreditation[]} res Array of Filtered accreditation Doc .
* @apiSuccess {String} accreditation.name Name of accreditation
* @apiSuccess {String} accreditation.agencyName Name of agency that issued the accreditation.
* @apiSuccess {Date} accreditation.dateofAccreditation Date on which accreditation was issued.
* @apiSuccess {Date} accreditation.dateofExpiry Date till which accreditation is valid.
*/
10 changes: 7 additions & 3 deletions controller/accreditation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { addNewAccreditation, deleteAccreditationById, updateAccreditationById, getAccreditations } from "#services/accreditation";
import {
addNewAccreditation, deleteAccreditationById, updateAccreditationById, getAccreditations,
} from "#services/accreditation";
import { logger } from "#util";

async function addAccreditation(req, res) {
Expand Down Expand Up @@ -31,7 +33,7 @@ async function updateAccreditation(req, res) {
const {
id, ...data
} = req.body;

try {
await updateAccreditationById(id, data);
res.json({ res: "accreditation updated" });
Expand All @@ -53,4 +55,6 @@ async function showAccreditation(req, res) {
}
}

export default { addAccreditation, updateAccreditation, deleteAccreditation, showAccreditation };
export default {
addAccreditation, updateAccreditation, deleteAccreditation, showAccreditation,
};
4 changes: 2 additions & 2 deletions services/accreditation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export async function getAccreditations(filter) {
}

export async function deleteAccreditationById(accredationId) {
const deleted = await accreditation.remove({ _id: accredationId });
const deleted = await Accreditation.remove({ _id: accredationId });
if (deleted) {
return deleted;
}
throw new databaseError.DataDeleteError("Accreditation");
}

export async function updateAccreditationById(id, data) {
const updated = await accreditation.update({ _id: id }, data);
const updated = await Accreditation.update({ _id: id }, data);
if (updated) {
return updated;
}
Expand Down

0 comments on commit 2b9d280

Please sign in to comment.