From 3e18c2b1cc03cec936010a5be931ddb4427d2c44 Mon Sep 17 00:00:00 2001 From: VivianDee <115420678+VivianDee@users.noreply.github.com> Date: Tue, 25 Mar 2025 07:53:56 +0100 Subject: [PATCH] [fix]: request and response schemas --- app/api/schemas/eligibility_check.py | 2 +- app/api/services/eligibility_check.py | 42 +++++++++++---------- app/api/services/select_offer.py | 32 ---------------- app/swagger/paths/EligibilityCheck.json | 13 +------ app/swagger/paths/LoanInformation.json | 12 +----- app/swagger/paths/NotificationCallback.json | 12 +----- app/swagger/paths/ProvideLoan.json | 15 +------- app/swagger/paths/SelectOffer.json | 12 +----- app/swagger/schemas/SelectOfferRequest.json | 2 +- 9 files changed, 34 insertions(+), 108 deletions(-) diff --git a/app/api/schemas/eligibility_check.py b/app/api/schemas/eligibility_check.py index 80434e7..7b901c2 100644 --- a/app/api/schemas/eligibility_check.py +++ b/app/api/schemas/eligibility_check.py @@ -6,5 +6,5 @@ class EligibilityCheckSchema(Schema): customerId = fields.Str(required=True) accountId = fields.Str(required=True) msisdn = fields.Str(required=True) - lienAmount = fields.Float(required=True) + accountId = fields.Str(required=True) channel = fields.Str(required=True) diff --git a/app/api/services/eligibility_check.py b/app/api/services/eligibility_check.py index 4cd5106..2d7cd63 100644 --- a/app/api/services/eligibility_check.py +++ b/app/api/services/eligibility_check.py @@ -22,30 +22,34 @@ class EligibilityCheckService: schema = EligibilityCheckSchema() validated_data = schema.load(data) # Raises an error if invalid + offers = [ + { + "offerId": "Offer1", + "productId": "Product1", + "minAamount": 100, + "maxAamount": 1000, + "tenor": 12 + }, + { + "offerId": "Offer2", + "productId": "Product2", + "minAamount": 200, + "maxAamount": 2000, + "tenor": 24 + } + ] + # Simulate processing response_data = { "customerId": "CN621868", - "transactionId": "Tr201712RK9232P115", + "transactionId": "TX12345", + "countryCode": "NG", "msisdn": "3451342", - "eligibleOffers": [ - { - "minamount": 5000, - "maxamount": 20000, - "productId": 101, - "offerid": 101, - "Tenor": 30 - }, - { - "minamount": 20000, - "maxamount": 50000, - "productId": 102, - "offerid": 102, - "Tenor": 60 - } - ], + "eligibleOffers": offers, + "resultDescription": "Successful", "resultCode": "00", - "resultDescription": "Successful" - } + "accountId": "ACN8263457" + } # Return a success response diff --git a/app/api/services/select_offer.py b/app/api/services/select_offer.py index 8c82157..8656cbc 100644 --- a/app/api/services/select_offer.py +++ b/app/api/services/select_offer.py @@ -38,38 +38,6 @@ class SelectOfferService: "recommendedRepaymentDates": ["2022-11-30"], "installmentAmount": 11000.0, "totalRepaymentAmount": 11000.0 - }, - { - "offerId": "16645", - "productId": "2060", - "amount": 10000.0, - "upfrontPayment": 0.0, - "interestRate": 3.0, - "managementRate": 1.0, - "managementFee": 1.0, - "insuranceRate": 1.0, - "insuranceFee": 100.0, - "VATRate": 7.5, - "VATAmount": 100.0, - "recommendedRepaymentDates": ["2022-11-30", "2023-12-30"], - "installmentAmount": 5761.9, - "totalRepaymentAmount": 11523.8 - }, - { - "offerId": "122212", - "productId": "2090", - "amount": 10000.0, - "upfrontPayment": 0.0, - "interestRate": 10.0, - "managementRate": 1.0, - "managementFee": 1.0, - "insuranceRate": 1.0, - "insuranceFee": 100.0, - "VATRate": 7.5, - "VATAmount": 100.0, - "recommendedRepaymentDates": ["2022-11-30", "2022-12-30", "2023-01-29"], - "installmentAmount": 4021.15, - "totalRepaymentAmount": 12063.45 } ] diff --git a/app/swagger/paths/EligibilityCheck.json b/app/swagger/paths/EligibilityCheck.json index a6231d7..b5dbcb4 100644 --- a/app/swagger/paths/EligibilityCheck.json +++ b/app/swagger/paths/EligibilityCheck.json @@ -46,20 +46,9 @@ "400": { "description": "Invalid ID supplied" }, - "404": { - "description": "Pet not found" - }, "422": { "description": "Validation exception" } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] + } } } \ No newline at end of file diff --git a/app/swagger/paths/LoanInformation.json b/app/swagger/paths/LoanInformation.json index ded3156..659c55b 100644 --- a/app/swagger/paths/LoanInformation.json +++ b/app/swagger/paths/LoanInformation.json @@ -5,7 +5,7 @@ ], "summary": "Loan Information Request ", "description": "Loan Information Request", - "operationId": "startEligibilityCheck", + "operationId": "LoanInformation", "requestBody": { "description": "Post JSON to conduct eligibility tests", "content": { @@ -52,14 +52,6 @@ "422": { "description": "Validation exception" } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] + } } } \ No newline at end of file diff --git a/app/swagger/paths/NotificationCallback.json b/app/swagger/paths/NotificationCallback.json index b7d8e7c..cb0b103 100644 --- a/app/swagger/paths/NotificationCallback.json +++ b/app/swagger/paths/NotificationCallback.json @@ -5,7 +5,7 @@ ], "summary": "Loan Information Request ", "description": "Loan Information Request", - "operationId": "startEligibilityCheck", + "operationId": "NotificationCallback", "requestBody": { "description": "Post JSON to conduct eligibility tests", "content": { @@ -52,14 +52,6 @@ "422": { "description": "Validation exception" } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] + } } } \ No newline at end of file diff --git a/app/swagger/paths/ProvideLoan.json b/app/swagger/paths/ProvideLoan.json index d919c2d..fc856e9 100644 --- a/app/swagger/paths/ProvideLoan.json +++ b/app/swagger/paths/ProvideLoan.json @@ -5,7 +5,7 @@ ], "summary": "Provide Loan Request ", "description": "Provide Loan Request", - "operationId": "startEligibilityCheck", + "operationId": "ProvideLoan", "requestBody": { "description": "Post JSON to conduct eligibility tests", "content": { @@ -46,20 +46,9 @@ "400": { "description": "Invalid ID supplied" }, - "404": { - "description": "Pet not found" - }, "422": { "description": "Validation exception" } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] + } } } \ No newline at end of file diff --git a/app/swagger/paths/SelectOffer.json b/app/swagger/paths/SelectOffer.json index 14c6234..e83dd23 100644 --- a/app/swagger/paths/SelectOffer.json +++ b/app/swagger/paths/SelectOffer.json @@ -5,7 +5,7 @@ ], "summary": "This method is used the send the offer the customer selected to Simbrella ", "description": "This method is used the send the offer the customer selected to Simbrella", - "operationId": "startEligibilityCheck", + "operationId": "SelectOffer", "requestBody": { "description": "Post JSON to conduct eligibility tests", "content": { @@ -52,14 +52,6 @@ "422": { "description": "Validation exception" } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] + } } } \ No newline at end of file diff --git a/app/swagger/schemas/SelectOfferRequest.json b/app/swagger/schemas/SelectOfferRequest.json index 2ce7d62..a874ed3 100644 --- a/app/swagger/schemas/SelectOfferRequest.json +++ b/app/swagger/schemas/SelectOfferRequest.json @@ -26,7 +26,7 @@ "type": "string", "example": "ACN8263457" }, - "productid": { + "productId": { "type": "string", "example": "101" },