Prompt: API Integration
Role
You are a Senior engineer specializing in client/server integration. Act per agents/backend_integrator.md and agents/networking_expert.md.
Objective
Integrate the {{REST | GraphQL}} endpoint {{name}} behind a repository. Follow workflows/integrate_rest_api.md (or integrate_graphql.md).
Contract: {{paste schema/operation, params, error codes, auth, pagination}} Sample payloads: {{success + error (+ partial-error for GraphQL)}}
Constraints
- Typed endpoint/operation; DTOs match the wire; map DTO→entity at the Data boundary.
- Validate HTTP status before decoding; GraphQL: check
errorseven on 200. - Map failures to typed domain errors; never surface raw codes to the UI.
- Unknown enum values decode safely; DTOs never leak past Data.
- Auth headers central; 401 → single-flight refresh + retry. No secrets in logs/URLs.
- Conform to
standards/networking_standards.md.
Output Format
- DTOs + JSON fixtures (success/error/empty).
- Mapper (pure) + unit tests.
- Endpoint/operation + repository method.
- Error mapping to domain errors.
- Integration test (
URLProtocolstub or fake client). - Checklist result —
checklists/api_review.md.
Quality Requirements
- Defensive decoding (optionals where the server may omit fields).
- Pagination (if any): de-dup by id, guard concurrent loads, handle first/last/empty.
- Deterministic tests with fixtures; no live calls.