Skip to content

Commit

Permalink
Test applicantcorrespondence
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocelyn Cabildo authored and Jocelyn Cabildo committed Jan 11, 2025
1 parent d72f283 commit 29c38b9
Showing 1 changed file with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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/<requestid>/<ministryrequestid>')
class FOIFlowApplicantCorrespondenceDraft(Resource):
Expand Down

0 comments on commit 29c38b9

Please sign in to comment.