Skip to content

Commit

Permalink
Add support for Sendcloud Partner id
Browse files Browse the repository at this point in the history
  • Loading branch information
Roald Wegh committed Mar 10, 2017
1 parent d7b6466 commit 5f2eab2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ composer require picqer/sendcloud-php-client
```

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

Expand Down
14 changes: 13 additions & 1 deletion src/Picqer/Carriers/SendCloud/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class Connection
*/
private $apiSecret;

/**
* The Sendcloud Partner ID
*
* @var string
*/
private $partnerId;

/**
* Contains the HTTP client (Guzzle)
* @var Client
Expand All @@ -48,10 +55,11 @@ class Connection
* @param string $apiKey API key for SendCloud
* @param string $apiSecret API secret for SendCloud
*/
public function __construct($apiKey, $apiSecret)
public function __construct($apiKey, $apiSecret, $partnerId = null)
{
$this->apiKey = $apiKey;
$this->apiSecret = $apiSecret;
$this->partnerId = $partnerId;
}

/**
Expand All @@ -76,6 +84,10 @@ public function client()
'handler' => $handlerStack
];

if (! is_null($this->partnerId)) {
$clientConfig['headers']['Sendcloud-Partner-Id'] = $this->partnerId;
}

$this->client = new Client($clientConfig);

return $this->client;
Expand Down

0 comments on commit 5f2eab2

Please sign in to comment.