<?php
// Load enneo SDK. Input is made available through $in
use EnneoSDK\ApiEnneo;
use EnneoSDK\Setting;
use EnneoSDK\Api;
require(getenv()['SDK']);
// Note: Customer data properties are largely the same as contract properties. In regular cases, they should be identical, but enneo gives you the option to have different data
// Example is a Holding on customer level, but subsidiaries with different legal entities on contract level
// Insert your API-Calls here, as described in the previous section
$customerRawData = Api::call(method: 'GET', url: 'https://admin.enneo.ai/api/seed-customers/' . $in->customerId);
$customer = [
// Mandatory properties. Must be defined or enneo to work
'id' => $in->customerId, // must be integer or string up to 50 chars
'business' => $customerRawData->processedData->business, // boolean, if the customer is a company or private person
'lastname' => $customerRawData->processedData->lastname, // last name of customer, can be null ONLY if business is true
'company' => $customerRawData->processedData->company, // company name, e.g. "ACME Corp.", can be null ONLY if business is false
'contractIds' => $customerRawData->processedData->contractIds, // array of contract this customer has. Must be at least one contract (otherwise it's not a "customer") e.g. ['VN-00001','VN-00002']
// Recommended properties. Should be defined if possible and is used by Enneo's AI and customer identification logic. Default to null if not set
'firstname' => $customerRawData->processedData->firstname, // first name of customer, can be null
'email' => $customerRawData->processedData->email,
'deliveryAddress' => $customerRawData->processedData->deliveryAddress, // address of customer
'billingAddress' => $customerRawData->processedData->billingAddress, // Optional separate billing address. If null, then billing address is the same as delivery address
'phone' => $customerRawData->processedData->phone,
];
// You may define any other properties you want enneo to be aware of here.
$customer = [
...$customer,
...array_diff_key((array) $customerRawData->processedData, $customer)
];
echo json_encode($customer);