Skip to content

Commit

Permalink
Merge pull request #6 from Dumkaaa/Dumkaaa-patch-1
Browse files Browse the repository at this point in the history
Dumkaaa patch 1
  • Loading branch information
AndrewNovikof authored Oct 16, 2018
2 parents c73d1c4 + 529b178 commit 12f00cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 12 additions & 5 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ public function sendData($data)
{
$url = $this->getEndPoint() . $this->getMethod();
$this->validate('userName', 'password');
$data = array_merge(
[
'userName' => $this->getUserName(),
'password' => $this->getPassword(),
],
$data
);

$httpResponse = $this->httpClient->request(
$this->getHttpMethod(),
$url,
$this->getHeaders(),
json_encode(array_merge([
'userName' => $this->getUserName(),
'password' => $this->getPassword()
], $data))
http_build_query($data, '', '&')
);

$responseClassName = str_replace('Request', 'Response', \get_class($this));
Expand All @@ -174,7 +179,9 @@ public function sendData($data)
);
}

return $reflection->newInstance($this, json_decode($httpResponse->getBody(true), true));
$content = json_decode($httpResponse->getBody()->getContents(), true);

return $reflection->newInstance($this, $content);
}

/**
Expand Down
17 changes: 12 additions & 5 deletions src/Message/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,19 @@ public function sendData($data)
$this->validate('userName', 'password');
$data['currency'] = $this->getCurrencyNumeric();
$data['amount'] = $this->getAmountInteger();
$data = array_merge(
[
'userName' => $this->getUserName(),
'password' => $this->getPassword(),
],
$data
);

$httpResponse = $this->httpClient->request(
$this->getHttpMethod(),
$url,
$this->getHeaders(),
json_encode(array_merge([
'userName' => $this->getUserName(),
'password' => $this->getPassword()
], $data))
http_build_query($data, '', '&')
);

$responseClassName = str_replace('Request', 'Response', \get_class($this));
Expand All @@ -259,6 +264,8 @@ public function sendData($data)
);
}

return $reflection->newInstance($this, json_decode($httpResponse->getBody(true), true));
$content = json_decode($httpResponse->getBody()->getContents(), true);

return $reflection->newInstance($this, $content);
}
}

0 comments on commit 12f00cb

Please sign in to comment.