Este webservice é utilizado para registrar uma visita (hit) em um imóvel.
| Resource information | |
|---|---|
| Authentication | Obrigatória (JWT com scope internal-portal) |
| HTTP Method | PUT |
| Response | String |
Resource URL
https://property-api.mapaprop.com/property/hit
Autenticação
É necessário um token JWT no header Authorization: Bearer {access_token}. O token deve incluir o scope internal-portal; caso contrário o serviço responde com 403.
Parameters body request.
| Key | Type | Required | Description |
|---|---|---|---|
| custId | String | yes | the customer id identifier |
| propertyId | String | yes | the property id identifier |
| brandId | String | yes | brand or system sending data |
| origin | String | yes | originating portal sending the data |
| originUrlHit | String | yes | url of the property from which the data is sent |
| brandCountry | String | yes | country code to store customer's local time |
Sample code
PUT https://property-api.mapaprop.com/property/hit Host: property-api.mapaprop.com Content-Type: application/json Authorization: Bearer {access_token}
Response
O serviço retorna texto simples de acordo com o resultado.
| Status | Corpo | Significado |
|---|---|---|
| 200 | Put hit. | O contador diário de hits do imóvel foi incrementado. |
| 200 | Post first hit. | O primeiro hit do imóvel foi registrado. |
| 403 | { "message": "Scope required: internal-portal" } | O token não possui o scope internal-portal. |
| 500 | Error parameters | Um ou mais parâmetros obrigatórios do body estão ausentes. |
Sample code
Sample for implementation
`import axios from 'axios'; //imports
//credentials const propertyHitAccess = { baseURL: 'https://property-api.mapaprop.com/property/hit', token: '{access_token}' }
//function
const propertyHit = async (custId: any, propertyId:any , currentUrl:any ) => {
try {
const apiUrl = propertyHitAccess.baseURL;
const headers = {
'Content-Type': 'application/json',
Authorization: Bearer ${propertyHitAccess.token},
};
const data = {
custId: custId,
propertyId: propertyId,
brandId: yourBrandName,
origin: yourWebsite,
originUrlHit: currentUrl,
brandCountry: 'ar', //countryCode
};
const response = await axios.put(apiUrl, data, { headers });
// console.log('Respuesta de la solicitud PUT:', response.data);
} catch (error) {
//console.error('Error al realizar la solicitud PUT:', error);
}
};
export { propertyHit };
//call the function propertyHit(response.data.customerId, response.data.propertyId, window.location.href)`