Skip to content

Add JSON API support for user data exports#2786

Merged
flavorjones merged 1 commit intobasecamp:mainfrom
robzolkos:exports-api-parity
Apr 8, 2026
Merged

Add JSON API support for user data exports#2786
flavorjones merged 1 commit intobasecamp:mainfrom
robzolkos:exports-api-parity

Conversation

@robzolkos
Copy link
Copy Markdown
Collaborator

Summary

Add JSON API support for user data exports and document the export API surface.

What changed

  • add JSON responses to Users::DataExportsController#create and #show
  • add app/views/users/data_exports/show.json.jbuilder
  • add controller tests covering JSON create/show, polling states, auth, and rate limiting
  • document export endpoints in docs/API.md, including existing account export JSON endpoints and new user data export JSON endpoints

API behavior

New JSON support

  • POST /:account_slug/users/:user_id/data_exports.json
  • GET /:account_slug/users/:user_id/data_exports/:id.json

Response shape:

  • id
  • status
  • created_at
  • download_url when completed and attached

Notes

  • user data exports remain self-service only: you can only create/show exports for your own user record
  • download URLs still require authenticated access by the export owner
  • this follows the existing account export JSON pattern

Tests

  • bin/rails test test/controllers/users/data_exports_controller_test.rb test/controllers/accounts/exports_controller_test.rb

Copilot AI review requested due to automatic review settings April 2, 2026 21:21
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JSON API support for user data exports, mirroring the existing account exports JSON endpoints. It enables clients to create personal data exports and poll their status asynchronously, with support for multiple export states (pending, processing, completed, failed).

Changes:

  • Add JSON format handlers to Users::DataExportsController#create and #show actions
  • Create show.json.jbuilder template to serialize export objects with conditional download URLs
  • Add comprehensive controller tests covering JSON requests, authorization, rate limiting, and different export states
  • Document the new JSON export endpoints in docs/API.md with request/response examples

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
app/controllers/users/data_exports_controller.rb Modified create/show actions to handle JSON responses via respond_to blocks; updated set_export to load all export states for JSON requests (vs only completed for HTML)
app/views/users/data_exports/show.json.jbuilder New Jbuilder template that serializes export id, status, created_at, and conditionally includes download_url when export is completed and file is attached
test/controllers/users/data_exports_controller_test.rb Added 6 new test cases covering JSON create/show, different export states, authorization, and rate limiting scenarios
docs/API.md Added comprehensive documentation for both account exports and user data exports JSON endpoints with response schema examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@robzolkos robzolkos requested a review from flavorjones April 7, 2026 15:19
Copy link
Copy Markdown
Member

@flavorjones flavorjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flavorjones flavorjones merged commit 8201c2a into basecamp:main Apr 8, 2026
9 of 10 checks passed
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.

3 participants