openapi: 3.0.0
info:
  title: Finance Microservice API
  description: |
    Financial management and payment processing microservice.
    Handles transactions, wallet operations, loan management, and investment tracking.
    
    **Database**: PROJ-microfinance_bank (NOTE: Custom override)
    **Service ID**: finance-service
    **Version**: 1.0.0
  version: 1.0.0
  contact:
    name: Finance Team
    email: finance@emmanylcode.local

servers:
  - url: http://localhost/projects/SMS-MICROSERVICES/finance-service/public
    description: Development Finance Service
  - url: https://finance.emmanylcode.local
    description: Production Finance Service

security:
  - BearerAuth: []

components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  schemas:
    Transaction:
      type: object
      properties:
        id:
          type: integer
          format: int64
        user_id:
          type: integer
          format: int64
        type:
          type: string
          enum: [deposit, withdrawal, transfer, investment, loan]
        amount:
          type: number
          format: float
        currency:
          type: string
          example: NGN
        status:
          type: string
          enum: [pending, completed, failed]
        created_at:
          type: string
          format: date-time

    Wallet:
      type: object
      properties:
        id:
          type: integer
          format: int64
        user_id:
          type: integer
          format: int64
        balance:
          type: number
          format: float
        currency:
          type: string
        updated_at:
          type: string
          format: date-time

paths:
  /api/finance/wallet/{userId}:
    get:
      summary: Get user wallet
      description: Retrieve user wallet and balance information
      operationId: getWallet
      tags:
        - Wallet
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Wallet information retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Wallet'
        '401':
          description: Unauthorized
        '404':
          description: Wallet not found

  /api/finance/transactions/{userId}:
    get:
      summary: Get user transactions
      description: Retrieve transaction history for a user
      operationId: getTransactions
      tags:
        - Transactions
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: integer
        - name: limit
          in: query
          schema:
            type: integer
            default: 50
        - name: offset
          in: query
          schema:
            type: integer
            default: 0
      responses:
        '200':
          description: Transactions retrieved
          content:
            application/json:
              schema:
                type: object
                properties:
                  transactions:
                    type: array
                    items:
                      $ref: '#/components/schemas/Transaction'
                  total:
                    type: integer
        '401':
          description: Unauthorized

tags:
  - name: Wallet
    description: Wallet management endpoints
  - name: Transactions
    description: Transaction endpoints
