Skip to content
Merged
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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions examples/customerSearch.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
$companyId = 0; // Company ID
$staffId = 0; //Staff ID
$staffSecret = ''; // Staff API Key

$signer = new \Kobas\Auth\Signer($companyId, $staffId, $staffSecret);
$client = new \Kobas\Client($signer);
require __DIR__ . '/../vendor/autoload.php';

$venues = $client->get('customer/search', ['email' => 'example@example.com']);
$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']);
14 changes: 14 additions & 0 deletions examples/wirelessSocial.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require __DIR__ . '/../vendor/autoload.php';

$companyId = 2716; // Company ID
$identifier = 'imid:1'; // Identifier
$secret = '...'; // API Key

$signer = (new \Kobas\Auth\Signer($companyId, $identifier, $secret));
$client = (new \Kobas\Client($signer));

$providedExample = json_decode('[{"id": 1665454,"occurredAt": "2017-02-01 10:00:00","isFirstSightingOfUser": true,"user": {"id": 55566,"emailAddress": "abc@def.com","firstName": "john","lastName": "farrimond","dateOfBirth": "1985-01-01","gender": "M","location": "leyland, lancashire","postcode": "PR25 3GR","mobilePhoneNumber": "07712345679","firstSeenAt": "2017-02-01 10:00:00","lastSeenAt": "2017-02-01 10:00:00","numLogins": 1,"dataSource": "facebook","dataSourceId": "14545654446"},"venue": {"id": 5554,"name": "bob\'s cafe","customerRef": "1"}}]', true);

$request = $client->post('wifi-login/wireless-social', $providedExample);
27 changes: 16 additions & 11 deletions src/Kobas/Auth/Signer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ class Signer


protected $company_id;
protected $staff_id;

/**
* @var string
*/
protected $identifier;

protected $region = 'uk-lon-1';
protected $terminator = 'kbs_request';
protected $auth_type = 'Bearer';
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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down