<?php
require_once('contacts.php');
require_once('inc/debug.php');
require_once('inc/api.php');
function contact_to_apicontact($c)
{
$ac = [];
$ac['id'] = $c['nic_id'];
$ac['handle'] = $c['nic_handle'];
$ac['type'] = 'person';
$ac['name'] = $c['name'];
$ac['organization'] = $c['company'];
$ac['street'] = explode("\n", $c['address'], 3);
$ac['postalCode'] = $c['zip'];
$ac['city'] = $c['city'];
$ac['country'] = strtolower($c['country']);
$ac['emailAddress'] = $c['email'];
$ac['phoneNumber'] = $c['phone'];
$ac['faxNumber'] = $c['fax'];
if ($c['state'] == 'deleted') {
$ac['hidden'] = true;
}
return $ac;
}
function apicontact_to_contact($ac)
{
$c = new_contact();
$c['nic_id'] = $ac['id'];
$c['nic_handle'] = $ac['handle'];
$c['name'] = maybe_null($ac['name']);
$c['company'] = maybe_null($ac['organization']);
$c['address'] = implode("\n", $ac['street']);
$c['zip'] = $ac['postalCode'];
$c['city'] = $ac['city'];