<!-- Demo code sample. Not indended for production use. -->

<?php

/**
 * See instructions for installing curl-php library locally
 * http://php.net/manual/en/book.curl.php
 * See instructions to enable curl-php in google cloud
 * https://cloud.google.com/appengine/docs/standard/php/issue-requests
 */

$url = 'https://apidev.emaar.com/etenantsales/casualsales';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'x-apikey: xOVCYCeyR4hGskA7JJZ3b1KHTrrc3R9U',
  'Accept: application/json',
  'Content-Type: application/json',
));
$bodyArray = array(
  'SalesDataCollection' => array(
    'SalesInfo' => array(
      array(
        'UnitNo' => 'TDM-FF-072',
        'LeaseCode' => 't0005562',
        'SalesDateFrom' => '2021-02-01',
        'SalesDateTo' => '2021-02-28',
        'TransactionCount' => '213',
        'TotalSales' => '5432',
        'Remarks' => ' for month of FEB-2021 test',
      ),
    ),
  ),
);
$body = json_encode($bodyArray);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$result = curl_exec($ch);
if ($result === false) {
  echo curl_error($ch);
}
else {
  echo $result;
}
?>