reapit / foundations

Foundations platform mono repo
56 stars 22 forks source link

Foundations API - Property Domain Model #10905

Closed mab-rdremza closed 8 months ago

mab-rdremza commented 8 months ago

Hi,

I'm currently working on a feature to pull customer information associated with a property from Reapit into MABs platform. The assumption we made was there is a one-to-one relationship between property and vendor i.e. a property must have only one vendor, and a vendor must have only one property. We could then rely on the vendor ID associated with a property to fetch the related contact/customer information and store that in our system.

After some investigation in a sandbox environment it looks like this assumption is wrong. Some properties have a vendor, others don't. E.g. in the sandbox environment:

Property MKT240216 is associated with one vendor. Property MKT240452 is not associated with a vendor.

Is the relationship between property and vendor in fact one to zero-or-one? Is there a visual domain model available from which it is clear how to find customer information associated with a property?

Many thanks

plittlewood-rpt commented 8 months ago

Hi @mab-rdremza your second example is a lettings property, so that would be associated with a landlord (if one was set in the CRM). For sales properties, there is a one to one relationship between the property and vendor. Note however that a vendor resource can have one or more contacts associated to it (in the case where a couple are separating for example, where they'd both be registered on the property as two separate contacts). I hope this helps. You will likely find the _links collection return in the PropertyModel helpful as this will assist with automatically navigating to related resources.

mab-rdremza commented 8 months ago

@plittlewood-rpt thank you for the quick response. That has helped clear things up in my mind.

Is there an endpoint within the Foundations API which returns the property type based on a unique identifier? E.g. MKT240452 has property type Lettings therefore I know not to expect a relationship with a vendor. Or should this be inferred based on the _links collection?

For context, we would like to extend our Reapit Marketplace app so that it is also accessible when viewing a property (currently only accessible from applicants), but only for properties with a vendor.

Thanks

plittlewood-rpt commented 8 months ago

Hi @mab-rdremza you should use the marketingMode property that is part of PropertyModel - this will be selling, letting or sellingAndLetting

mab-rdremza commented 8 months ago

Perfect, thank you.

When querying selling properties in the sandbox environment, the property ID and vendor ID are always the same. Is this just a quirk of the sandbox environment or an accurate reflection of production data? E.g.

https://platform.reapit.cloud/properties/AAN240001

Response: { "id": "AAN240001", ..., "selling": { "vendorId": "AAN240001", ..., } }

plittlewood-rpt commented 8 months ago

This is correct and expected behaviour. Under the hood, the property and vendor are actually the same database entity, they are just separate concerns in the API.

mab-rdremza commented 8 months ago

Makes sense.

Going to close the issue now - thank you for very much for the help.

github-actions[bot] commented 8 months ago

It looks like you have commented on a closed issue. If your comment relates to a bug or feature request, please open a new issue, and include this issue number/url for reference. For more information on our processes, please click here