-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the channellist call for channel retrieval
- Loading branch information
1 parent
fc06906
commit 05a6739
Showing
6 changed files
with
277 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
namespace EffectConnect\PHPSdk\Core\CallType; | ||
|
||
use EffectConnect\PHPSdk\Core\Abstracts\CallType; | ||
use EffectConnect\PHPSdk\ApiCall; | ||
use EffectConnect\PHPSdk\Core\Exception\InvalidActionForCallTypeException; | ||
use EffectConnect\PHPSdk\Core\Helper\Payload; | ||
use EffectConnect\PHPSdk\Core\Interfaces\CallTypeInterface; | ||
use EffectConnect\PHPSdk\Core\Interfaces\ResponseContainerInterface; | ||
use EffectConnect\PHPSdk\Core\Model\Request\OrderList; | ||
use EffectConnect\PHPSdk\Core\Model\Response\ChannelListReadResponseContainer; | ||
use EffectConnect\PHPSdk\Core\Model\Response\OrderListReadResponseContainer; | ||
use EffectConnect\PHPSdk\Core\Validation\ChannelListValidator; | ||
use EffectConnect\PHPSdk\Core\Validation\OrderListValidator; | ||
|
||
/** | ||
* Class ChannelListCall | ||
* | ||
* CallType class receiving orders from the EffectConnect Api. | ||
* | ||
* @author Mark Thiesen | ||
* @company Koek & Peer | ||
* @product EffectConnect | ||
* @package EffectConnectSDK | ||
* | ||
* @method ApiCall read() | ||
*/ | ||
final class ChannelListCall extends CallType implements CallTypeInterface | ||
{ | ||
protected $callVersion = '2.0'; | ||
protected $validatorClass = ChannelListValidator::class; | ||
|
||
/** | ||
* @param ApiCall $apiCall | ||
* | ||
* @return ApiCall | ||
* @throws InvalidActionForCallTypeException | ||
*/ | ||
public function _prepareCall($apiCall) | ||
{ | ||
switch ($this->action) | ||
{ | ||
case CallTypeInterface::ACTION_READ: | ||
$method = 'GET'; | ||
break; | ||
default: | ||
throw new InvalidActionForCallTypeException(); | ||
} | ||
$apiCall | ||
->setUri('/channellist') | ||
->setMethod($method) | ||
; | ||
|
||
return $apiCall; | ||
} | ||
|
||
/** | ||
* @param $method | ||
* @param $responsePayload | ||
* | ||
* @return ResponseContainerInterface | ||
*/ | ||
public static function processResponse($method, $responsePayload) | ||
{ | ||
return new ChannelListReadResponseContainer(Payload::extract($responsePayload, 'ChannelListReadResponseContainer')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
namespace EffectConnect\PHPSdk\Core\Model\Response; | ||
|
||
use EffectConnect\PHPSdk\Core\Helper\Payload; | ||
|
||
/** | ||
* Class Channel | ||
* | ||
* @author Stefan Van den Heuvel | ||
* @company Koek & Peer | ||
* @product EffectConnect | ||
* @package EffectConnectSDK | ||
*/ | ||
final class Channel | ||
{ | ||
|
||
/** | ||
* @var int $_id | ||
*/ | ||
private $_id; | ||
|
||
/** | ||
* @var string $_type | ||
*/ | ||
private $_type; | ||
|
||
/** | ||
* @var string $_subtype | ||
*/ | ||
private $_subtype; | ||
|
||
/** | ||
* @var string $_language | ||
*/ | ||
private $_language; | ||
|
||
/** | ||
* @var string $_title | ||
*/ | ||
private $_title; | ||
|
||
/** | ||
* Channel constructor. | ||
* | ||
* @param $payload | ||
*/ | ||
public function __construct($payload) | ||
{ | ||
if ($payload === null) | ||
{ | ||
return; | ||
} | ||
$this->_id = Payload::extract($payload, 'id'); | ||
$this->_type = Payload::extract($payload, 'type'); | ||
$this->_subtype = Payload::extract($payload, 'subtype'); | ||
$this->_language = Payload::extract($payload, 'language'); | ||
$this->_title = Payload::extract($payload, 'title'); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->_id; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType() | ||
{ | ||
return $this->_type; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSubtype() | ||
{ | ||
return $this->_subtype; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLanguage() | ||
{ | ||
return $this->_language; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTitle() | ||
{ | ||
return $this->_title; | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
EffectConnectSDK/Core/Model/Response/ChannelListReadResponseContainer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
namespace EffectConnect\PHPSdk\Core\Model\Response; | ||
|
||
use EffectConnect\PHPSdk\Core\Helper\Payload; | ||
use EffectConnect\PHPSdk\Core\Interfaces\ResponseContainerInterface; | ||
|
||
/** | ||
* Class ChannelListReadResponseContainer | ||
* | ||
* @author Stefan Van den Heuvel | ||
* @company Koek & Peer | ||
* @product EffectConnect | ||
* @package EffectConnectSDK | ||
*/ | ||
final class ChannelListReadResponseContainer implements ResponseContainerInterface | ||
{ | ||
/** | ||
* @var Channel[] $_orders | ||
*/ | ||
private $_channels = []; | ||
|
||
/** | ||
* OrderListReadResponseContainer constructor. | ||
* | ||
* @param $payload | ||
*/ | ||
public function __construct($payload) | ||
{ | ||
if ($payload === null || $payload === '') | ||
{ | ||
return; | ||
} | ||
foreach (Payload::extract($payload, 'Channels', true) as $channel) | ||
{ | ||
$this->_channels[] = new Channel($channel); | ||
} | ||
} | ||
|
||
/** | ||
* @return Channel[] | ||
*/ | ||
public function getChannels() | ||
{ | ||
return $this->_channels; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
namespace EffectConnect\PHPSdk\Core\Validation; | ||
|
||
use EffectConnect\PHPSdk\Core\Abstracts\Validator; | ||
use EffectConnect\PHPSdk\Core\Exception\InvalidPayloadException; | ||
use EffectConnect\PHPSdk\Core\Interfaces\CallTypeInterface; | ||
use EffectConnect\PHPSdk\Core\Interfaces\CallValidatorInterface; | ||
use EffectConnect\PHPSdk\Core\Model\Request\OrderList; | ||
|
||
/** | ||
* Class OrderListValidator | ||
* | ||
* @author Mark Thiesen | ||
* @company Koek & Peer | ||
* @product EffectConnect | ||
* @package EffectConnectSDK | ||
* | ||
*/ | ||
final class ChannelListValidator extends Validator implements CallValidatorInterface | ||
{ | ||
protected $validActions = [ | ||
CallTypeInterface::ACTION_READ, | ||
]; | ||
|
||
/** | ||
* @param $argument | ||
* | ||
* @return bool | ||
* @throws InvalidPayloadException | ||
*/ | ||
public function validateCall($argument) | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
// 1. Require the SDK base file. | ||
require_once(realpath(__DIR__.'/..').'/base.php'); | ||
/** | ||
* @var \EffectConnect\PHPSdk\Core $effectConnectSDK | ||
* @var \EffectConnect\PHPSdk\Core\CallType\ChannelListCall $channelListCallType | ||
* | ||
* 2. Get the OrderList call type. | ||
*/ | ||
try | ||
{ | ||
$channelListCallType = $effectConnectSDK->ChannelListCall(); | ||
} catch (Exception $exception) { | ||
echo sprintf('Could not create call type. `%s`', $exception->getMessage()); | ||
die(); | ||
} | ||
|
||
/** | ||
* 4. Make the call | ||
*/ | ||
$apiCall = $channelListCallType->read(); | ||
$apiCall->call(); | ||
/** | ||
* 5. Handle call result | ||
*/ | ||
require_once(realpath(__DIR__.'/..').'/result.php'); |