Skip to content

Commit

Permalink
Merge pull request #3 from OpusCapita/MEP-4859
Browse files Browse the repository at this point in the history
Mep 4859 - fix
  • Loading branch information
przemyslawss authored Apr 24, 2024
2 parents f6934f6 + 9e503bf commit 1eab32b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Credentials/controllers/receiving/Create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const createReceive = async (req: HttpRequest) => {
// Chack body params
checkReceivingRequestBodyParamsForCreateOrUpdate(uuid, username, id_account);

checkIfTypeIsNumber(Number(id_account), 'id_account');
checkIfTypeIsNumber(id_account, 'id_account');

checkIfTypeIsString(uuid, 'uuid');

Expand Down
2 changes: 1 addition & 1 deletion Credentials/controllers/receiving/Get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getReceive = async (req: HttpRequest) => {
// Chack body params
checkReceivingRequestQueryParamsForGet(id_account);

checkIfTypeIsNumber(Number(id_account), 'id_account');
checkIfTypeIsNumber(id_account, 'id_account');

// Check if row with id_account already exists
const response_from_db = await ReceivingCredential.get(Number(id_account));
Expand Down
2 changes: 1 addition & 1 deletion Credentials/controllers/receiving/Remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const removeReceive = async (req: HttpRequest) => {
// Chack body params
checkReceivingRequestBodyParamsForDelete(id_account);

checkIfTypeIsNumber(Number(id_account), 'id_account');
checkIfTypeIsNumber(id_account, 'id_account');

// Check if row with id_account already exists
let response_from_db = await ReceivingCredential.get(Number(id_account));
Expand Down
4 changes: 2 additions & 2 deletions Credentials/controllers/receiving/Update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const updateReceive = async (req: HttpRequest) => {

const { uuid, username, id_account } = req.body;

checkIfTypeIsNumber(Number(id_account), 'id_account');
checkIfTypeIsNumber(id_account, 'id_account');

// Chack body params
checkReceivingRequestBodyParamsForCreateOrUpdate(uuid, username, id_account);

Expand Down
2 changes: 2 additions & 0 deletions Credentials/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const httpTrigger: AzureFunction = async function (context: Context, req: HttpRe
const { receive, get_list } = req.query;

try {
// Check if request is for receiving
if (receive) {
switch (req.method) {
case 'POST':
Expand Down Expand Up @@ -47,6 +48,7 @@ const httpTrigger: AzureFunction = async function (context: Context, req: HttpRe
return;
}

// Check if request is for fetching
switch (req.method) {
case 'POST':
context.res = await create(req);
Expand Down
12 changes: 6 additions & 6 deletions _common/utils/ReceivingRequest.utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { returnRequiredParamsErrorMessage } from './Request.utils';

export const checkReceivingRequestQueryParamsForGet = (uuid: string) => {
if (!uuid) {
export const checkReceivingRequestQueryParamsForGet = (id_account: string) => {
if (!id_account) {
throw {
status: 400,
body: {
status: 'Bad Request',
description: returnRequiredParamsErrorMessage(['uuid'], 'query')
description: returnRequiredParamsErrorMessage(['id_account'], 'query')
},
headers: {
'Content-Type': 'application/json'
Expand All @@ -15,13 +15,13 @@ export const checkReceivingRequestQueryParamsForGet = (uuid: string) => {
}
}

export const checkReceivingRequestBodyParamsForDelete = (uuid: string) => {
if (!uuid) {
export const checkReceivingRequestBodyParamsForDelete = (id_account: string) => {
if (!id_account) {
throw {
status: 400,
body: {
status: 'Bad Request',
description: returnRequiredParamsErrorMessage(['uuid'], 'body')
description: returnRequiredParamsErrorMessage(['id_account'], 'body')
},
headers: {
'Content-Type': 'application/json'
Expand Down

0 comments on commit 1eab32b

Please sign in to comment.