Skip to content

Add Payment model with Decimal amounts and PaymentStatus. - #44

Open
sainath5001 wants to merge 1 commit into
ShadeProtocol:mainfrom
sainath5001:feat/payment-model
Open

Add Payment model with Decimal amounts and PaymentStatus.#44
sainath5001 wants to merge 1 commit into
ShadeProtocol:mainfrom
sainath5001:feat/payment-model

Conversation

@sainath5001

@sainath5001 sainath5001 commented Jul 21, 2026

Copy link
Copy Markdown

Description

Introduce ShadeObject base for from_dict / to_dict, add Payment and PaymentStatus (str, Enum for Python 3.10), validate amount > 0, declare pydantic in pyproject.toml, and cover the model with unit tests.

This adds the typed Payment API response model so monetary amounts use Decimal (not float) and status values are validated via enum.

Dependency: pydantic >= 2.0 (added to pyproject.toml; poetry.lock content-hash updated).

Fixes #37

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • pytest — full suite (146 passed)
  • tests/models/test_payment.pyfrom_dict, Decimal amount, PaymentStatus enum, invalid status errors, amount > 0
pytest tests/models/test_payment.py -v
pytest

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • Added typed payment models with lifecycle statuses, monetary details, timestamps, and optional blockchain information.
    • Added validation to ensure payment amounts are positive.
    • Added convenient serialization and deserialization for API response data.
    • Added support for retaining additional API fields not explicitly defined by the model.
    • Exposed payment models through the public models package.

Introduce ShadeObject base for from_dict/to_dict, add Payment and
PaymentStatus (str, Enum for Python 3.10), validate amount > 0, declare
pydantic in pyproject.toml, and cover the model with unit tests.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Pydantic-based Shade models with shared serialization helpers, a typed Payment resource and lifecycle enum, positive amount validation, package exports, and tests covering parsing, validation, extra fields, and Decimal-preserving round trips.

Changes

Payment models

Layer / File(s) Summary
Pydantic model foundation
pyproject.toml, src/shade/models/base.py, src/shade/models/__init__.py
Adds Pydantic, shared model serialization/deserialization helpers, permissive extra-field handling, and package-level exports.
Payment resource contract
src/shade/models/payment.py
Defines payment fields, lifecycle statuses, Decimal amounts, timestamps, and positive-amount validation.
Payment parsing and validation coverage
tests/models/test_payment.py
Tests construction, coercion, validation errors, optional and extra fields, and serialization round trips.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • #37 — Directly covers the requested Payment model, statuses, Decimal amount handling, and positive-amount validation.
  • #36 — Directly covers the requested ShadeObject base model, serialization helpers, configuration, and package initialization.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements payment models, not the linked HTTP 429 auto-retry and gateway work required by #24. Refocus the changes on rate-limit handling, Retry-After parsing, async/sync retry logic, gateway wiring, and the associated tests from #24.
Out of Scope Changes check ⚠️ Warning The payment model, Pydantic dependency, and tests are unrelated to the linked rate-limit auto-retry issue. Remove or split the payment-model work into a separate PR and keep this one limited to the HTTP 429 retry feature.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding the Payment model with Decimal amounts and PaymentStatus.
Description check ✅ Passed The description matches the template well, including summary, linked issue, change type, testing details, dependency, and checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codebestia

codebestia commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

GM @sainath5001
Please link to right issue in the issue description.
The wrong issue is linked.

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.

Implement Payment model

2 participants