Skip to content

Commit 9586978

Browse files
committed
Merge remote-tracking branch 'github/master'
2 parents 1402656 + dab01bc commit 9586978

4 files changed

Lines changed: 46 additions & 24 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ Signs API requests and allows interaction via cURL methods.
99
/**
1010
* Setup
1111
*/
12-
$companyId = 0; // Company ID
13-
$staffId = 0; //Staff ID
14-
$staffSecret = ''; // Staff API Key
12+
$companyId = 0; // Company ID
13+
$identifier = 'sid:?/imid:?'; // Identifier either sid: (staff id) or imid: (integration member id) followed by the id provided.
14+
$secret = '...'; // API Key
1515

16-
$signer = new \Kobas\Auth\Signer($companyId, $staffId, $staffSecret);
17-
$client = new \Kobas\Client($signer);
16+
$signer = (new \Kobas\Auth\Signer($companyId, $identifier, $secret));
17+
$client = (new \Kobas\Client($signer));
1818

1919
/**
2020
* Usage
2121
*/
22-
$venues = $client->get('data/venue');
22+
$request = $client->get('customer/search', ['email' => 'example@example.com']);
2323
```
2424

2525
## Client Functions
@@ -43,4 +43,4 @@ Allows over-riding the base URL (only really needed for development)
4343
Allows over-riding of the API version. Might be useful in future?
4444

4545
## disableSSLVerification()
46-
Disables SSL Verify Peer. Needed for development, should never be used in production
46+
Disables SSL Verify Peer. Needed for development, should never be used in production

examples/customerSearch.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?php
2-
$companyId = 0; // Company ID
3-
$staffId = 0; //Staff ID
4-
$staffSecret = ''; // Staff API Key
52

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

9-
$venues = $client->get('customer/search', ['email' => 'example@example.com']);
5+
$companyId = 2716; // Company ID
6+
$identifier = 'sid:1'; // Identifier
7+
$secret = '...'; // API Key
8+
9+
$signer = (new \Kobas\Auth\Signer($companyId, $identifier, $secret));
10+
$client = (new \Kobas\Client($signer));
11+
12+
$request = $client->get('customer/search', ['email' => 'example@example.com']);

examples/wirelessSocial.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
$companyId = 2716; // Company ID
6+
$identifier = 'imid:1'; // Identifier
7+
$secret = '...'; // API Key
8+
9+
$signer = (new \Kobas\Auth\Signer($companyId, $identifier, $secret));
10+
$client = (new \Kobas\Client($signer));
11+
12+
$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);
13+
14+
$request = $client->post('wifi-login/wireless-social', $providedExample);

src/Kobas/Auth/Signer.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@ class Signer
1515

1616

1717
protected $company_id;
18-
protected $staff_id;
18+
19+
/**
20+
* @var string
21+
*/
22+
protected $identifier;
1923

2024
protected $region = 'uk-lon-1';
2125
protected $terminator = 'kbs_request';
2226
protected $auth_type = 'Bearer';
2327
protected $signed_headers = array();
2428
protected $signature;
2529

26-
public function __construct($company_id, $staff_id, $secret)
30+
public function __construct($company_id, $identifier, $secret)
2731
{
2832
$this->setCompanyId($company_id);
29-
$this->setStaffId($staff_id);
33+
$this->setIdentifier($identifier);
3034
$this->setSecret($secret);
3135
}
3236

@@ -282,7 +286,7 @@ protected function payloadHash($params)
282286
protected function authorization($time, $signature)
283287
{
284288
return $this->auth_type .
285-
' Credential=' . $this->getCompanyId() . '-' . $this->getStaffId() .
289+
' Credential=' . $this->getCompanyId() . '-' . $this->getIdentifier() .
286290
'/' . $this->credentialScope($time) . ',' .
287291
'SignedHeaders=' . implode(';', $this->signed_headers) . ',' .
288292
'Signature=' . $this->hex16($signature);
@@ -307,20 +311,21 @@ public function setCompanyId($company_id)
307311
}
308312

309313
/**
310-
* @return mixed
314+
* @return string
311315
*/
312-
public function getStaffId()
316+
public function getIdentifier(): string
313317
{
314-
return $this->staff_id;
318+
return $this->identifier;
315319
}
316320

317321
/**
318-
* @param mixed $staff_id
319-
* @return $this
322+
* @param string $identifier
323+
* @return Signer
320324
*/
321-
public function setStaffId($staff_id)
325+
public function setIdentifier(string $identifier): Signer
322326
{
323-
$this->staff_id = $staff_id;
327+
$this->identifier = $identifier;
328+
324329
return $this;
325330
}
326331

0 commit comments

Comments
 (0)