reapit / foundations

Foundations platform mono repo
56 stars 22 forks source link

adding vendorID, landlordID to property record #10863

Closed chestertons closed 8 months ago

chestertons commented 8 months ago

In Foundations, we want to duplicate a lettings record for sales marketing (or the other way round)

How do we add a contactID, vendorID or landlordID to the record on a POST?

By the same token, where we have a client whose record has no entry for vendorID or landlordID, and we're able to identify the contact as an existing client, how do we PATCH the vendorID or landlordID?

HollyJoyPhillips commented 8 months ago

Hi @chestertons, please see comments below:

How do we add a contactID, vendorID or landlordID to the record on a POST?

POST /Property already supports the ‘landlordID’:

image

For sales properties, note that the vendorId IS the propertyId for sales properties (they are the same entity we just use different endpoints to separate the 'premise' level fields from 'contact' type fields. As a result when you create a property the vendor resource is already available to you using the same ID as the new propertyID. To manage/update the relationships with an existing property/vendor, you can use the Vendors endpoint (POST /vendors/{id}/relationships) to update a vendor to a specific contact/company.

Where we have a client whose record has no entry for vendorID or landlordID, and we're able to identify the contact as an existing client, how do we PATCH the vendorID or landlordID?

You can use the GET contacts/{id}/relationships to understand the associated relationships e.g. applicants/vendor

image

You can also use the landlords/{id}/relationships and or the vendor/{id}/relationships to manage the relationships between the property and the contact record.

It may help using the links collection on the created property to navigate between the related resources.