[DO NOT MERGE] - Example endpoint implemented by a custom AI agent#2812
Draft
[DO NOT MERGE] - Example endpoint implemented by a custom AI agent#2812
Conversation
5 tasks
jzbahrai
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary | Résumé
This PR is a simple example of the
rest-endpoint-builderagent adding a new API endpoint/service/<id>/billing/sms-costwhich tallies up thefragment_countandtotal_costfor a service within a given date range.Example output:

Promp & chat
I have a good understanding of the existing patterns. Let me check the
FactBillingmodel to understand the columns available for the SMS cost query, and also readdefinitions.pyfor shared definitions.Now I have full context. The FactBilling model has
service_id,bst_date,notification_type,billable_units,rate_multiplier,rate, andbilling_totalcolumns.I'll add:
rest.pyNow let me add test stubs. Let me check how the existing tests import and structure things:
Now I'll append tests for the new endpoint at the end of the test file:
The import ordering in
rest.pyneeds fixing —from datetime import dateshould come before Flask imports per standard Python import ordering (stdlib before third-party).All changes are complete. Here's a summary of what was added:
Edited files:
billing_schemas.py— added get_sms_cost_for_service_schema requiring start_date and end_date string properties with "format": "date"fact_billing_dao.py— added dao_fetch_sms_cost_for_service_in_range(service_id, start_date, end_date) that queries FactBilling for SMS-type rows, returning total fragment_count (billable_units × rate_multiplier) and total_cost (fragments × rate)rest.py— added GET /service/uuid:service_id/billing/sms-cost?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD route that validates params, checks start < end, calls the DAO, and returns {start_date, end_date, fragment_count, total_cost}test_billing.py— added TestGetSmsCostForService class with 4 tests: happy path with data, zero-result case, missing dates (400), andstart_dateafterend_date(400)Checklist:
billing_schemas.py— edited (addedget_sms_cost_for_service_schema)fact_billing_dao.py— edited (addeddao_fetch_sms_cost_for_service_in_range)rest.py— edited (added new route + updated imports)test_billing.py— edited (added test class)__init__.pychange needed — thebilling_blueprintis already registeredTest instructions | Instructions pour tester la modification
TODO: Fill in test instructions for the reviewer.
Release Instructions | Instructions pour le déploiement
None.
Reviewer checklist | Liste de vérification du réviseur