Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Endpoints/DeviceDevicesEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace Fortifi\Api\V1\Endpoints;

use Fortifi\Api\Core\ApiEndpoint;

class DeviceDevicesEndpoint extends ApiEndpoint
{
protected $_path = 'device/devices';
protected $_replacements = [];

public function __construct()
{
}

/**
* @param $hardwareId
*
* @return DeviceDevicesHardwareIdEndpoint
*/
public function with($hardwareId)
{
$endpoint = new DeviceDevicesHardwareIdEndpoint(
$hardwareId
);
$endpoint->_buildFromEndpoint($this);
return $endpoint;
}
}
42 changes: 42 additions & 0 deletions src/Endpoints/DeviceDevicesHardwareIdEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
namespace Fortifi\Api\V1\Endpoints;

use Fortifi\Api\V1\Requests\DevicesRequest;
use Fortifi\Api\Core\ApiRequestDetail;
use Fortifi\Api\Core\ApiEndpoint;

class DeviceDevicesHardwareIdEndpoint extends ApiEndpoint
{
protected $_path = 'device/devices/{hardwareId}';
protected $_replacements = [];

public function __construct($hardwareId)
{
$this->_replacements['{hardwareId}'] = $hardwareId;
}

/**
* @summary Get devices by hardware ID
*
* @return DevicesRequest
*/
public function retrieve()
{
$request = new DevicesRequest();
$request->setConnection($this->_getConnection());
$request->setEndpoint($this);

$detail = new ApiRequestDetail();
$detail->setRequireAuth(true);
$detail->setUrl($this->_buildUrl(
str_replace(
array_keys($this->_replacements),
array_values($this->_replacements),
'device/devices/{hardwareId}'
)
));
$detail->setMethod('GET');
$request->setRequestDetail($detail);
return $request;
}
}
20 changes: 20 additions & 0 deletions src/Endpoints/DeviceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ public function with($hardwareId)
return $endpoint;
}

/**
* @return DeviceDevicesEndpoint
*/
public function devices()
{
$endpoint = new DeviceDevicesEndpoint();
$endpoint->_buildFromEndpoint($this);
return $endpoint;
}

/**
* @return DeviceStatusesEndpoint
*/
public function statuses()
{
$endpoint = new DeviceStatusesEndpoint();
$endpoint->_buildFromEndpoint($this);
return $endpoint;
}

/**
* @return DeviceUpsertEndpoint
*/
Expand Down
47 changes: 47 additions & 0 deletions src/Endpoints/DeviceStatusesDeviceFidEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
namespace Fortifi\Api\V1\Endpoints;

use Fortifi\Api\V1\Requests\ContactStatusesRequest;
use Fortifi\Api\Core\ApiRequestDetail;
use Fortifi\Api\Core\ApiEndpoint;

class DeviceStatusesDeviceFidEndpoint extends ApiEndpoint
{
protected $_path = 'device/statuses/{deviceFid}';
protected $_replacements = [];

public function __construct($deviceFid)
{
$this->_replacements['{deviceFid}'] = $deviceFid;
}

/**
* @summary List contact status
*
* @param $brandFid
* @param $groupFid
*
* @return ContactStatusesRequest
*/
public function retrieve($brandFid = null, $groupFid = null)
{
$request = new ContactStatusesRequest();
$request->setConnection($this->_getConnection());
$request->setEndpoint($this);

$detail = new ApiRequestDetail();
$detail->setRequireAuth(true);
$detail->setUrl($this->_buildUrl(
str_replace(
array_keys($this->_replacements),
array_values($this->_replacements),
'device/statuses/{deviceFid}'
)
));
$detail->addQueryField('brandFid', $brandFid);
$detail->addQueryField('groupFid', $groupFid);
$detail->setMethod('GET');
$request->setRequestDetail($detail);
return $request;
}
}
28 changes: 28 additions & 0 deletions src/Endpoints/DeviceStatusesEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace Fortifi\Api\V1\Endpoints;

use Fortifi\Api\Core\ApiEndpoint;

class DeviceStatusesEndpoint extends ApiEndpoint
{
protected $_path = 'device/statuses';
protected $_replacements = [];

public function __construct()
{
}

/**
* @param $deviceFid
*
* @return DeviceStatusesDeviceFidEndpoint
*/
public function with($deviceFid)
{
$endpoint = new DeviceStatusesDeviceFidEndpoint(
$deviceFid
);
$endpoint->_buildFromEndpoint($this);
return $endpoint;
}
}
50 changes: 50 additions & 0 deletions src/Requests/ContactStatusRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,39 @@ class ContactStatusRequest
public function jsonSerialize()
{
return [
"companyFid" => $this->getCompanyFid(),
"contactFid" => $this->getContactFid(),
"groupFid" => $this->getGroupFid(),
"groupName" => $this->getGroupName(),
"unsubscribed" => $this->isUnsubscribed(),
"bounced" => $this->isBounced(),
];
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getCompanyFid($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'companyFid', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getContactFid($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'contactFid', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
* @param bool $trim Trim Value
Expand All @@ -31,6 +59,18 @@ public function getGroupFid($default = null, $trim = true)
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getGroupName($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'groupName', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param bool $default
*
Expand All @@ -40,4 +80,14 @@ public function isUnsubscribed($default = false)
{
return Objects::property($this->_getResultJson(), 'unsubscribed', $default);
}

/**
* @param bool $default
*
* @return boolean
*/
public function isBounced($default = false)
{
return Objects::property($this->_getResultJson(), 'bounced', $default);
}
}
95 changes: 95 additions & 0 deletions src/Requests/DeviceRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
namespace Fortifi\Api\V1\Requests;

use Fortifi\Api\Core\ApiRequest;
use Packaged\Helpers\Objects;
use Packaged\Helpers\Strings;

class DeviceRequest
extends ApiRequest
implements \JsonSerializable
{

#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
"fid" => $this->getFid(),
"hardwareId" => $this->getHardwareId(),
"customerFid" => $this->getCustomerFid(),
"displayName" => $this->getDisplayName(),
"deviceType" => $this->getDeviceType(),
"dateCreated" => $this->getDateCreated(),
];
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getFid($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'fid', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getHardwareId($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'hardwareId', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getCustomerFid($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'customerFid', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getDisplayName($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'displayName', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
* @param bool $trim Trim Value
*
* @return string
*/
public function getDeviceType($default = null, $trim = true)
{
$value = Objects::property($this->_getResultJson(), 'deviceType', $default);
return $trim ? Strings::ntrim($value) : $value;
}

/**
* @param mixed $default
*
* @return integer
*/
public function getDateCreated($default = null)
{
return Objects::property($this->_getResultJson(), 'dateCreated', $default);
}
}
46 changes: 46 additions & 0 deletions src/Requests/DevicesRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
namespace Fortifi\Api\V1\Requests;

use Fortifi\Api\Core\ApiRequest;
use Packaged\Helpers\Objects;
use Packaged\Helpers\Strings;

class DevicesRequest
extends ApiRequest
implements \JsonSerializable
{

#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
"devices" => $this->getDevices(),
];
}

/**
* @param mixed $default
*
* @return DeviceRequest[]
*/
public function getDevices($default = [])
{
return Objects::property($this->_getResultJson(), 'devices', $default);
}

protected function _prepareResult($result)
{
$return = parent::_prepareResult($result);

if(!empty($return->devices))
{
foreach($return->devices as $itmKey => $itm)
{
$return->devices[$itmKey] = (new DeviceRequest())
->hydrate($itm);
}
}

return $return;
}
}
Loading