openapi: 3.0.3
info:
  title: ChamaPay API
  description: Financial Infrastructure for African Savings Groups
  version: 1.0.0
  contact:
    name: ChamaPay Support
    email: api-support@chamapay.co.ke
  license:
    name: Commercial
servers:
  - url: https://api.chamapay.co.ke/v1
    description: Production server
  - url: http://localhost/chamapay/api/v1
    description: Local development server
tags:
  - name: Members
    description: Member management
  - name: Contributions
    description: Contribution tracking
  - name: Loans
    description: Loan management
paths:
  /members:
    get:
      tags:
        - Members
      summary: List all members
      description: Retrieve a paginated list of all members
      parameters:
        - name: status
          in: query
          schema:
            type: string
          description: Filter by status (Active, Inactive, Pending)
        - name: page
          in: query
          schema:
            type: integer
            default: 1
          description: Page number
        - name: limit
          in: query
          schema:
            type: integer
            default: 50
            maximum: 100
          description: Results per page
        - name: search
          in: query
          schema:
            type: string
          description: Search by name, email, or member ID
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        member_id:
                          type: string
                        first_name:
                          type: string
                        last_name:
                          type: string
                        email:
                          type: string
                        phone:
                          type: string
                        status:
                          type: string
                        created_at:
                          type: string
                          format: date-time
                  meta:
                    type: object
                    properties:
                      total:
                        type: integer
                      page:
                        type: integer
                      limit:
                        type: integer
                      pages:
                        type: integer
    post:
      tags:
        - Members
      summary: Create a new member
      description: Register a new member
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - first_name
                - last_name
                - email
                - phone
              properties:
                first_name:
                  type: string
                last_name:
                  type: string
                email:
                  type: string
                  format: email
                phone:
                  type: string
                id_number:
                  type: string
      security:
        - BearerAuth: []
      responses:
        '201':
          description: Member created successfully
        '400':
          description: Bad Request
        '409':
          description: Conflict - Member already exists
  /contributions:
    get:
      tags:
        - Contributions
      summary: List contributions
      description: Retrieve contribution records with filtering
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
