Skip to content

Commit fb98ca8

Browse files
authored
Merge pull request #8 from picqer/add-partnerid-support
Add support for Sendcloud Partner id
2 parents d7b6466 + 5f2eab2 commit fb98ca8

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ composer require picqer/sendcloud-php-client
1313
```
1414

1515
## Set-up connection
16-
Prepare the client for connecting to SendCloud with your API key and secret
16+
Prepare the client for connecting to SendCloud with your API key, API secret and Sendcloud Partner id (optional)
1717
```php
18-
$connection = new \Picqer\Carriers\SendCloud\Connection('apikey', 'apisecret');
18+
$connection = new \Picqer\Carriers\SendCloud\Connection('apikey', 'apisecret', 'partnerid');
1919
$sendCloud = new \Picqer\Carriers\SendCloud\SendCloud($connection);
2020
```
2121

src/Picqer/Carriers/SendCloud/Connection.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ class Connection
3131
*/
3232
private $apiSecret;
3333

34+
/**
35+
* The Sendcloud Partner ID
36+
*
37+
* @var string
38+
*/
39+
private $partnerId;
40+
3441
/**
3542
* Contains the HTTP client (Guzzle)
3643
* @var Client
@@ -48,10 +55,11 @@ class Connection
4855
* @param string $apiKey API key for SendCloud
4956
* @param string $apiSecret API secret for SendCloud
5057
*/
51-
public function __construct($apiKey, $apiSecret)
58+
public function __construct($apiKey, $apiSecret, $partnerId = null)
5259
{
5360
$this->apiKey = $apiKey;
5461
$this->apiSecret = $apiSecret;
62+
$this->partnerId = $partnerId;
5563
}
5664

5765
/**
@@ -76,6 +84,10 @@ public function client()
7684
'handler' => $handlerStack
7785
];
7886

87+
if (! is_null($this->partnerId)) {
88+
$clientConfig['headers']['Sendcloud-Partner-Id'] = $this->partnerId;
89+
}
90+
7991
$this->client = new Client($clientConfig);
8092

8193
return $this->client;

0 commit comments

Comments
 (0)