Skip to content

Add a typed profile resource for the self-service profile.json endpoint - #51

Merged
sevgibson merged 1 commit into
masterfrom
DP-206-add-put-endpoint
Sep 10, 2026
Merged

sevgibson merged 1 commit into
masterfrom
DP-206-add-put-endpoint

Conversation

@sevgibson

@sevgibson sevgibson commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

Resource#save always PUTs to {collection}/{id}.json — the users endpoint, which is account-admin-gated on p.core. So there was no way to write the singular self-service profile.json (Api::V3::ProfilesController), where a user updates their own record (including work_phone/mobile_number) without admin rights.

This unblocks p.int's Pipeline Phone work_phone sync (DP-206): it sets a provisioned user's work_phone as that user themselves.

What

A typed Pipeline::Profile resource, following the gem's existing inheritance (same shape as Pipeline::Import — a Resource subclass in its own file):

  • pipeline.profile accessor mirrors the existing user/account singular accessors (loads profile.json).
  • Pipeline::Profile#save overrides only what differs from Resource#save: the endpoint (profile.json, not profiles/:id) and the body key (:user, since ProfilesController#update reads params[:user]). Attributes + dirty-tracking are inherited, so save still sends only changed keys.
p = pipeline.profile          # GET /api/v3/profile.json (the authed user)
p.work_phone = "+15551234567"
p.save                        # PUT /api/v3/profile.json → { user: { work_phone } }

Version bump 1.0.11 → 1.0.12.

Tests

spec/pipeline/profile_spec.rb — loads from profile.json, saves changed attributes back under the :user key, and raises the mapped exception (403 → PermissionDeniedError) on refusal. WebMock, mirroring the existing endpoint spec style.

Consumers

p.int will bump to this revision and change sync_user_work_phone to pipeline_api_for_user(user_id).profile → set work_phone → save, guarding against the no-token fallback (which would otherwise write the admin's own profile).

🤖 Generated with Claude Code

@sevgibson

Copy link
Copy Markdown
Contributor Author

@claude Please review this PR.

@sevgibson sevgibson changed the title Add a public put for off-resource writes (e.g. profile.json) Add a typed profile resource for the self-service profile.json endpoint Sep 10, 2026
@sevgibson
sevgibson requested a review from jlocke2 September 10, 2026 21:00
…dpoint

Resource#save always PUTs to {collection}/{id}.json — the admin-gated users
endpoint — so there was no way to write the singular self-service profile.json
(Api::V3::ProfilesController), where a user updates their own record (incl.
work_phone/mobile_number) without account-admin rights.

Add a typed Pipeline::Profile following the gem's existing inheritance (same
shape as Pipeline::Import): a `pipeline.profile` accessor mirroring user/account,
and a save overriding only the endpoint (profile.json, not collection/id) and
the :user body key (ProfilesController#update reads params[:user]). Bump 1.0.12.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sevgibson
sevgibson force-pushed the DP-206-add-put-endpoint branch from d9819a6 to ca0d7f4 Compare September 10, 2026 21:21
@sevgibson
sevgibson merged commit e27e9d8 into master Sep 10, 2026
2 checks passed
@sevgibson
sevgibson deleted the DP-206-add-put-endpoint branch September 10, 2026 21:22
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