Skip to content

Fix message API conformance and add bulk-send/send-group commands#292

Draft
SeanAlexanderHarris wants to merge 2 commits intomainfrom
002-fix-message-api-conformance
Draft

Fix message API conformance and add bulk-send/send-group commands#292
SeanAlexanderHarris wants to merge 2 commits intomainfrom
002-fix-message-api-conformance

Conversation

@SeanAlexanderHarris
Copy link
Contributor

Summary

  • Fix Message model to match Prolific Messages API schema: rename datetime_createdsent_at, add missing id/type/channel_id fields, replace map[string]any Data with typed MessageData struct (exposing study_id and category)
  • Eliminate UnreadMessage struct — both /messages/ and /messages/unread/ return the same Message schema per API docs
  • Remove post-processing loop in GetMessages that extracted study_id from the Data map — the typed struct handles this via JSON unmarshaling
  • Update list output to 6 curated columns: ID, Sender ID, Study ID, Category, Sent At, Body (breaking change — old output was incorrect/incomplete)
  • Add bulk-send command (POST /api/v1/messages/bulk/) for sending messages to multiple participants
  • Add send-group command (POST /api/v1/messages/participant-group/) for messaging a participant group (study_id optional)
  • Add BulkSendMessage and SendGroupMessage to client.API interface with implementations
  • Regenerate mocks; all tests pass, lint clean, 99.2% coverage on cmd/message

Test plan

  • make test — all 24 packages pass
  • make lint — 0 issues
  • go test ./cmd/message/... -v — 17 tests pass (99.2% coverage)
  • Verified --help output for all 4 message subcommands
  • Model verification: Message struct matches API schema, UnreadMessage deleted, MessageData added
  • Live API verification with PROLIFIC_TOKEN (see specs/002-fix-message-api-conformance/quickstart.md)

🤖 Generated with Claude Code

Align CLI message commands with the current Prolific Messages API:
- Fix Message model fields (datetime_created→sent_at, add id/type/channel_id)
- Replace map[string]any Data with typed MessageData struct (study_id, category)
- Eliminate UnreadMessage struct; unify both endpoints on Message
- Remove post-processing loop in GetMessages (JSON unmarshaling handles it)
- Update list output to 6 curated columns (ID, Sender ID, Study ID, Category, Sent At, Body)
- Add bulk-send command (POST /api/v1/messages/bulk/)
- Add send-group command (POST /api/v1/messages/participant-group/)
- Add BulkSendMessage and SendGroupMessage to client.API interface
- Regenerate mocks; all tests pass, lint clean (99.2% coverage on cmd/message)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prolific-snyk
Copy link

prolific-snyk commented Feb 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

…eated)

The Prolific API documentation was inaccurate — the real API returns
"sender" (not "sender_id") for the unread endpoint and "datetime_created"
(not "sent_at") for timestamps. This adds both sender fields with a
GetSenderID() coalescing method and reverts the timestamp json tag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@SeanAlexanderHarris SeanAlexanderHarris self-assigned this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants