Merge branch 'testing' of DigiFi/FirstCore into master

This commit is contained in:
2025-04-24 10:27:52 +00:00
committed by Gogs
20 changed files with 908 additions and 437 deletions
+22 -6
View File
@@ -1,7 +1,9 @@
from flask import Blueprint, request, jsonify, send_from_directory
from flask import Blueprint, request, jsonify
from app.api.services.loan import LoanService
from app.api.services.transaction import TransactionService
from app.api.services import RepaymentService
from app.api.services.loan_service import LoanService
from app.api.services.transaction_service import TransactionService
from app.api.services.auth_service import AuthService
from app.api.services.dashboard_service import DashboardService
from functools import wraps
@@ -96,6 +98,7 @@ def get_dashboard():
return jsonify(result)
@api.route('/loans', methods=['GET'])
# @token_required
def get_loans():
@@ -109,8 +112,10 @@ def get_loans():
'start_date': request.args.get('start_date'),
'end_date': request.args.get('end_date'),
'due_before': request.args.get('due_before'),
'due_after': request.args.get('due_after')
}
'due_after': request.args.get('due_after'),
'page': request.args.get('page', 1),
'limit': request.args.get('limit', 20)
}
# logger.info(f"Get loans request received with filters: {filters}")
response = LoanService.process_request(filters)
return response
@@ -125,8 +130,19 @@ def get_transactions():
'type': request.args.get('type'),
'channel': request.args.get('channel'),
'start_date': request.args.get('start_date'),
'end_date': request.args.get('end_date')
}
'end_date': request.args.get('end_date'),
'page': request.args.get('page', 1),
'limit': request.args.get('limit', 20)
}
# logger.info(f"Get transactions request received with filters: {filters}")
response = TransactionService.process_request(filters)
return response
# Repayment Endpoint
@api.route("/Repayment", methods=["POST"])
# @jwt_required()
def repayment():
data = request.get_json()
# logger.info(f"Repayment request received: {data}")
response = RepaymentService.process_request(data)
return response
+12
View File
@@ -0,0 +1,12 @@
from marshmallow import Schema, fields
# Repayment Schema
class RepaymentSchema(Schema):
type = fields.Str(required=False)
msisdn = fields.Str(required=False) #optional
debtId = fields.Str(required=True)
productId = fields.Str(required=True)
transactionId = fields.Str(required=True)
accountId = fields.Str(required=True)
customerId = fields.Str(required=True)
channel = fields.Str(required=True)
+3 -2
View File
@@ -1,7 +1,8 @@
from app.api.services.loan_status import LoanStatusService
from app.api.services.customer_consent import CustomerConsentService
from app.api.services.authorization import AuthorizationService
from app.api.services.transaction import TransactionService
from app.api.services.loan import LoanService
from app.api.services.transaction_service import TransactionService
from app.api.services.loan_service import LoanService
from app.api.services.auth_service import AuthService
from app.api.services.dashboard_service import DashboardService
from app.api.services.repayment_service import RepaymentService
@@ -1,11 +1,60 @@
from flask import jsonify
from app.utils.logger import logger
from app.api.services.base_service import BaseService
from app.models.loan import Loan
import logging
from datetime import datetime
from flask import jsonify
# Configure logging
logger = logging.getLogger(__name__)
class LoanService(BaseService):
class Loan: # Mock Loan class for demonstration
def __init__(self, id, customer_id, account_id, offer_id, initial_loan_amount, current_loan_amount, status,
product_id, default_penalty_fee, continuous_fee, due_date, created_at, updated_at):
self.id = id
self.customer_id = customer_id
self.account_id = account_id
self.offer_id = offer_id
self.initial_loan_amount = initial_loan_amount
self.current_loan_amount = current_loan_amount
self.status = status
self.product_id = product_id
self.default_penalty_fee = default_penalty_fee
self.continuous_fee = continuous_fee
self.due_date = due_date
self.created_at = created_at
self.updated_at = updated_at
@staticmethod
def get_all_loans(customer_id=None, account_id=None, status=None, offer_id=None, product_id=None, start_date=None,
end_date=None, due_before=None, due_after=None, page=1, limit=20):
# This is a mock implementation. In a real application, this would query a database.
loans = []
# Create some dummy loans for testing
for i in range(limit):
loan = Loan(
id=i + (page - 1) * limit,
customer_id=customer_id or "customer123",
account_id=account_id or "account456",
offer_id=offer_id or "offer789",
initial_loan_amount=1000.00,
current_loan_amount=900.00,
status=status or "active",
product_id=product_id or "product101",
default_penalty_fee=50.00,
continuous_fee=10.00,
due_date=datetime.now(),
created_at=datetime.now(),
updated_at=datetime.now()
)
loans.append(loan)
total_count = 100 # Example total count
return loans, total_count
class LoanService:
"""
Service class for handling loan-related operations.
"""
@staticmethod
def process_request(filters=None):
"""
@@ -32,6 +81,16 @@ class LoanService(BaseService):
due_before = filters.get('due_before')
due_after = filters.get('due_after')
# Extract pagination parameters
page = int(filters.get('page', 1))
limit = int(filters.get('limit', 20))
# Ensure page and limit are valid
if page < 1:
page = 1
if limit < 1 or limit > 100:
limit = 20
# Convert string dates to datetime objects if provided
if start_date and isinstance(start_date, str):
start_date = datetime.fromisoformat(start_date.replace('Z', '+00:00'))
@@ -42,8 +101,8 @@ class LoanService(BaseService):
if due_after and isinstance(due_after, str):
due_after = datetime.fromisoformat(due_after.replace('Z', '+00:00'))
# Get loans with optional filters
loans = Loan.get_all_loans(
# Get loans with optional filters and pagination
loans, total_count = Loan.get_all_loans(
customer_id=customer_id,
account_id=account_id,
status=status,
@@ -52,7 +111,9 @@ class LoanService(BaseService):
start_date=start_date,
end_date=end_date,
due_before=due_before,
due_after=due_after
due_after=due_after,
page=page,
limit=limit
)
# Convert loans to dictionary format
@@ -74,14 +135,24 @@ class LoanService(BaseService):
'updated_at': loan.updated_at.isoformat() if loan.updated_at else None
})
# Calculate total pages
total_pages = (total_count + limit - 1) // limit
response_data = {
'loans': loans_data,
'count': len(loans_data)
'count': len(loans_data),
'pagination': {
'total_count': total_count,
'total_pages': total_pages,
'current_page': page,
'limit': limit,
'has_next': page < total_pages,
'has_prev': page > 1
}
}
return response_data
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
+115
View File
@@ -0,0 +1,115 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.api.enums.loan_status import LoanStatus
from app.models.customer import Customer
from app.models.loan import Loan
from app.models.repayment import Repayment
from app.utils.logger import logger
from app.api.schemas.repayment import RepaymentSchema
from app.api.services.base_service import BaseService
from app.api.enums import TransactionType
from threading import Thread
from app.extensions import db
class RepaymentService(BaseService):
TRANSACTION_TYPE = TransactionType.REPAYMENT
@staticmethod
def process_request(data):
"""
Process the Repayment request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
with db.session.begin():
validated_data = RepaymentService.validate_data(data, RepaymentSchema())
customer_id = validated_data.get('customerId')
request_id = validated_data.get('requestId')
loan_id = validated_data.get('debtId')
product_id = validated_data.get('productId')
account_id = validated_data.get('accountId')
customer = Customer.get_customer(customer_id)
if(RepaymentService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
# Save the repayment details
repayment = Repayment.create_repayment(
customer_id = customer_id,
loan_id = loan_id,
product_id = product_id
)
if not repayment:
logger.error(f"Failed to save repayment details")
return jsonify({
"message": "Failed to save repayment details."
}), 400
#Update Loan status
Loan.update_status(loan_id = loan_id, status = LoanStatus.REPAID)
transaction = RepaymentService.log_transaction(validated_data = validated_data)
if not transaction:
logger.error(f"Failed to log transaction")
return jsonify({
"message": "Failed to log transaction."
}), 400
else:
return jsonify({
"message": "Invalid Customer or Account"
}), 400
# Simulated processing logic
response_data = {
"customerId": customer_id,
"productId": product_id,
"debtId": loan_id,
"resultCode": "00",
"resultDescription": "Successful"
}
# return ResponseHelper.success(
# data=response_data,
# message="Repayment processed successfully"
# )
# Call Kafka in a background thread
thread = Thread(target=RepaymentService.async_send_to_kafka, args=(response_data, request_id, "LOAN_REPAYMENT"))
thread.start()
db.session.commit()
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {getattr(err, 'messages', str(err))}")
db.session.rollback()
return jsonify({
"message": "Validation exception"
}) , 422
except ValueError as err:
logger.error(f"{getattr(err, 'messages', str(err))}")
db.session.rollback()
return jsonify({
"message": str(err)
}) , 400
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
db.session.rollback()
return jsonify({
"message": "Internal Server Error"
}) , 500
@@ -1,11 +1,18 @@
from flask import jsonify
from app.utils.logger import logger
from app.api.services.base_service import BaseService
from app.models.transaction import Transaction
import logging
from datetime import datetime
from flask import jsonify
from app.models.transaction import Transaction
logger = logging.getLogger(__name__)
class TransactionService:
"""
Service class for handling transaction-related operations.
"""
class TransactionService(BaseService):
@staticmethod
def process_request(filters=None):
"""
@@ -28,19 +35,31 @@ class TransactionService(BaseService):
start_date = filters.get('start_date')
end_date = filters.get('end_date')
# Extract pagination parameters
page = int(filters.get('page', 1))
limit = int(filters.get('limit', 20))
# Ensure page and limit are valid
if page < 1:
page = 1
if limit < 1 or limit > 100:
limit = 20
# Convert string dates to datetime objects if provided
if start_date and isinstance(start_date, str):
start_date = datetime.fromisoformat(start_date.replace('Z', '+00:00'))
if end_date and isinstance(end_date, str):
end_date = datetime.fromisoformat(end_date.replace('Z', '+00:00'))
# Get transactions with optional filters
transactions = Transaction.get_all_transactions(
# Get transactions with optional filters and pagination
transactions, total_count = Transaction.get_all_transactions(
account_id=account_id,
transaction_type=transaction_type,
channel=channel,
start_date=start_date,
end_date=end_date
end_date=end_date,
page=page,
limit=limit
)
# Convert transactions to dictionary format
@@ -56,9 +75,20 @@ class TransactionService(BaseService):
'updated_at': transaction.updated_at.isoformat()
})
# Calculate total pages
total_pages = (total_count + limit - 1) // limit
response_data = {
'transactions': transactions_data,
'count': len(transactions_data)
'count': len(transactions_data),
'pagination': {
'total_count': total_count,
'total_pages': total_pages,
'current_page': page,
'limit': limit,
'has_next': page < total_pages,
'has_prev': page > 1
}
}
return response_data
@@ -67,4 +97,4 @@ class TransactionService(BaseService):
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
}), 500
+10 -2
View File
@@ -111,7 +111,8 @@ class Loan(db.Model):
@classmethod
def get_all_loans(cls, customer_id=None, account_id=None, status=None, offer_id=None,
product_id=None, start_date=None, end_date=None, due_before=None, due_after=None):
product_id=None, start_date=None, end_date=None, due_before=None, due_after=None,
page=1, limit=20):
"""
Get all loans with optional filtering
@@ -162,7 +163,14 @@ class Loan(db.Model):
# Order by created_at descending (newest first)
query = query.order_by(cls.created_at.desc())
return query.all()
# Get total count before pagination
total_count = query.count()
# Apply pagination
offset = (page - 1) * limit
query = query.limit(limit).offset(offset)
return query.all(), total_count
def to_dict(self):
"""
+51
View File
@@ -0,0 +1,51 @@
from datetime import datetime, timezone
from app.api.enums.loan_status import LoanStatus
from app.extensions import db
from app.models.customer import Customer
from app.models.loan import Loan
from sqlalchemy.exc import IntegrityError
class Repayment(db.Model):
__tablename__ = 'repayments'
id = db.Column(
db.Integer,
primary_key=True,
autoincrement=True,
)
loan_id = db.Column(db.String(50), nullable=False)
customer_id = db.Column(db.String(50), nullable=False)
product_id = db.Column(db.String(20), nullable=True)
created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc))
updated_at = db.Column(db.DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
@classmethod
def create_repayment(cls, customer_id, loan_id, product_id):
# Check customer exists
if not Customer.is_valid_customer(customer_id):
raise ValueError("Invalid customer")
# Check loan exists
loan = Loan.get_customer_loan(loan_id = loan_id, customer_id = customer_id)
# Check that the loan is active
if loan.status != LoanStatus.ACTIVE:
raise ValueError(f"Repayment cannot be processed. Loan status: ({loan.status})")
repayment = cls(
customer_id=customer_id,
loan_id=loan_id,
product_id=product_id,
)
try:
db.session.add(repayment)
except IntegrityError as err:
raise ValueError(f"Database integrity error: {err}")
return repayment
def __repr__(self):
return f'<Repayment {self.id}>'
+9 -2
View File
@@ -50,7 +50,7 @@ class Transaction(db.Model):
return cls.query.get(transaction_id)
@classmethod
def get_all_transactions(cls, account_id=None, transaction_type=None, channel=None, start_date=None, end_date=None):
def get_all_transactions(cls, account_id=None, transaction_type=None, channel=None, start_date=None, end_date=None, page=1, limit=20):
"""
Get all transactions with optional filtering
@@ -85,4 +85,11 @@ class Transaction(db.Model):
# Order by created_at descending (newest first)
query = query.order_by(cls.created_at.desc())
return query.all()
# Get total count before pagination
total_count = query.count()
# Apply pagination
offset = (page - 1) * limit
query = query.limit(limit).offset(offset)
return query.all(), total_count
+26 -17
View File
@@ -14,9 +14,15 @@
"version": "1.0.11"
},
"servers": [
{
"url": "http://localhost:4300"
},
{
"url": "http://localhost:4700"
},
{
"url": "http://www.simbrellang.net:4300"
},
{
"url": "http://www.simbrellang.net:4700"
},
@@ -26,6 +32,9 @@
{
"url": "http://www.simbrellang.net:14700"
},
{
"url" : "http://10.10.11.17:4300"
},
{
"url" : "http://10.10.11.17:4700"
}
@@ -39,14 +48,6 @@
"url": "https://www.simbrellang.net"
}
},
{
"name": "AuthorizeRefresh",
"description": "This feature will be used for refreshing authorized customers.",
"externalDocs": {
"description": "Find out more",
"url": "https://www.simbrellang.net"
}
},
{
"name": "Loans",
"description": "Get all loans with optional filtering.",
@@ -62,6 +63,14 @@
"description": "Find out more",
"url": "https://www.simbrellang.net"
}
},
{
"name": "Repayment",
"description": "Repayment Request.",
"externalDocs": {
"description": "Find out more",
"url": "https://www.simbrellang.net"
}
}
],
"paths": {
@@ -74,14 +83,14 @@
"/Authorize": {
"$ref": "../swagger/paths/Authorize.json"
},
"/AuthorizeRefresh": {
"$ref": "../swagger/paths/AuthorizeRefresh.json"
},
"/loans": {
"$ref": "../swagger/paths/Loans.json"
},
"/transactions": {
"$ref": "../swagger/paths/Transactions.json"
},
"/Repayment": {
"$ref": "../swagger/paths/Repayment.json"
}
},
"components": {
@@ -95,12 +104,6 @@
"AuthorizeRequest": {
"$ref": "../swagger/schemas/AuthorizeRequest.json"
},
"AuthorizeRefreshResponse": {
"$ref": "../swagger/schemas/AuthorizeRefreshResponse.json"
},
"AuthorizeRefreshRequest": {
"$ref": "../swagger/schemas/AuthorizeRefreshRequest.json"
},
"LoginRequest": {
"$ref": "../swagger/schemas/LoginRequest.json"
},
@@ -115,6 +118,12 @@
},
"TransactionsResponse": {
"$ref": "../swagger/schemas/TransactionsResponse.json"
},
"RepaymentRequest": {
"$ref": "../swagger/schemas/RepaymentRequest.json"
},
"RepaymentResponse": {
"$ref": "../swagger/schemas/RepaymentResponse.json"
}
},
"securitySchemes": {
-54
View File
@@ -1,54 +0,0 @@
{
"post": {
"tags": ["Authorize Refresh"],
"summary": "Customer Authorize Refresh Request",
"description": "Customer Authorize Refresh Request",
"operationId": "AuthorizeRefresh",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/AuthorizeRefreshRequest.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/AuthorizeRefreshRequest.json"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "../schemas/AuthorizeRefreshRequest.json"
}
}
}
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/AuthorizeRefreshResponse.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/AuthorizeRefreshResponse.json"
}
}
}
},
"400": {
"description": "Invalid request parameters"
},
"422": {
"description": "Validation exception"
},
"500": {
"description": "Internal server error"
}
}
}
}
+143 -120
View File
@@ -1,124 +1,147 @@
{
"get": {
"tags": [
"Loans"
],
"summary": "Get all loans with optional filtering",
"description": "Retrieve loans with various filter options including customer ID, account ID, status, etc.",
"operationId": "getLoans",
"parameters": [
{
"name": "customer_id",
"in": "query",
"description": "Filter by customer ID",
"required": false,
"schema": {
"type": "string"
},
"example": "CUST123"
},
{
"name": "account_id",
"in": "query",
"description": "Filter by account ID",
"required": false,
"schema": {
"type": "string"
},
"example": "ACC456"
},
{
"name": "status",
"in": "query",
"description": "Filter by loan status",
"required": false,
"schema": {
"type": "string"
},
"example": "active"
},
{
"name": "offer_id",
"in": "query",
"description": "Filter by offer ID",
"required": false,
"schema": {
"type": "string"
},
"example": "OFFER789"
},
{
"name": "product_id",
"in": "query",
"description": "Filter by product ID",
"required": false,
"schema": {
"type": "string"
},
"example": "PROD101"
},
{
"name": "start_date",
"in": "query",
"description": "Filter by start date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-01-01T00:00:00Z"
},
{
"name": "end_date",
"in": "query",
"description": "Filter by end date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-12-31T23:59:59Z"
},
{
"name": "due_before",
"in": "query",
"description": "Filter loans due before this date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-12-31T23:59:59Z"
},
{
"name": "due_after",
"in": "query",
"description": "Filter loans due after this date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-01-01T00:00:00Z"
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/LoansResponse.json"
}
}
}
},
"400": {
"description": "Invalid request"
},
"500": {
"description": "Internal server error"
"get": {
"tags": ["Loans"],
"summary": "Get all loans with optional filtering",
"description": "Retrieve loans with various filter options including customer ID, account ID, status, etc.",
"operationId": "getLoans",
"parameters": [
{
"name": "customer_id",
"in": "query",
"description": "Filter by customer ID",
"required": false,
"schema": {
"type": "string"
},
"example": "CUST123"
},
{
"name": "account_id",
"in": "query",
"description": "Filter by account ID",
"required": false,
"schema": {
"type": "string"
},
"example": "ACC456"
},
{
"name": "status",
"in": "query",
"description": "Filter by loan status",
"required": false,
"schema": {
"type": "string"
},
"example": "active"
},
{
"name": "offer_id",
"in": "query",
"description": "Filter by offer ID",
"required": false,
"schema": {
"type": "string"
},
"example": "OFFER789"
},
{
"name": "product_id",
"in": "query",
"description": "Filter by product ID",
"required": false,
"schema": {
"type": "string"
},
"example": "PROD101"
},
{
"name": "start_date",
"in": "query",
"description": "Filter by start date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-01-01T00:00:00Z"
},
{
"name": "end_date",
"in": "query",
"description": "Filter by end date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-12-31T23:59:59Z"
},
{
"name": "due_before",
"in": "query",
"description": "Filter loans due before this date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-12-31T23:59:59Z"
},
{
"name": "due_after",
"in": "query",
"description": "Filter loans due after this date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-01-01T00:00:00Z"
},
{
"name": "page",
"in": "query",
"description": "Page number for pagination",
"required": false,
"schema": {
"type": "integer",
"default": 1,
"minimum": 1
},
"example": 1
},
{
"name": "limit",
"in": "query",
"description": "Number of items per page (max 100)",
"required": false,
"schema": {
"type": "integer",
"default": 20,
"minimum": 1,
"maximum": 100
},
"example": 20
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/LoansResponse.json"
}
}
}
},
"400": {
"description": "Invalid request"
},
"500": {
"description": "Internal server error"
}
}
}
}
}
+56
View File
@@ -0,0 +1,56 @@
{
"post": {
"tags": [
"Repayment"
],
"summary": "Repayment Request",
"description": "Repayment Request",
"operationId": "Repayment",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/RepaymentRequest.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/RepaymentRequest.json"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "../schemas/RepaymentRequest.json"
}
}
}
},
"responses": {
"200": {
"description": "Repayment Successful",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/RepaymentResponse.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/RepaymentResponse.json"
}
}
}
},
"400": {
"description": "Invalid request"
},
"422": {
"description": "Validation exception"
},
"500": {
"description": "Internal server error"
}
}
}
}
+101 -78
View File
@@ -1,82 +1,105 @@
{
"get": {
"tags": [
"Transactions"
],
"summary": "Get all transactions with optional filtering",
"description": "Retrieve transactions with various filter options including account ID, type, channel, etc.",
"operationId": "getTransactions",
"parameters": [
{
"name": "account_id",
"in": "query",
"description": "Filter by account ID",
"required": false,
"schema": {
"type": "string"
},
"example": "ACC456"
},
{
"name": "type",
"in": "query",
"description": "Filter by transaction type",
"required": false,
"schema": {
"type": "string"
},
"example": "PAYMENT"
},
{
"name": "channel",
"in": "query",
"description": "Filter by channel",
"required": false,
"schema": {
"type": "string"
},
"example": "MOBILE"
},
{
"name": "start_date",
"in": "query",
"description": "Filter by start date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-01-01T00:00:00Z"
},
{
"name": "end_date",
"in": "query",
"description": "Filter by end date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-12-31T23:59:59Z"
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/TransactionsResponse.json"
}
}
}
},
"400": {
"description": "Invalid request"
},
"500": {
"description": "Internal server error"
"get": {
"tags": ["Transactions"],
"summary": "Get all transactions with optional filtering",
"description": "Retrieve transactions with various filter options including account ID, type, channel, etc.",
"operationId": "getTransactions",
"parameters": [
{
"name": "account_id",
"in": "query",
"description": "Filter by account ID",
"required": false,
"schema": {
"type": "string"
},
"example": "ACC456"
},
{
"name": "type",
"in": "query",
"description": "Filter by transaction type",
"required": false,
"schema": {
"type": "string"
},
"example": "PAYMENT"
},
{
"name": "channel",
"in": "query",
"description": "Filter by channel",
"required": false,
"schema": {
"type": "string"
},
"example": "MOBILE"
},
{
"name": "start_date",
"in": "query",
"description": "Filter by start date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-01-01T00:00:00Z"
},
{
"name": "end_date",
"in": "query",
"description": "Filter by end date (ISO format)",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2023-12-31T23:59:59Z"
},
{
"name": "page",
"in": "query",
"description": "Page number for pagination",
"required": false,
"schema": {
"type": "integer",
"default": 1,
"minimum": 1
},
"example": 1
},
{
"name": "limit",
"in": "query",
"description": "Number of items per page (max 100)",
"required": false,
"schema": {
"type": "integer",
"default": 20,
"minimum": 1,
"maximum": 100
},
"example": 20
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/TransactionsResponse.json"
}
}
}
},
"400": {
"description": "Invalid request"
},
"500": {
"description": "Internal server error"
}
}
}
}
}
@@ -1,7 +0,0 @@
{
"type": "object",
"properties": {},
"xml": {
"name": "AuthorizeRefreshRequest"
}
}
@@ -1,12 +0,0 @@
{
"type": "object",
"properties": {
"access_token": {
"type": "string",
"example": "access_token"
}
},
"xml": {
"name": "AuthorizeRefreshResponse"
}
}
+102 -73
View File
@@ -1,79 +1,108 @@
{
"type": "object",
"properties": {
"loans": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"customer_id": {
"type": "string",
"example": "CUST123"
},
"account_id": {
"type": "string",
"example": "ACC456"
},
"offer_id": {
"type": "string",
"example": "OFFER789"
},
"initial_loan_amount": {
"type": "number",
"format": "float",
"example": 10000.0
},
"current_loan_amount": {
"type": "number",
"format": "float",
"example": 8500.0
},
"status": {
"type": "string",
"example": "active"
},
"product_id": {
"type": "string",
"example": "PROD101"
},
"default_penalty_fee": {
"type": "number",
"format": "float",
"example": 500.0
},
"continuous_fee": {
"type": "number",
"format": "float",
"example": 50.0
},
"due_date": {
"type": "string",
"format": "date-time",
"example": "2023-12-31T23:59:59Z"
},
"created_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-15T10:30:00Z"
},
"updated_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-20T14:45:00Z"
}
}
}
},
"count": {
"type": "object",
"properties": {
"loans": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"customer_id": {
"type": "string",
"example": "CUST123"
},
"account_id": {
"type": "string",
"example": "ACC456"
},
"offer_id": {
"type": "string",
"example": "OFFER789"
},
"initial_loan_amount": {
"type": "number",
"format": "float",
"example": 10000.0
},
"current_loan_amount": {
"type": "number",
"format": "float",
"example": 8500.0
},
"status": {
"type": "string",
"example": "active"
},
"product_id": {
"type": "string",
"example": "PROD101"
},
"default_penalty_fee": {
"type": "number",
"format": "float",
"example": 500.0
},
"continuous_fee": {
"type": "number",
"format": "float",
"example": 50.0
},
"due_date": {
"type": "string",
"format": "date-time",
"example": "2023-12-31T23:59:59Z"
},
"created_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-15T10:30:00Z"
},
"updated_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-20T14:45:00Z"
}
}
}
},
"xml": {
"name": "LoansResponse"
"count": {
"type": "integer",
"example": 1
},
"pagination": {
"type": "object",
"properties": {
"total_count": {
"type": "integer",
"example": 100
},
"total_pages": {
"type": "integer",
"example": 5
},
"current_page": {
"type": "integer",
"example": 1
},
"limit": {
"type": "integer",
"example": 20
},
"has_next": {
"type": "boolean",
"example": true
},
"has_prev": {
"type": "boolean",
"example": false
}
}
}
}
},
"xml": {
"name": "LoansResponse"
}
}
+36
View File
@@ -0,0 +1,36 @@
{
"type": "object",
"properties": {
"msisdn": {
"type": "string",
"example": "3451342"
},
"debtId": {
"type": "string",
"example": "10"
},
"productId": {
"type": "string",
"example": "101"
},
"transactionId": {
"type": "string",
"example": "20171209232115"
},
"customerId": {
"type": "string",
"example": "CID0000025585"
},
"channel": {
"type": "string",
"example": "USSD"
},
"accountId": {
"type": "string",
"example": "ACN8263457"
}
},
"xml": {
"name": "RepaymentRequest"
}
}
@@ -0,0 +1,28 @@
{
"type": "object",
"properties": {
"customerId": {
"type": "string",
"example": "CN621868"
},
"productId": {
"type": "string",
"example": "101"
},
"debtId": {
"type": "string",
"example": "273194670"
},
"resultCode": {
"type": "string",
"example": "00"
},
"resultDescription": {
"type": "string",
"example": "Successful"
}
},
"xml": {
"name": "RepaymentResponse"
}
}
+73 -44
View File
@@ -1,50 +1,79 @@
{
"type": "object",
"properties": {
"transactions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"transaction_id": {
"type": "string",
"example": "TRX123456"
},
"account_id": {
"type": "string",
"example": "ACC456"
},
"type": {
"type": "string",
"example": "PAYMENT"
},
"channel": {
"type": "string",
"example": "MOBILE"
},
"created_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-15T10:30:00Z"
},
"updated_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-15T10:30:00Z"
}
}
}
},
"count": {
"type": "object",
"properties": {
"transactions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"example": 1
},
"transaction_id": {
"type": "string",
"example": "TRX123456"
},
"account_id": {
"type": "string",
"example": "ACC456"
},
"type": {
"type": "string",
"example": "PAYMENT"
},
"channel": {
"type": "string",
"example": "MOBILE"
},
"created_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-15T10:30:00Z"
},
"updated_at": {
"type": "string",
"format": "date-time",
"example": "2023-01-15T10:30:00Z"
}
}
}
},
"xml": {
"name": "TransactionsResponse"
"count": {
"type": "integer",
"example": 1
},
"pagination": {
"type": "object",
"properties": {
"total_count": {
"type": "integer",
"example": 100
},
"total_pages": {
"type": "integer",
"example": 5
},
"current_page": {
"type": "integer",
"example": 1
},
"limit": {
"type": "integer",
"example": 20
},
"has_next": {
"type": "boolean",
"example": true
},
"has_prev": {
"type": "boolean",
"example": false
}
}
}
}
},
"xml": {
"name": "TransactionsResponse"
}
}