Skip to content

Implement Create Investment API#83

Open
nikkybel wants to merge 2 commits intoamina69:mainfrom
nikkybel:feature/create-lifecycle-state
Open

Implement Create Investment API#83
nikkybel wants to merge 2 commits intoamina69:mainfrom
nikkybel:feature/create-lifecycle-state

Conversation

@nikkybel
Copy link
Copy Markdown

PR: Pet Status Lifecycle Implementation (Closes #60 )

Overview

This PR implements the Pet Status Lifecycle feature, enforcing a state machine for pet status transitions throughout the adoption and custody process. It ensures that pets can only move between valid states, maintaining data integrity and preventing invalid transitions.

Features

  • State Machine for Pet Status:
    • Enforces valid transitions: AVAILABLE → PENDING → ADOPTED, AVAILABLE → IN_CUSTODY → AVAILABLE, etc.
    • Blocks invalid transitions (e.g., ADOPTED → PENDING, IN_CUSTODY → ADOPTED).
    • Allows admin override for ADOPTED → AVAILABLE (return scenario).
  • Transition Validation:
    • Centralized validator for all status changes.
    • Throws clear errors for invalid transitions.
    • Logs all status changes for audit trail.
  • API Endpoints:
    • PATCH /pets/:id/status: Update pet status with validation and audit logging.
    • GET /pets/:id/transitions: Get allowed transitions and current status for a pet.
    • GET /pets/:id/transitions/allowed: Get allowed transitions for the current user (role-aware).
  • Swagger Documentation:
    • All endpoints are fully documented and visible in Swagger UI.
    • Request/response schemas and examples included.
  • Test Coverage:
    • Unit tests for all valid and invalid transitions.
    • Tests for admin overrides and edge case

Closes


@amina69
Copy link
Copy Markdown
Owner

amina69 commented Feb 26, 2026

@nikkybel the test failes and the branch also has conflict, kindly fix

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 26, 2026

@nikkybel Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Custody Lifecycle State Machine

2 participants