Skip to content

Commit

Permalink
Merge pull request #28 from incarnate/auth-fix
Browse files Browse the repository at this point in the history
Add auth to Rapid requests
  • Loading branch information
barryvdh authored Sep 3, 2018
2 parents 4a0f2e0 + a87b270 commit a2c5fb3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/Message/RapidCaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ public function getEndpoint()

public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword()),
'content-type' => 'application/json',
], json_encode($data));
];

$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));

return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
Expand Down
6 changes: 5 additions & 1 deletion src/Message/RapidDirectAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ protected function getBaseData()

public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
];

$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));

return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
Expand Down
6 changes: 5 additions & 1 deletion src/Message/RapidDirectCreateCardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ protected function getEndpoint()

public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
];

$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));

$this->response = new RapidDirectCreateCardResponse(
$this,
Expand Down
6 changes: 5 additions & 1 deletion src/Message/RapidDirectUpdateCardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ protected function getEndpoint()

public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
];

$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));

return $this->response = new RapidDirectCreateCardResponse(
$this,
Expand Down
7 changes: 5 additions & 2 deletions src/Message/RapidDirectVoidRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ protected function getEndpoint()

public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword()),
'content-type' => 'application/json',
], json_encode($data));
];

$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));

return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
Expand Down
6 changes: 5 additions & 1 deletion src/Message/RapidPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ public function getData()

public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
];

$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));

return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
Expand Down
6 changes: 5 additions & 1 deletion src/Message/RapidSharedPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public function getData()

public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
$headers = [
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
];

$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));

return $this->response = new RapidSharedResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
Expand Down

0 comments on commit a2c5fb3

Please sign in to comment.