diff --git a/request-management-api/request_api/resources/applicantcorrespondence.py b/request-management-api/request_api/resources/applicantcorrespondence.py index 365bf3132..63a5c11dd 100644 --- a/request-management-api/request_api/resources/applicantcorrespondence.py +++ b/request-management-api/request_api/resources/applicantcorrespondence.py @@ -82,6 +82,20 @@ def get(requestid, ministryrequestid): except BusinessException: return "Error happened while fetching applicant correspondence logs" , 500 + # @staticmethod + # @TRACER.trace() + # @cross_origin(origins=allowedorigins()) + # @auth.require + # @auth.hasusertype('iao') + # def post(requestid, ministryrequestid): + # try: + # requestjson = request.get_json() + # applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) + # rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) + # result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog) + # return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + # except BusinessException: + # return "Error happened while saving applicant correspondence log" , 500 @staticmethod @TRACER.trace() @cross_origin(origins=allowedorigins()) @@ -91,14 +105,23 @@ def post(requestid, ministryrequestid): try: requestjson = request.get_json() applicantcorrespondencelog = FOIApplicantCorrespondenceSchema().load(data=requestjson) - rawrequestid = requestservice().getrawrequestidbyfoirequestid(requestid) - result = communicationwrapperservice().send_email(rawrequestid, ministryrequestid, applicantcorrespondencelog) - return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 + result = applicantcorrespondenceservice().saveapplicantcorrespondencelog(requestid, ministryrequestid, applicantcorrespondencelog, AuthHelper.getuserid()) + if cfrfeeservice().getactivepayment(requestid, ministryrequestid) != None: + requestservice().postfeeeventtoworkflow(requestid, ministryrequestid, "CANCELLED") + if result.success == True: + _attributes = applicantcorrespondencelog["attributes"][0] if "attributes" in applicantcorrespondencelog else None + _paymentexpirydate = _attributes["paymentExpiryDate"] if _attributes is not None and "paymentExpiryDate" in _attributes else None + if _paymentexpirydate not in (None, ""): + paymentservice().createpayment(requestid, ministryrequestid, _attributes, AuthHelper.getuserid()) + requestservice().postcorrespondenceeventtoworkflow(requestid, ministryrequestid, result.identifier, applicantcorrespondencelog['attributes'], applicantcorrespondencelog['templateid']) + + return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 except BusinessException: return "Error happened while saving applicant correspondence log" , 500 + @cors_preflight('POST,OPTIONS') @API.route('/foiflow/applicantcorrespondence/draft//') class FOIFlowApplicantCorrespondenceDraft(Resource):