-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Oct 17, 2019
1 parent
0ce6b8b
commit 1e918bf
Showing
12 changed files
with
668 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { Response, Logger } = require('../util'); | ||
const paramUtil = require('../helper/param-util'); | ||
const service = require('../service/beneficiario-service'); | ||
const BeneficiarioValidator = require('../http-validators/beneficiario-validator'); | ||
|
||
const consultarBeneficiarios = async (req, res, next) => { | ||
try { | ||
const params = paramUtil.getParams(req); | ||
const options = BeneficiarioValidator.requisicaoConsultarBeneficiarios(params); | ||
const resposta = await service.consultarBeneficiarios(options); | ||
return Response.success(res, resposta, { contentType: Response.CONTENT_TYPE.APPLICATION_QR_PAGUE }); | ||
} catch (err) { | ||
Logger.warn(err); | ||
return Response.fromError(res, err); | ||
} | ||
} | ||
|
||
const consultarBeneficiario = async (req, res, next) => { | ||
try { | ||
const params = paramUtil.getParams(req); | ||
const options = BeneficiarioValidator.requisicaoConsultarBeneficiario(params); | ||
const resposta = await service.consultarBeneficiario(options); | ||
return Response.success(res, resposta, { contentType: Response.CONTENT_TYPE.APPLICATION_QR_PAGUE }); | ||
} catch (err) { | ||
Logger.warn(err); | ||
return Response.fromError(res, err); | ||
} | ||
} | ||
|
||
module.exports = { | ||
consultarBeneficiarios, | ||
consultarBeneficiario | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const { CONSTANTS } = require('../jwt'); | ||
const { Response, ResponseError, Err, Logger } = require('../util'); | ||
const { campoObrigatorio } = require('./commum'); | ||
|
||
const requisicaoConsultarBeneficiarios = (params) => { | ||
|
||
try { | ||
|
||
campoObrigatorio('token-instituicao', params[CONSTANTS.TOKEN_NAME]); | ||
|
||
let requisicao = { | ||
tokenInstituicao: params[CONSTANTS.TOKEN_NAME], | ||
} | ||
|
||
if(params.cpfCnpj) { | ||
requisicao = { ...requisicao, cpfCnpj: params.cpfCnpj } | ||
} | ||
|
||
return requisicao; | ||
|
||
} catch(err) { | ||
Logger.warn(err); | ||
if(!(err instanceof ResponseError)){ | ||
Err.throwError(Response.HTTP_STATUS.BAD_REQUEST, 997000); | ||
} | ||
throw err; | ||
} | ||
} | ||
|
||
const requisicaoConsultarBeneficiario = (params) => { | ||
|
||
try { | ||
|
||
campoObrigatorio('token-instituicao', params[CONSTANTS.TOKEN_NAME]); | ||
campoObrigatorio('cpfCnpj', params.cpfCnpj); | ||
|
||
let requisicao = { | ||
tokenInstituicao: params[CONSTANTS.TOKEN_NAME], | ||
cpfCnpj: params.cpfCnpj | ||
} | ||
|
||
return requisicao; | ||
|
||
} catch(err) { | ||
Logger.warn(err); | ||
if(!(err instanceof ResponseError)){ | ||
Err.throwError(Response.HTTP_STATUS.BAD_REQUEST, 997000); | ||
} | ||
throw err; | ||
} | ||
} | ||
|
||
module.exports = { | ||
requisicaoConsultarBeneficiarios, | ||
requisicaoConsultarBeneficiario | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.