Skip to content

Add update method to People resource - #8

Merged
ebrett merged 4 commits into
mainfrom
feature/people-update-method
Dec 10, 2025
Merged

Add update method to People resource#8
ebrett merged 4 commits into
mainfrom
feature/people-update-method

Conversation

@ebrett

@ebrett ebrett commented Dec 10, 2025

Copy link
Copy Markdown
Owner

Summary

  • Implements People.update() method for modifying person/signup data
  • Uses V2 API endpoint PATCH /api/v2/signups/:id with JSON:API format
  • Adds comprehensive test coverage for success, error cases, and edge cases

Changes

Implementation (lib/nationbuilder_api/resources/people.rb)

  • Added update(id, attributes:) method
  • Accepts person ID and attributes hash
  • Handles nested structures (e.g., addresses)
  • Proper JSON:API request formatting
  • Full RDoc documentation with examples

Tests (spec/nationbuilder_api/resources/people_spec.rb)

  • Success case: basic field updates
  • Success case: nested address updates
  • Edge case: empty attributes hash
  • Edge case: string vs integer IDs
  • Error handling: 404 NotFoundError
  • Error handling: 422 ValidationError
  • Error handling: 401 AuthenticationError

Test Results

  • ✅ All 186 tests passing
  • ✅ Coverage: 92.51% (above 90% threshold)
  • ✅ StandardRB linting passed

Usage Example

# Update basic fields
client.people.update(123, attributes: {
  first_name: "John",
  last_name: "Doe",
  email: "john@example.com",
  mobile: "+1234567890"
})

# Update address
client.people.update(123, attributes: {
  primary_address: {
    address1: "123 Main St",
    city: "Portland",
    state: "OR",
    zip: "97201",
    country_code: "US"
  }
})

Related Issues

  • Closes nb-0a4
  • Partial implementation of nb-7 (People Resource - Full CRUD)

🤖 Generated with Claude Code

ebrett and others added 4 commits December 10, 2025 13:16
Implements People.update() to modify person/signup data via PATCH
/api/v2/signups/:id with JSON:API format.

Features:
- Accepts id and attributes parameters
- Handles nested address structures
- Proper error handling (404, 422, 401)
- Comprehensive test coverage (success, errors, edge cases)
- RDoc documentation with examples

Closes nb-0a4

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…permissions

Enhances RDoc for People.update() with important usage notes:
- Partial update semantics (only provided attributes modified)
- Read-only fields behavior (id, timestamps ignored)
- OAuth scope requirements for certain fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ebrett
ebrett merged commit 0d19d2c into main Dec 10, 2025
3 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.

1 participant