Skip to content

Implement Merchant model #39

Description

@codebestia

The Python Merchant model must mirror the Shade backend's Prisma schema exactly. Field names are converted from camelCase (Prisma/JSON) to snake_case (Python). The merchant_id field (from merchantId: Int) is the numeric identifier stored by the Soroban contract on every invoice, making it the bridge between the backend and the on-chain world.

Proposed Steps:

  • Create src/shade/models/merchant.py.
  • Define Merchant(ShadeObject) with Pydantic Field(alias=...) for camelCase ↔ snake_case mapping.
  • Fields: id: str, merchant_id: int, address: str, account: Optional[str], email: Optional[str], first_name: Optional[str], last_name: Optional[str], business_name: Optional[str], category: Optional[str], description: Optional[str], logo: Optional[str], webhook: Optional[str], active: bool, verified: bool.
  • Add display_name computed property: returns business_name if set, else "{first_name} {last_name}".strip(), else email.
  • Validate address is a valid Stellar public key (starts with G, 56 chars).

Acceptance Criteria:

  • Merchant.from_dict(api_response) correctly maps camelCase fields to snake_case attributes.
  • merchant.merchant_id is an int.
  • A non-Stellar address raises InvalidRequestError on construction.
  • merchant.display_name returns the most informative available name.
  • The model has no generic settings dict — all fields are explicitly typed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions