| 1 |
<?php |
| 2 |
/** |
| 3 |
* MLS provider adapter: Centris (Quebec provincial MLS, RESO Web API / OData v4). |
| 4 |
* |
| 5 |
* Centris is the single provincial MLS for Quebec, operated by the Association |
| 6 |
* professionnelle des courtiers immobiliers du Quebec (APCIQ/QPAREB). It serves |
| 7 |
* one federated feed at datadistributionqc.centris.ca rather than a platform |
| 8 |
* hosting many separate boards, so there is no OriginatingSystemName filter and |
| 9 |
* no board-selection step: one MLS id (9001) is the whole province. |
| 10 |
* |
| 11 |
* What this adapter owns: |
| 12 |
* |
| 13 |
* 1. Identity — the stable saved provider type string 'centris', which is what |
| 14 |
* the mld_details DynamoDB row stores in its `type` attribute and what the |
| 15 |
* AWS listings Lambda dispatches on. |
| 16 |
* 2. Login — Centris issues a static, long-lived Bearer token (the `cddk.<...>` |
| 17 |
* string). Despite decoding to something that looks like client_id/secret, it |
| 18 |
* is NOT an OAuth2 client_credentials pair: there is no token endpoint and no |
| 19 |
* refresh. The saved token is sent verbatim in the Authorization header, so |
| 20 |
* this adapter reuses ResoBase's shared stored-token login by declaring |
| 21 |
* $direct_uses_stored_token, exactly like Bridge and RMLS. |
| 22 |
* 3. Timestamps — Centris is a strict OData v4 endpoint and rejects a bare |
| 23 |
* 'Y-m-d\TH:i' in a $filter=ModificationTimestamp comparison, so the stored |
| 24 |
* sync marker is widened to a full DateTimeOffset literal before it leaves |
| 25 |
* WordPress. |
| 26 |
* |
| 27 |
* What this adapter deliberately does NOT claim: Direct MLS (Standalone Live / |
| 28 |
* passthrough) support. Centris has two shape differences from every provider |
| 29 |
* already ported — Property carries no City string field (only a |
| 30 |
* CityOrTownshipKey foreign key into a separate CityOrTownship entity set) and |
| 31 |
* has no CountyOrParish concept at all (the StateRegion administrative region |
| 32 |
* is the closest analog). Until those two lookups are resolved, a Live query |
| 33 |
* built from the shared OData encoder would emit filters on fields Centris does |
| 34 |
* not have, so $direct_access_supported stays false and callers receive the |
| 35 |
* standard 'unsupported_direct_provider' outcome instead of a broken request. |
| 36 |
* |
| 37 |
* @package MLSImport |
| 38 |
*/ |
| 39 |
|
| 40 |
// Abort if the file is accessed directly outside of WordPress. |
| 41 |
if ( ! defined( 'ABSPATH' ) ) { |
| 42 |
exit; // Exit if accessed directly |
| 43 |
} |
| 44 |
|
| 45 |
/** Provider adapter for Centris (Quebec). */ |
| 46 |
class CentrisResoClass extends ResoBase { |
| 47 |
|
| 48 |
/** @var string Stable provider type saved with the MLS configuration. */ |
| 49 |
protected $provider_type = 'centris'; |
| 50 |
|
| 51 |
/** |
| 52 |
* @var bool Direct MLS (Standalone Live) is not implemented for Centris yet. |
| 53 |
* See the file header: City and CountyOrParish have no matching |
| 54 |
* Property field, so the shared OData query cannot be trusted. |
| 55 |
*/ |
| 56 |
protected $direct_access_supported = false; |
| 57 |
|
| 58 |
/** |
| 59 |
* Widen the saved sync marker to a full OData DateTimeOffset literal. |
| 60 |
* |
| 61 |
* Step 1: the plugin stores the Last Successful Sync Time as 'Y-m-d\TH:i'. |
| 62 |
* Step 2: Centris's OData v4 endpoint compares ModificationTimestamp as an |
| 63 |
* Edm.DateTimeOffset and rejects a value with no seconds and no |
| 64 |
* zone, which would surface to the customer as an import that finds |
| 65 |
* zero changed listings on every run. |
| 66 |
* Step 3: re-emit the same instant as 'Y-m-d\TH:i:s.000\Z' (milliseconds and |
| 67 |
* the UTC Z suffix), which Centris accepts. |
| 68 |
* |
| 69 |
* @param string $value Saved sync timestamp. |
| 70 |
* @return string Full UTC DateTimeOffset literal. |
| 71 |
*/ |
| 72 |
protected function format_stored_timestamp( $value ) { |
| 73 |
return $this->format_utc_timestamp( $value, true, true ); |
| 74 |
} |
| 75 |
} |
| 76 |
|