{% extends "base.html" %} {% block title %}API Documentation - Project Ploughshares{% endblock %} {% block content %}

Project Ploughshares API Documentation

Endpoints

1. List All Transactions

GET /api/transactions

Complete Example:
curl -X GET "http://{{ server_name }}/api/transactions"
Response:
[
  {
    "transaction_id": 1,
    "transaction_no": "78708",
    "transaction_type": "Subcontract",
    "company_division": "C A E Inc",
    "amount": 0.00,
    "recipient": "US Army",
    "created_at": "2023-07-02T12:34:56.789012"
  },
  {
    "transaction_id": 2,
    "transaction_no": "78709",
    "transaction_type": "Purchase Order",
    "company_division": "Example Corp",
    "amount": 1000.00,
    "recipient": "Test Recipient",
    "created_at": "2023-07-03T10:11:12.131415"
  }
]

2. Get Transaction Details

GET /api/transaction/{id}

Complete Example:
curl -X GET "http://{{ server_name }}/api/transaction/1"
Response:
{
  "transaction": {
    "transaction_id": 1,
    "transaction_no": "78708",
    "transaction_type": "Subcontract",
    "company_division": "C A E Inc",
    "address_1": "5585 Cote de Liesse",
    "address_2": "P O Box 1800",
    "city": "ST LAURENT",
    "province": "QC",
    "region": "Quebec",
    "postal_code": "H4T 1G6",
    "is_primary": true,
    "source_date": "2023-08-23",
    "source_description": "Source Description",
    "description": "7000XR Full Flight Simulator (FFS) in Global 6000/6500 configuration (subc)",
    "amount": 0.00,
    "recipient": "US Army",
    "commodity_class": "Aerospace",
    "contract_number": "SUMMARY",
    "comments": "Subcontract with Leidos, US, through CAE Defense & Security...",
    "created_at": "2023-07-02T12:34:56.789012"
  },
  "documents": [
    {
      "document_id": 1,
      "transaction_id": 1,
      "filename": "78708_20240501.pdf",
      "file_path": "1/78708_20240501.pdf",
      "document_type": "Contract",
      "description": "Contract document",
      "note": "Original contract",
      "upload_date": "2023-07-02T12:34:56.789012"
    }
  ]
}

3. Create New Transaction

POST /api/transaction

Complete Example:
curl -X POST "http://{{ server_name }}/api/transaction" \
  -H "Content-Type: application/json" \
  -d '{
    "transaction_no": "12345",
    "transaction_type": "Purchase Order",
    "company_division": "Example Corp",
    "description": "Test transaction",
    "amount": 1000.00,
    "recipient": "Test Recipient"
  }'
Response:
{
  "message": "Transaction created successfully",
  "transaction_id": 2
}

4. Update Transaction

PUT /api/transaction/{id}

Complete Example:
curl -X PUT "http://{{ server_name }}/api/transaction/2" \
  -H "Content-Type: application/json" \
  -d '{
    "transaction_type": "Purchase Order",
    "company_division": "Updated Corp",
    "description": "Updated transaction",
    "amount": 1500.00,
    "recipient": "Updated Recipient"
  }'
Response:
{
  "message": "Transaction updated successfully"
}

5. Delete Transaction

DELETE /api/transaction/{id}

Complete Example:
curl -X DELETE "http://{{ server_name }}/api/transaction/3"
Response:
{
  "message": "Transaction deleted successfully"
}
{% endblock %} {% block scripts %} {% endblock %}