From 5602749fe12d84ccb8af88d8a29e1a372e16986f Mon Sep 17 00:00:00 2001 From: aleeeftw Date: Thu, 23 Mar 2017 12:08:45 +0200 Subject: [PATCH] Changed staff id with an identifier to be able to use the api client for staff & integration members. --- README.md | 10 +++++----- examples/customerSearch.php | 15 +++++++++------ examples/wirelessSocial.php | 14 ++++++++++++++ src/Kobas/Auth/Signer.php | 27 ++++++++++++++++----------- 4 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 examples/wirelessSocial.php diff --git a/README.md b/README.md index 919e4f0..ab514a6 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,12 @@ Signs API requests and allows interaction via cURL methods. /** * Setup */ -$companyId = 0; // Company ID -$staffId = 0; //Staff ID -$staffSecret = ''; // Staff API Key +$companyId = 0; // Company ID +$identifier = 'sid:?/imid:?'; // Identifier +$secret = '...'; // API Key -$signer = new \Kobas\Auth\Signer($companyId, $staffId, $staffSecret); -$client = new \Kobas\Client($signer); +$signer = (new \Kobas\Auth\Signer($companyId, $identifier, $secret)); +$client = (new \Kobas\Client($signer)); /** * Usage diff --git a/examples/customerSearch.php b/examples/customerSearch.php index 6e8929d..cfe100e 100644 --- a/examples/customerSearch.php +++ b/examples/customerSearch.php @@ -1,9 +1,12 @@ get('customer/search', ['email' => 'example@example.com']); \ No newline at end of file +$companyId = 2716; // Company ID +$identifier = 'sid:1'; // Identifier +$secret = '...'; // API Key + +$signer = (new \Kobas\Auth\Signer($companyId, $identifier, $secret)); +$client = (new \Kobas\Client($signer)); + +$request = $client->get('customer/search', ['email' => 'example@example.com']); diff --git a/examples/wirelessSocial.php b/examples/wirelessSocial.php new file mode 100644 index 0000000..d6d65cf --- /dev/null +++ b/examples/wirelessSocial.php @@ -0,0 +1,14 @@ +post('wifi-login/wireless-social', $providedExample); diff --git a/src/Kobas/Auth/Signer.php b/src/Kobas/Auth/Signer.php index 1c6b62c..cc6ace3 100644 --- a/src/Kobas/Auth/Signer.php +++ b/src/Kobas/Auth/Signer.php @@ -15,7 +15,11 @@ class Signer protected $company_id; - protected $staff_id; + + /** + * @var string + */ + protected $identifier; protected $region = 'uk-lon-1'; protected $terminator = 'kbs_request'; @@ -23,10 +27,10 @@ class Signer protected $signed_headers = array(); protected $signature; - public function __construct($company_id, $staff_id, $secret) + public function __construct($company_id, $identifier, $secret) { $this->setCompanyId($company_id); - $this->setStaffId($staff_id); + $this->setIdentifier($identifier); $this->setSecret($secret); } @@ -282,7 +286,7 @@ protected function payloadHash($params) protected function authorization($time, $signature) { return $this->auth_type . - ' Credential=' . $this->getCompanyId() . '-' . $this->getStaffId() . + ' Credential=' . $this->getCompanyId() . '-' . $this->getIdentifier() . '/' . $this->credentialScope($time) . ',' . 'SignedHeaders=' . implode(';', $this->signed_headers) . ',' . 'Signature=' . $this->hex16($signature); @@ -307,20 +311,21 @@ public function setCompanyId($company_id) } /** - * @return mixed + * @return string */ - public function getStaffId() + public function getIdentifier(): string { - return $this->staff_id; + return $this->identifier; } /** - * @param mixed $staff_id - * @return $this + * @param string $identifier + * @return Signer */ - public function setStaffId($staff_id) + public function setIdentifier(string $identifier): Signer { - $this->staff_id = $staff_id; + $this->identifier = $identifier; + return $this; }