Api reference
components.pet.public.actions ¶
Public actions for the pet component.
create_pet_profile ¶
create_pet_profile(
owner_global_user_id,
name,
species,
breed,
gender,
birth_date,
identification_number=None,
lifestyle=None,
picture_uri=None,
)
Create a PetProfile and return its id.
Does not commit — caller is responsible for committing.
Source code in components/pet/internal/business_logic/create_pet_profile.py
create_pet_subscription_request ¶
create_pet_subscription_request(
owner_global_user_id,
name,
species,
breed,
gender,
birth_date,
identification_number=None,
lifestyle=None,
pet_picture_uri=None,
draft_id=None,
)
Create a PetProfile, an InsurancePlan, and request CG/CP signature.
Enrollment (core_enrollment ChangeRequest) does NOT happen here anymore.
It is deferred to the post-signature ContractCreated events_pipeline
handler in pet.internal.events_pipeline_consumers — pet is only
enrolled once the owner e-signs CP via Dropbox Sign and contracting
publishes ContractCreated.
Does not commit — caller is responsible for committing.
Source code in components/pet/internal/business_logic/enroll_pet.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
components.pet.public.commands ¶
components.pet.public.entities ¶
DraftPetSummary
dataclass
¶
DraftPetSummary(
id,
owner_user_id,
name,
species,
breed,
birth_date,
gender,
identification_number,
lifestyle,
created_at,
)
Bases: DataClassJsonMixin
An in-flight DependentDraft of dependent_type=pet, not yet at Confirmation.
Carries whatever subset of fields the user has filled so far. The
id is the DependentDraft.id — the FE uses it to fetch the full
record and to seed the resume flow. Drafts without name are
filtered server-side and never surface here.
EnrolledPetSummary
dataclass
¶
EnrolledPetSummary(
id,
name,
species,
breed,
birth_date,
owner_user_id,
gender,
identification_number,
lifestyle,
picture_uri,
)
Bases: DataClassJsonMixin
A pet currently enrolled on a pet-insurance contract (PetProfile + core_enrollment).
PendingPetSummary
dataclass
¶
PendingPetSummary(
id,
name,
species,
breed,
birth_date,
owner_user_id,
gender,
identification_number,
picture_uri,
lifestyle,
)
Bases: DataClassJsonMixin
A pet whose signature was submitted but whose backend enrollment is still in flight.
Materializes a PetProfile joined with a DependentDraft whose
signature_submitted_at is set: the user finished the Dropbox Sign iframe
but the async webhook hasn't yet completed enrollment. The frontend
surfaces this as a "pending" pet in the profile list and polls until the
draft is deleted and the pet transitions to enrolled.
PetSummary
module-attribute
¶
WaitlistPetSummary
dataclass
¶
WaitlistPetSummary(
id,
name,
species,
breed,
birth_date,
owner_user_id,
gender,
picture_uri,
is_chipped,
is_already_insured,
expected_monthly_price,
created_at,
)
Bases: DataClassJsonMixin
A pet registered on the waiting list (PetWaitlistEntry).
components.pet.public.enums ¶
Public pet enums.
Re-exports the canonical pet-domain enums so other components can use
them at the public boundary (e.g. member_lifecycle referencing
PetType for its draft pet_species column) without reaching into
pet.internal.
components.pet.public.labels ¶
Localized display labels for pet attributes (species, gender, lifestyle, breed).
Pure i18n helpers (value + Lang → str). The label tables live in
internal/business_logic/labels.py; these are the public wrappers.
get_breed_display_name ¶
Localized display label for a breed i18n key (e.g. breeds.dog.beagle).
Falls back to French, then to the raw key when unmapped (e.g. a breed added to the frontend but not yet synced into the label map).
Source code in components/pet/public/labels.py
get_gender_label ¶
Localized display label for a pet gender (e.g. male → "Mâle").
Source code in components/pet/public/labels.py
get_lifestyle_category_label ¶
Localized indoor/outdoor category for the CP "Mode de vie" — "Intérieur" /
"Extérieur". Collapses the fine-grained PetLifestyle (cat-specific) into a
coarse category. None when the pet has no lifestyle (e.g. dogs), so callers
can show their own fallback.
Source code in components/pet/public/labels.py
get_species_label ¶
Localized display label for a pet species (e.g. dog → "Chien").
Source code in components/pet/public/labels.py
components.pet.public.queries ¶
compute_pet_monthly_price_in_cents ¶
Monthly premium in cents at the currently sold (rate=80%, ceiling=2000€) combo.
Raises ValueError on unknown breed or age outside 0..7.
Source code in components/pet/public/queries.py
get_pet_profile ¶
Retrieve a pet profile by ID.
Source code in components/pet/public/queries.py
is_known_breed_key ¶
Whether breed_key is a recognised canonical i18n breed key (e.g. breeds.dog.labrador_retriever).
Source code in components/pet/public/queries.py
list_draft_pets_for_owner ¶
In-flight pet drafts for owner_user_id: no PetProfile yet, no
signature dispatched, has a name. Surfaced on the profile list as
clickable "resume" rows.
Source code in components/pet/public/queries.py
list_pending_pets_for_owner ¶
List the user's pets whose Dropbox Sign signature was submitted but whose backend enrollment hasn't yet completed (DependentDraft still alive).
The draft row is deleted on ContractCreated so this list naturally
drains as the webhook fires. Ordering is newest pet first by
PetProfile.created_at (a faithful proxy: signature is submitted
seconds-to-minutes after the profile is created).
Source code in components/pet/public/queries.py
list_pet_profiles_for_owner ¶
List pet profiles currently enrolled by owner_global_user_id.
Cross-checks core_enrollment: only pets with an active enrollment period (membership_type=pet, period not ended) are returned. Pets whose PetProfile row exists but never reached an EnrollmentPeriod are excluded.
Source code in components/pet/public/queries.py
list_pets_for_owner ¶
List a user's pets — enrolled, then pending (signature done but enrollment in flight), then draft (pre-Confirmation, user-resumable), then waiting-list.
Enrolled pets come from core_enrollment (membership_type=pet, active periods).
Pending pets come from DependentDraft rows whose signature was submitted
but whose ContractCreated webhook hasn't fired yet (deletes the draft).
Draft pets come from in-flight DependentDraft rows (no profile, no AR id,
has a name) — user abandoned the add-pet flow mid-way and can resume.
Waiting-list entries come from PetWaitlistEntry rows scoped to the user.
Ordering is stable: enrolled then pending then draft then waiting-list, each newest-first within its group.
owner_user_id is the true global_user_id: enrolled/pending/draft key on it
directly; the waitlist (app-local app_user_id) is translated internally.
Source code in components/pet/public/queries.py
list_waitlist_pets_for_owner ¶
List the user's pet waiting-list entries, newest first.
owner_user_id is the true global_user_id. Waitlist rows are keyed on the
app-local app_user_id (FeatureUserMixin), so translate global → local
before matching.