sheets endpoints — Google Sheets settings & invoices¶
Endpoints to configure and interact with the Google Sheets used as the invoice source. The router exposes settings management, invoice retrieval, confirmation updates and a connection test endpoint.
Routes
POST /settings— Update Google Sheets settings- Body:
SheetSettingsUpdate(JSON). Typical fields:spreadsheet_id,sheet_id,date_column,invoice_number_column,confirmation_column,order_place_column,confirmation_success_value,confirmation_fail_value. -
Returns: updated
SheetSettings. -
GET /settings— Get current sheet settings -
Returns:
SheetSettingsobject. -
DELETE /settings— Reset sheet settings to defaults -
Returns:
SheetSettings(reset state). -
GET /invoices/{year}/{month}— Get invoices for a month - Path params:
year(int),month(int). -
Returns:
InvoicesResponsewithcountandinvoices(list ofInvoiceobjects withsheet_row,invoice_number,order_place,date,confirmation_status). -
POST /invoices/confirmation— Update a single invoice confirmation - Body/form:
row(int),status(str). -
Behavior: calls
Sheets_Manager.update_invoice_confirmationand returnsInvoiceConfirmationResponse. -
POST /invoices/confirmation/bulk— Bulk confirmation updates - Body:
BulkConfirmationUpdate(JSON) containing list of{ row:int, status:str }entries. -
Behavior: calls
Sheets_Manager.bulk_update_confirmations(usesbatchUpdateunder the hood) and returnsBulkConfirmationResponse. -
GET /test-connection— Test configured Sheets connection - Returns:
ConnectionTestResponsecontainingspreadsheet_title,spreadsheet_id,sheetslist, andconfigured_sheet_id.
Operational notes
get_invoices_for_monthuses an optimized bulk approach: it finds matching rows by scanning the configured date column, then fetches the minimal rectangular range needed in a single API call and constructsInvoiceobjects for each invoice number found.- Ensure
SheetSettingsare configured correctly before calling invoice endpoints — missingspreadsheet_idor column mappings will fail. - Use
bulkupdate when updating many rows to minimize API calls;bulk_update_confirmationsmapsrow+statusinto abatchUpdatecall.
Examples
- Fetch invoices for March 2024:
curl "http://localhost:8000/api/v1/invoice/invoices/2024/3"
- Update a single confirmation:
curl -X POST "http://localhost:8000/api/v1/invoice/invoices/confirmation" \
-d "row=123" -d "status=SUCCESS"