{
    "openapi": "3.0.0",
    "info": {
        "title": "Connector API",
        "description": "API documentation for Ultimate POS Connector module.",
        "contact": {
            "name": "API Support"
        },
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "http://localhost/dashboard/agent/public",
            "description": "API Server"
        }
    ],
    "paths": {
        "/connector/api/business-location": {
            "get": {
                "tags": [
                    "Business Location"
                ],
                "summary": "List business locations",
                "description": "Returns list of active business locations",
                "operationId": "6a2ac6a5170158f5a94bedb6c76d009c",
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/connector/api/business-location/{location}": {
            "get": {
                "tags": [
                    "Business Location"
                ],
                "summary": "Get specified business location",
                "description": "Get the specified business location",
                "operationId": "06b09aa817b083c74aaa5183c906c1e5",
                "parameters": [
                    {
                        "name": "location",
                        "in": "path",
                        "description": "Location ID",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/connector/api/contactapi": {
            "get": {
                "tags": [
                    "Contacts"
                ],
                "summary": "List contacts (customers/suppliers)",
                "description": "Returns paginated list of contacts for business",
                "operationId": "1790ad972d650cecc8e4c2635fd5a3f0",
                "parameters": [
                    {
                        "name": "type",
                        "in": "query",
                        "description": "Type: customer or supplier",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "name",
                        "in": "query",
                        "description": "Search by name",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "contact_id",
                        "in": "query",
                        "description": "Search by Contact ID",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 10
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/connector/api/product": {
            "get": {
                "tags": [
                    "Products"
                ],
                "summary": "List products",
                "description": "Returns paginated list of products with filters",
                "operationId": "7aa9ea48604a4bce60eb4b489186a36c",
                "parameters": [
                    {
                        "name": "name",
                        "in": "query",
                        "description": "Filter by product name",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sku",
                        "in": "query",
                        "description": "Filter by SKU",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "brand_id",
                        "in": "query",
                        "description": "Filter by Brand ID",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "category_id",
                        "in": "query",
                        "description": "Filter by Category ID",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "location_id",
                        "in": "query",
                        "description": "Filter by Location ID",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 10
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/connector/api/sell": {
            "get": {
                "tags": [
                    "Sales"
                ],
                "summary": "List sales transactions",
                "description": "Returns paginated list of sales transactions",
                "operationId": "3e1fb034c2430bbecaf399800bd58928",
                "parameters": [
                    {
                        "name": "location_id",
                        "in": "query",
                        "description": "Location ID",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "contact_id",
                        "in": "query",
                        "description": "Contact ID",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "payment_status",
                        "in": "query",
                        "description": "Payment status (paid, due, partial)",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "start_date",
                        "in": "query",
                        "description": "Format: YYYY-MM-DD",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "end_date",
                        "in": "query",
                        "description": "Format: YYYY-MM-DD",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 10
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/connector/api/sell-return": {
            "post": {
                "tags": [
                    "Sales"
                ],
                "summary": "Create a Sales Return and optionally reduce another invoice",
                "description": "Creates a sales return transaction for an existing sale and optionally applies the return amount to reduce the outstanding due amount on another target sale/invoice.",
                "operationId": "c854c8b3a95a024d52333d1ffa5e1b49",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "transaction_id",
                                    "products"
                                ],
                                "properties": {
                                    "transaction_id": {
                                        "description": "ID of original sale transaction to return items from",
                                        "type": "integer",
                                        "example": 157
                                    },
                                    "invoice_no": {
                                        "description": "Optional custom reference/invoice number for return",
                                        "type": "string",
                                        "example": "SR2026/0001"
                                    },
                                    "discount_type": {
                                        "description": "fixed or percentage",
                                        "type": "string",
                                        "example": "fixed"
                                    },
                                    "discount_amount": {
                                        "type": "number",
                                        "example": 0
                                    },
                                    "tax_id": {
                                        "type": "integer",
                                        "nullable": true
                                    },
                                    "transaction_date": {
                                        "type": "string",
                                        "example": "2026-07-23 18:00:00"
                                    },
                                    "products": {
                                        "type": "array",
                                        "items": {
                                            "properties": {
                                                "sell_line_id": {
                                                    "type": "integer",
                                                    "example": 139
                                                },
                                                "quantity": {
                                                    "type": "number",
                                                    "example": 2
                                                },
                                                "unit_price": {
                                                    "type": "number",
                                                    "example": 100
                                                },
                                                "variation_id": {
                                                    "type": "integer",
                                                    "example": 205
                                                },
                                                "product_id": {
                                                    "type": "integer",
                                                    "example": 157
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "reduce_invoice_id": {
                                        "description": "Optional target sale/invoice ID whose due amount will be reduced by the return amount",
                                        "type": "integer",
                                        "example": 160
                                    },
                                    "reduce_amount": {
                                        "description": "Optional custom amount to reduce on target invoice (defaults to return total or target due)",
                                        "type": "number",
                                        "example": 200
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sales return created successfully"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/connector/api/user": {
            "get": {
                "tags": [
                    "Users"
                ],
                "summary": "List users",
                "description": "Returns list of users in business",
                "operationId": "b833e2cc3120224db617c853a6a6bdf1",
                "parameters": [
                    {
                        "name": "service_staff",
                        "in": "query",
                        "description": "Filter service staff (1 or 0)",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "description": "Enter token in format: Bearer <token>",
                "bearerFormat": "JWT",
                "scheme": "bearer"
            }
        }
    },
    "tags": [
        {
            "name": "Business Location",
            "description": "Business Location"
        },
        {
            "name": "Contacts",
            "description": "Contacts"
        },
        {
            "name": "Products",
            "description": "Products"
        },
        {
            "name": "Sales",
            "description": "Sales"
        },
        {
            "name": "Users",
            "description": "Users"
        }
    ]
}