| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | namespace Worldline\Connect\Sdk; |
| 7: | |
| 8: | use Worldline\Connect\Sdk\Logging\CommunicatorLogger; |
| 9: | use Worldline\Connect\Sdk\V1\V1Client; |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | class Client extends ApiResource |
| 15: | { |
| 16: | |
| 17: | private $communicator; |
| 18: | |
| 19: | |
| 20: | private $clientMetaInfo; |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public function __construct(Communicator $communicator, $clientMetaInfo = '') |
| 30: | { |
| 31: | parent::__construct(); |
| 32: | $this->communicator = $communicator; |
| 33: | $this->setClientMetaInfo($clientMetaInfo); |
| 34: | $this->context = array(); |
| 35: | } |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | protected function getCommunicator() |
| 41: | { |
| 42: | return $this->communicator; |
| 43: | } |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | public function enableLogging(CommunicatorLogger $communicatorLogger) |
| 49: | { |
| 50: | $this->getCommunicator()->enableLogging($communicatorLogger); |
| 51: | } |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | public function disableLogging() |
| 57: | { |
| 58: | $this->getCommunicator()->disableLogging(); |
| 59: | } |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | public function setClientMetaInfo($clientMetaInfo) |
| 66: | { |
| 67: | $this->clientMetaInfo = $clientMetaInfo ? base64_encode($clientMetaInfo) : ''; |
| 68: | return $this; |
| 69: | } |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | protected function getClientMetaInfo() |
| 75: | { |
| 76: | return $this->clientMetaInfo; |
| 77: | } |
| 78: | |
| 79: | public function v1() |
| 80: | { |
| 81: | return new V1Client($this, $this->context); |
| 82: | } |
| 83: | } |
| 84: | |