Skip to content

Commit

Permalink
Merge pull request #305 from TransbankDevelopers/revert-301-feat/kiwa…
Browse files Browse the repository at this point in the history
…n-reports

revert: PR #301 "fix: kiwan reports"
  • Loading branch information
DiegoHBustamante authored Nov 28, 2024
2 parents af13ae8 + 11242bf commit 92b1c63
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 79 deletions.
3 changes: 2 additions & 1 deletion src/Contracts/HttpClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Transbank\Contracts;

use Psr\Http\Message\ResponseInterface;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;

interface HttpClientInterface
{
Expand All @@ -12,7 +13,7 @@ interface HttpClientInterface
* @param array|null $payload
* @param array|null $options
*
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return ResponseInterface
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Contracts/RequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Transbank\Contracts;

use Transbank\Webpay\Options;
use Transbank\Webpay\Exceptions\WebpayRequestException;
use Psr\Http\Message\ResponseInterface;
use Transbank\Utils\TransbankApiRequest;

Expand All @@ -14,7 +15,7 @@ interface RequestService
* @param array $payload
* @param Options $options
*
* @throws \Transbank\Webpay\Exceptions\WebpayRequestException
* @throws WebpayRequestException
*
* @return array Response from the API as json.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/PatpassComercio/Inscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Transbank\Utils\RequestServiceTrait;
use Transbank\Contracts\RequestService;
use Transbank\PatpassComercio\Options;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;

class Inscription
{
Expand Down Expand Up @@ -62,7 +63,7 @@ public function __construct(
* @param string $city
*
* @throws InscriptionStartException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return InscriptionStartResponse
*/
Expand Down Expand Up @@ -122,7 +123,7 @@ public function start(
* @param string $token
*
* @throws InscriptionStatusException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return InscriptionStatusResponse
*/
Expand Down
32 changes: 0 additions & 32 deletions src/Utils/Curl/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Transbank\Utils\Curl;

use Psr\Http\Message\StreamInterface;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;

trait MessageTrait
{
Expand Down Expand Up @@ -61,35 +60,4 @@ public function withBody(StreamInterface $body): static
$new->body = $body;
return $new;
}

public function withHeader($name, $value): static
{
$new = clone $this;
$new->headers[$name] = (array) $value;
return $new;
}

public function withAddedHeader($name, $value): static
{
$new = clone $this;
$new->headers[$name][] = $value;
return $new;
}

private function createBody($body = ''): StreamInterface
{
$resource = fopen('php://temp', 'rw+');
if ($resource === false) {
throw new CurlRequestException('Unable to open stream');
}

if (!empty($body)) {
$writtenBytes = fwrite($resource, $body);
if ($writtenBytes === false) {
throw new CurlRequestException('Unable to write to stream');
}
}

return new Stream($resource);
}
}
20 changes: 20 additions & 0 deletions src/Utils/Curl/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,24 @@ public function withUri(UriInterface $uri, $preserveHost = false): RequestInterf

return $new;
}

public function withHeader($name, $value): RequestInterface
{
return clone $this;
}

public function withAddedHeader($name, $value): RequestInterface
{
return clone $this;
}

private function createBody($body = ''): StreamInterface
{
$resource = fopen('php://temp', 'rw+');
if (!empty($body)) {
fwrite($resource, $body);
}

return new Stream($resource);
}
}
24 changes: 24 additions & 0 deletions src/Utils/Curl/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,28 @@ public function getReasonPhrase(): string
{
return $this->reasonPhrase;
}

public function withHeader($name, $value): ResponseInterface
{
$new = clone $this;
$new->headers[$name] = (array) $value;
return $new;
}

public function withAddedHeader($name, $value): ResponseInterface
{
$new = clone $this;
$new->headers[$name][] = $value;
return $new;
}

private function createBody($body = ''): StreamInterface
{
$resource = fopen('php://temp', 'rw+');
if (!empty($body)) {
fwrite($resource, $body);
}

return new Stream($resource);
}
}
4 changes: 2 additions & 2 deletions src/Utils/HttpClientRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Transbank\Utils\Curl\HttpCurlClient;
use Transbank\Webpay\Exceptions\WebpayRequestException;
use Transbank\Webpay\Options;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;
use Psr\Http\Message\ResponseInterface;

class HttpClientRequestService implements RequestService
Expand Down Expand Up @@ -56,8 +57,7 @@ public function setHttpClient(HttpClientInterface $httpClient): void
* @param array $payload
* @param Options $options
*
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
* @throws WebpayRequestException
*
* @return array
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/RequestServiceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Transbank\Utils;

use Transbank\Contracts\RequestService;
use Transbank\Webpay\Exceptions\WebpayRequestException;

/**
* Trait RequestServiceTrait .
Expand All @@ -20,7 +21,7 @@ trait RequestServiceTrait
* @param string $endpoint
* @param array $payload
*
* @throws \Transbank\Webpay\Exceptions\WebpayRequestException
* @throws WebpayRequestException
*
* @return array
*/
Expand Down
7 changes: 4 additions & 3 deletions src/Webpay/Oneclick/MallInscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Transbank\Webpay\Oneclick\Exceptions\InscriptionStartException;
use Transbank\Webpay\Oneclick\Responses\InscriptionFinishResponse;
use Transbank\Webpay\Oneclick\Responses\InscriptionStartResponse;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;

class MallInscription
{
Expand All @@ -26,7 +27,7 @@ class MallInscription
* @return InscriptionStartResponse
*
* @throws InscriptionStartException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*/
public function start(string $username, string $email, string $responseUrl): InscriptionStartResponse
{
Expand Down Expand Up @@ -61,7 +62,7 @@ public function start(string $username, string $email, string $responseUrl): Ins
* @return InscriptionFinishResponse
*
* @throws InscriptionFinishException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*/
public function finish(string $token): InscriptionFinishResponse
{
Expand Down Expand Up @@ -91,7 +92,7 @@ public function finish(string $token): InscriptionFinishResponse
* @return bool
*
* @throws InscriptionDeleteException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*/
public function delete(string $tbkUser, string $username): bool
{
Expand Down
9 changes: 5 additions & 4 deletions src/Webpay/Oneclick/MallTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Transbank\Webpay\Oneclick\Responses\MallTransactionCaptureResponse;
use Transbank\Webpay\Oneclick\Responses\MallTransactionRefundResponse;
use Transbank\Webpay\Oneclick\Responses\MallTransactionStatusResponse;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;

class MallTransaction
{
Expand All @@ -30,7 +31,7 @@ class MallTransaction
* @return MallTransactionAuthorizeResponse
*
* @throws MallTransactionAuthorizeException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*/
public function authorize(
string $userName,
Expand Down Expand Up @@ -73,7 +74,7 @@ public function authorize(
* @return MallTransactionCaptureResponse
*
* @throws MallTransactionCaptureException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*/
public function capture(
string $childCommerceCode,
Expand Down Expand Up @@ -113,7 +114,7 @@ public function capture(
* @return MallTransactionStatusResponse
*
* @throws MallTransactionStatusException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*/
public function status(string $buyOrder): MallTransactionStatusResponse
{
Expand Down Expand Up @@ -145,7 +146,7 @@ public function status(string $buyOrder): MallTransactionStatusResponse
* @return MallTransactionRefundResponse
*
* @throws MallRefundTransactionException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*/
public function refund(
string $buyOrder,
Expand Down
3 changes: 2 additions & 1 deletion src/Webpay/TransaccionCompleta/MallTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Transbank\Webpay\TransaccionCompleta\Responses\MallTransactionStatusResponse;
use Transbank\Webpay\TransaccionCompleta\Responses\MallTransactionCaptureResponse;
use Transbank\Utils\InteractsWithWebpayApi;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;
use Transbank\Webpay\Exceptions\WebpayRequestException;

class MallTransaction
Expand Down Expand Up @@ -223,7 +224,7 @@ public function status(string $token)
* @param int|float $captureAmount
*
* @throws MallTransactionCaptureException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return MallTransactionCaptureResponse
*/
Expand Down
13 changes: 7 additions & 6 deletions src/Webpay/TransaccionCompleta/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Transbank\Webpay\TransaccionCompleta\Responses\TransactionCaptureResponse;
use Transbank\Utils\InteractsWithWebpayApi;
use Transbank\Webpay\Exceptions\WebpayRequestException;
use Transbank\Utils\Curl\Exceptions\CurlRequestException;

/**
* Class Transaction.
Expand All @@ -41,7 +42,7 @@ class Transaction
* @param string|null $cvv
*
* @throws TransactionCreateException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return TransactionCreateResponse
*/
Expand Down Expand Up @@ -82,7 +83,7 @@ public function create(
* @param int $installmentsNumber
*
* @throws TransactionInstallmentsException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return TransactionInstallmentsResponse
*/
Expand Down Expand Up @@ -118,7 +119,7 @@ public function installments(
* @param bool|null $gracePeriod
*
* @throws TransactionCommitException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return TransactionCommitResponse
*/
Expand Down Expand Up @@ -156,7 +157,7 @@ public function commit(
* @param int|float $amount
*
* @throws TransactionRefundException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return TransactionRefundResponse
*/
Expand Down Expand Up @@ -187,7 +188,7 @@ public function refund(string $token, int|float $amount)
* @param string $token
*
* @throws TransactionStatusException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return TransactionStatusResponse
*/
Expand Down Expand Up @@ -217,7 +218,7 @@ public function status($token)
* @param int|float $captureAmount
*
* @throws TransactionCaptureException
* @throws \Transbank\Utils\Curl\Exceptions\CurlRequestException
* @throws CurlRequestException
*
* @return TransactionCaptureResponse
*/
Expand Down
Loading

0 comments on commit 92b1c63

Please sign in to comment.