2.7 KiB
2.7 KiB
Phase 2: Bitrix24 API Integration
Summary
- Implement Bitrix24 as a first-class
SourceAdapter. - Use
tmp/get_calls_via_Bitrix24_REST_v1.pyas the working prototype for REST calls, pagination, rate limiting, recording downloads, and diagnostics. - Target CLI:
b24calls discover --source bitrix24. - Download call recordings during discovery so the existing validation, spool, transcription, and export pipeline continues to operate on local audio files.
Commit Plan
-
docs: add phase 2 Bitrix24 implementation plan- Add this plan.
- Document required webhook scopes:
telephonyanddisk;useris only needed for optional user enrichment.
-
config: expand Bitrix24 settings- Extend
Bitrix24Configwithrecordings_dir,download_recordings,enrich_users, andtimeout_seconds. - Add
B24CALLS_BITRIX24_*environment overrides. - Update
configs/example.toml.
- Extend
-
bitrix24: add REST client- Add a standard-library REST client.
- Support
voximplant.statistic.get,disk.file.get, optionaluser.get, form-encoded POST, pagination, rate limiting, timeouts, and clear diagnostics.
-
bitrix24: implement source adapter and recording download- Add
Bitrix24Source. - Download by
CALL_RECORD_URL, or byRECORD_FILE_ID -> disk.file.get -> DOWNLOAD_URL. - Store recordings in
bitrix24.recordings_dir. - Skip existing non-empty local files.
- Use Bitrix24 call
IDassource_idand store raw call metadata.
- Add
-
discovery: route discover by source- Add
b24calls discover --source local|bitrix24, defaultlocal. - Register downloaded Bitrix24 recordings through the existing SQLite discovery flow.
- Print
download_failedin discovery summaries.
- Add
-
tests: cover Bitrix24 discovery- Cover REST pagination and errors with fake HTTP transport.
- Cover direct URL download,
RECORD_FILE_IDdownload, missing recordings, repeat discovery, config overrides, and CLI source routing. - Keep local discovery tests unchanged.
-
docs: document Bitrix24 workflow- Update README with command examples and webhook scope requirements.
- Mark
tmp/get_calls_via_Bitrix24_REST_v1.pyas a diagnostic prototype, not the runtime path.
Verification
python -m compileall src testspython -m unittest discover -s tests- Manual smoke test with a real webhook:
b24calls discover --source bitrix24 --start YYYY-MM-DD --end YYYY-MM-DDb24calls validateb24calls spoolb24calls transcribe --limit 1
Assumptions
- Recording download happens in
discover. telephonyscope is required for call statistics.diskscope is required forRECORD_FILE_IDdownloads.userscope is optional and only needed when user enrichment is enabled.