Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
168 lines (151 sloc) 4.52 KB
<?php
/**
* @package Oneall PHP SDK
* @copyright Copyright 2017-Present http://www.oneall.com
* @license GNU/GPL 2 or later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
*
* The "GNU General Public License" (GPL) is available at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
namespace Oneall\Api\Apis;
use Oneall\Api\AbstractApi;
use Oneall\Api\Pagination;
/**
* Class Identity
*
* @package Oneall\Api\Apis
*/
class Identity extends AbstractApi
{
/**
* {@inheritdoc
*/
public function getName()
{
return 'identity';
}
/**
* List all identities
*
* @param \Oneall\Api\Pagination|null $pagination
*
* @see http://docs.oneall.com/api/resources/identities/list-all-identities/
*
* @return \Oneall\Client\Response
*/
public function getAll(Pagination $pagination = null)
{
if (!$pagination)
{
$pagination = new Pagination();
}
return $this->getClient()->get('/identities.json?' . $pagination->build());
}
/**
* Read Identity Details
*
* @param string $identityToken
*
* @see http://docs.oneall.com/api/resources/identities/list-all-identities/
*
* @return \Oneall\Client\Response
*/
public function get($identityToken)
{
return $this->getClient()->get('/identities/' . $identityToken . '.json');
}
/**
* Delete Identity
*
* @param string $identityToken
*
* @see http://docs.oneall.com/api/resources/identities/delete-identity/
*
* @return \Oneall\Client\Response
*/
public function delete($identityToken)
{
return $this->getClient()->delete('/identities/' . $identityToken . '.json?confirm_deletion=true');
}
/**
* ReLink Identity
*
* @param string $identityToken
*
* @see http://docs.oneall.com/api/resources/identities/relink-identity/
*
* @return \Oneall\Client\Response
*/
public function relink($identityToken, $userToken)
{
$data = [
'request' => [
'user' => [
'user_token' => $userToken
]
]
];
return $this->getClient()->put('/identities/' . $identityToken . '/link.json', $data);
}
/**
* Synchronize Identity
*
* @param string $identityToken
* @param bool $updateUserData
* @param bool $forceTokenUpdate
*
* @see http://docs.oneall.com/api/resources/identities/synchronize-identity/
*
* @return \Oneall\Client\Response
*/
public function synchronize($identityToken, $updateUserData = true, $forceTokenUpdate = false)
{
$data = [
'request' => [
'synchronize' => [
'update_user_data' => (bool) $updateUserData,
'force_token_update' => (bool) $forceTokenUpdate,
]
]
];
return $this->getClient()->put('/identities/' . $identityToken . '/synchronize.json', $data);
}
/**
* Read Identity Contacts
*
* @param string $identityToken
* @param \Oneall\Api\Pagination|null $pagination
* @param bool $disable_cache
*
* @see http://docs.oneall.com/api/resources/identities/read-contacts/
*
* @return \Oneall\Client\Response
*/
public function getContacts($identityToken, Pagination $pagination = null, $disable_cache = false)
{
if (!$pagination)
{
$pagination = new Pagination();
}
$cache = 'disable_cache=false';
if ($disable_cache)
{
$cache = 'disable_cache=true';
}
$uri = '/identities/' . $identityToken . '/contacts.json?' . $cache . '&' . $pagination->build();
return $this->getClient()->get($uri);
}
}