diff --git a/README.md b/README.md
index 47b0f82..3644180 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ To run your project, right click on your PHP file inside your Test project and c
## Initialize the API Client
-**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/client.md)
+**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/client.md)
The following parameters are configurable for the API Client:
@@ -115,46 +115,59 @@ The following parameters are configurable for the API Client:
| `retryOnTimeout` | `bool` | Whether to retry on request timeout.
*Default*: `true` |
| `httpStatusCodesToRetry` | `array` | Http status codes to retry against.
*Default*: `408, 413, 429, 500, 502, 503, 504, 521, 522, 524` |
| `httpMethodsToRetry` | `array` | Http methods to retry against.
*Default*: `'GET', 'PUT'` |
+| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/basic-authentication.md) | The Credentials Setter for Basic Authentication |
The API client can be initialized as follows:
```php
$client = PagarmeApiSDKClientBuilder::init()
+ ->basicAuthCredentials(
+ BasicAuthCredentialsBuilder::init(
+ 'BasicAuthUserName',
+ 'BasicAuthPassword'
+ )
+ )
->serviceRefererName('ServiceRefererName')
->build();
```
+## Authorization
+
+This API uses the following authentication schemes.
+
+* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/$a/https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/basic-authentication.md)
+
## API Errors
Here is the list of errors that the API might throw.
| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
-| 400 | Invalid request | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) |
-| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) |
-| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) |
-| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) |
-| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) |
-| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/models/error-exception.md) |
+| 400 | Invalid request | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/models/error-exception.md) |
+| 401 | Invalid API key | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/models/error-exception.md) |
+| 404 | An informed resource was not found | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/models/error-exception.md) |
+| 412 | Business validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/models/error-exception.md) |
+| 422 | Contract validation error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/models/error-exception.md) |
+| 500 | Internal server error | [`ErrorException`](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/models/error-exception.md) |
## List of APIs
-* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/subscriptions.md)
-* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/orders.md)
-* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/plans.md)
-* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/invoices.md)
-* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/customers.md)
-* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/charges.md)
-* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/recipients.md)
-* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/tokens.md)
-* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/transactions.md)
-* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/transfers.md)
-* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/payables.md)
-* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/controllers/balance-operations.md)
+* [Subscriptions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/subscriptions.md)
+* [Orders](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/orders.md)
+* [Plans](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/plans.md)
+* [Invoices](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/invoices.md)
+* [Customers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/customers.md)
+* [Charges](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/charges.md)
+* [Recipients](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/recipients.md)
+* [Tokens](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/tokens.md)
+* [Transactions](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/transactions.md)
+* [Transfers](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/transfers.md)
+* [Payables](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/payables.md)
+* [Balance Operations](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/controllers/balance-operations.md)
## Classes Documentation
-* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/api-exception.md)
-* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/http-request.md)
-* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.5/doc/http-response.md)
+* [ApiException](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/api-exception.md)
+* [HttpRequest](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/http-request.md)
+* [HttpResponse](https://www.github.com/pagarme/pagarme-php-sdk/tree/6.8.6/doc/http-response.md)
diff --git a/doc/auth/basic-authentication.md b/doc/auth/basic-authentication.md
new file mode 100644
index 0000000..f0f05f3
--- /dev/null
+++ b/doc/auth/basic-authentication.md
@@ -0,0 +1,36 @@
+
+# Basic Authentication
+
+
+
+Documentation for accessing and setting credentials for httpBasic.
+
+## Auth Credentials
+
+| Name | Type | Description | Setter | Getter |
+| --- | --- | --- | --- | --- |
+| BasicAuthUserName | `string` | The username to use with basic authentication | `username` | `getBasicAuthUserName()` |
+| BasicAuthPassword | `string` | The password to use with basic authentication | `password` | `getBasicAuthPassword()` |
+
+
+
+**Note:** Auth credentials can be set using `BasicAuthCredentialsBuilder::init()` in `basicAuthCredentials` method in the client builder and accessed through `getBasicAuthCredentials` method in the client instance.
+
+## Usage Example
+
+### Client Initialization
+
+You must provide credentials in the client as shown in the following code snippet.
+
+```php
+$client = PagarmeApiSDKClientBuilder::init()
+ ->basicAuthCredentials(
+ BasicAuthCredentialsBuilder::init(
+ 'BasicAuthUserName',
+ 'BasicAuthPassword'
+ )
+ )
+ ->build();
+```
+
+
diff --git a/doc/client.md b/doc/client.md
index 0071fb8..6bdf60d 100644
--- a/doc/client.md
+++ b/doc/client.md
@@ -15,11 +15,18 @@ The following parameters are configurable for the API Client:
| `retryOnTimeout` | `bool` | Whether to retry on request timeout.
*Default*: `true` |
| `httpStatusCodesToRetry` | `array` | Http status codes to retry against.
*Default*: `408, 413, 429, 500, 502, 503, 504, 521, 522, 524` |
| `httpMethodsToRetry` | `array` | Http methods to retry against.
*Default*: `'GET', 'PUT'` |
+| `basicAuthCredentials` | [`BasicAuthCredentials`]($a/basic-authentication.md) | The Credentials Setter for Basic Authentication |
The API client can be initialized as follows:
```php
$client = PagarmeApiSDKClientBuilder::init()
+ ->basicAuthCredentials(
+ BasicAuthCredentialsBuilder::init(
+ 'BasicAuthUserName',
+ 'BasicAuthPassword'
+ )
+ )
->serviceRefererName('ServiceRefererName')
->build();
```
diff --git a/doc/controllers/tokens.md b/doc/controllers/tokens.md
index ba3d3f3..732e7a7 100644
--- a/doc/controllers/tokens.md
+++ b/doc/controllers/tokens.md
@@ -16,6 +16,8 @@ $tokensController = $client->getTokensController();
# Create Token
+:information_source: **Note** This endpoint does not require authentication.
+
```php
function createToken(
string $publicKey,
@@ -65,6 +67,8 @@ $result = $tokensController->createToken(
Gets a token from its id
+:information_source: **Note** This endpoint does not require authentication.
+
```php
function getToken(string $id, string $publicKey): GetTokenResponse
```
diff --git a/src/Authentication/BasicAuthCredentialsBuilder.php b/src/Authentication/BasicAuthCredentialsBuilder.php
new file mode 100644
index 0000000..a547327
--- /dev/null
+++ b/src/Authentication/BasicAuthCredentialsBuilder.php
@@ -0,0 +1,71 @@
+config = $config;
+ }
+
+ /**
+ * Initializer for BasicAuthCredentialsBuilder
+ *
+ * @param string $username
+ * @param string $password
+ */
+ public static function init(string $username, string $password): self
+ {
+ return new self(['basicAuthUserName' => $username, 'basicAuthPassword' => $password]);
+ }
+
+ /**
+ * Setter for BasicAuthUserName.
+ *
+ * @param string $username
+ *
+ * @return $this
+ */
+ public function username(string $username): self
+ {
+ $this->config['basicAuthUserName'] = $username;
+ return $this;
+ }
+
+ /**
+ * Setter for BasicAuthPassword.
+ *
+ * @param string $password
+ *
+ * @return $this
+ */
+ public function password(string $password): self
+ {
+ $this->config['basicAuthPassword'] = $password;
+ return $this;
+ }
+
+ public function getConfiguration(): array
+ {
+ return CoreHelper::clone($this->config);
+ }
+}
diff --git a/src/Authentication/BasicAuthManager.php b/src/Authentication/BasicAuthManager.php
new file mode 100644
index 0000000..91ce7af
--- /dev/null
+++ b/src/Authentication/BasicAuthManager.php
@@ -0,0 +1,69 @@
+required()
+ );
+ $this->basicAuthUserName = $basicAuthUserName;
+ $this->basicAuthPassword = $basicAuthPassword;
+ }
+
+ /**
+ * String value for basicAuthUserName.
+ */
+ public function getBasicAuthUserName(): string
+ {
+ return $this->basicAuthUserName;
+ }
+
+ /**
+ * String value for basicAuthPassword.
+ */
+ public function getBasicAuthPassword(): string
+ {
+ return $this->basicAuthPassword;
+ }
+
+ /**
+ * Checks if provided credentials match with existing ones.
+ *
+ * @param string $basicAuthUserName The username to use with basic authentication
+ * @param string $basicAuthPassword The password to use with basic authentication
+ */
+ public function equals(string $basicAuthUserName, string $basicAuthPassword): bool
+ {
+ return $basicAuthUserName == $this->basicAuthUserName &&
+ $basicAuthPassword == $this->basicAuthPassword;
+ }
+}
diff --git a/src/BasicAuthCredentials.php b/src/BasicAuthCredentials.php
new file mode 100644
index 0000000..23d88d8
--- /dev/null
+++ b/src/BasicAuthCredentials.php
@@ -0,0 +1,35 @@
+ self::HTTP_STATUS_CODES_TO_RETRY,
'httpMethodsToRetry' => self::HTTP_METHODS_TO_RETRY,
'serviceRefererName' => self::SERVICE_REFERER_NAME,
- 'environment' => self::ENVIRONMENT
+ 'environment' => self::ENVIRONMENT,
+ 'basicAuthUserName' => self::BASIC_AUTH_USER_NAME,
+ 'basicAuthPassword' => self::BASIC_AUTH_PASSWORD
];
}
diff --git a/src/ConfigurationInterface.php b/src/ConfigurationInterface.php
index e89478a..d638872 100644
--- a/src/ConfigurationInterface.php
+++ b/src/ConfigurationInterface.php
@@ -11,6 +11,7 @@
namespace PagarmeApiSDKLib;
use CoreInterfaces\Http\HttpConfigurations;
+use PagarmeApiSDKLib\Authentication\BasicAuthCredentialsBuilder;
/**
* An interface for all configuration parameters required by the SDK.
@@ -27,6 +28,16 @@ public function getServiceRefererName(): string;
*/
public function getEnvironment(): string;
+ /**
+ * Get the credentials to use with BasicAuth
+ */
+ public function getBasicAuthCredentials(): BasicAuthCredentials;
+
+ /**
+ * Get the credentials builder instance to update credentials for BasicAuth
+ */
+ public function getBasicAuthCredentialsBuilder(): ?BasicAuthCredentialsBuilder;
+
/**
* Get the base uri for a given server in the current environment.
*
diff --git a/src/Controllers/BalanceOperationsController.php b/src/Controllers/BalanceOperationsController.php
index fb623cc..a030c80 100644
--- a/src/Controllers/BalanceOperationsController.php
+++ b/src/Controllers/BalanceOperationsController.php
@@ -37,6 +37,7 @@ public function getBalanceOperations(
?string $recipientId = null
): ListBalanceOperationResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/balance/operations')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('status', $status),
QueryParam::init('created_since', $createdSince)
@@ -61,6 +62,7 @@ public function getBalanceOperations(
public function getBalanceOperationById(int $id): GetBalanceOperationResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/balance/operations/{id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('id', $id));
$_resHandler = $this->responseHandler()->type(GetBalanceOperationResponse::class);
diff --git a/src/Controllers/ChargesController.php b/src/Controllers/ChargesController.php
index 9048de7..22a3033 100644
--- a/src/Controllers/ChargesController.php
+++ b/src/Controllers/ChargesController.php
@@ -49,6 +49,7 @@ public function updateChargeMetadata(
?string $idempotencyKey = null
): GetChargeResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/metadata')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
BodyParam::init($request),
@@ -78,6 +79,7 @@ public function updateChargePaymentMethod(
?string $idempotencyKey = null
): GetChargeResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/payment-method')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
BodyParam::init($request),
@@ -104,6 +106,7 @@ public function getChargeTransactions(
?int $size = null
): ListChargeTransactionsResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}/transactions')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
QueryParam::init('page', $page),
@@ -132,6 +135,7 @@ public function updateChargeDueDate(
?string $idempotencyKey = null
): GetChargeResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Charges/{charge_id}/due-date')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
BodyParam::init($request),
@@ -173,6 +177,7 @@ public function getCharges(
?\DateTime $createdUntil = null
): ListChargesResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('page', $page),
QueryParam::init('size', $size),
@@ -209,6 +214,7 @@ public function captureCharge(
?string $idempotencyKey = null
): GetChargeResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/capture')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
BodyParam::init($request),
@@ -237,6 +243,7 @@ public function updateChargeCard(
?string $idempotencyKey = null
): GetChargeResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/charges/{charge_id}/card')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
BodyParam::init($request),
@@ -260,6 +267,7 @@ public function updateChargeCard(
public function getCharge(string $chargeId): GetChargeResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/{charge_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('charge_id', $chargeId));
$_resHandler = $this->responseHandler()->type(GetChargeResponse::class);
@@ -282,6 +290,7 @@ public function getChargesSummary(
?\DateTime $createdUntil = null
): GetChargesSummaryResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/charges/summary')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('status', $status),
QueryParam::init('created_since', $createdSince)
@@ -308,6 +317,7 @@ public function getChargesSummary(
public function retryCharge(string $chargeId, ?string $idempotencyKey = null): GetChargeResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/retry')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
HeaderParam::init('idempotency-key', $idempotencyKey)
@@ -335,6 +345,7 @@ public function cancelCharge(
?string $idempotencyKey = null
): GetChargeResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/charges/{charge_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
BodyParam::init($request),
@@ -359,6 +370,7 @@ public function cancelCharge(
public function createCharge(CreateChargeRequest $request, ?string $idempotencyKey = null): GetChargeResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/Charges')
+ ->auth('httpBasic')
->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey));
$_resHandler = $this->responseHandler()->type(GetChargeResponse::class);
@@ -381,6 +393,7 @@ public function confirmPayment(
?string $idempotencyKey = null
): GetChargeResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/charges/{charge_id}/confirm-payment')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('charge_id', $chargeId),
BodyParam::init($request),
diff --git a/src/Controllers/CustomersController.php b/src/Controllers/CustomersController.php
index 995fc1a..52a7fe7 100644
--- a/src/Controllers/CustomersController.php
+++ b/src/Controllers/CustomersController.php
@@ -54,6 +54,7 @@ public function updateCard(
?string $idempotencyKey = null
): GetCardResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/cards/{card_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
TemplateParam::init('card_id', $cardId),
@@ -85,6 +86,7 @@ public function updateAddress(
?string $idempotencyKey = null
): GetAddressResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}/addresses/{address_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
TemplateParam::init('address_id', $addressId),
@@ -117,6 +119,7 @@ public function deleteAccessToken(
RequestMethod::DELETE,
'/customers/{customer_id}/access-tokens/{token_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
TemplateParam::init('token_id', $tokenId),
@@ -141,6 +144,7 @@ public function deleteAccessToken(
public function createCustomer(CreateCustomerRequest $request, ?string $idempotencyKey = null): GetCustomerResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers')
+ ->auth('httpBasic')
->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey));
$_resHandler = $this->responseHandler()->type(GetCustomerResponse::class);
@@ -165,6 +169,7 @@ public function createAddress(
?string $idempotencyKey = null
): GetAddressResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/addresses')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
BodyParam::init($request),
@@ -188,6 +193,7 @@ public function createAddress(
public function deleteAccessTokens(string $customerId): ListAccessTokensResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens/')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('customer_id', $customerId));
$_resHandler = $this->responseHandler()->type(ListAccessTokensResponse::class);
@@ -208,6 +214,7 @@ public function deleteAccessTokens(string $customerId): ListAccessTokensResponse
public function getAddress(string $customerId, string $addressId): GetAddressResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses/{address_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
TemplateParam::init('address_id', $addressId)
@@ -238,6 +245,7 @@ public function deleteAddress(
RequestMethod::DELETE,
'/customers/{customer_id}/addresses/{address_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
TemplateParam::init('address_id', $addressId),
@@ -266,6 +274,7 @@ public function createCard(
?string $idempotencyKey = null
): GetCardResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
BodyParam::init($request),
@@ -300,6 +309,7 @@ public function getCustomers(
?string $code = null
): ListCustomersResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('name', $name),
QueryParam::init('document', $document),
@@ -331,6 +341,7 @@ public function updateCustomer(
?string $idempotencyKey = null
): GetCustomerResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/customers/{customer_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
BodyParam::init($request),
@@ -359,6 +370,7 @@ public function createAccessToken(
?string $idempotencyKey = null
): GetAccessTokenResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/access-tokens')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
BodyParam::init($request),
@@ -384,6 +396,7 @@ public function createAccessToken(
public function getAccessTokens(string $customerId, ?int $page = null, ?int $size = null): ListAccessTokensResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/access-tokens')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
QueryParam::init('page', $page),
@@ -409,6 +422,7 @@ public function getAccessTokens(string $customerId, ?int $page = null, ?int $siz
public function getCards(string $customerId, ?int $page = null, ?int $size = null): ListCardsResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
QueryParam::init('page', $page),
@@ -434,6 +448,7 @@ public function getCards(string $customerId, ?int $page = null, ?int $size = nul
public function renewCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/customers/{customer_id}/cards/{card_id}/renew')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
TemplateParam::init('card_id', $cardId),
@@ -460,7 +475,12 @@ public function getAccessToken(string $customerId, string $tokenId): GetAccessTo
$_reqBuilder = $this->requestBuilder(
RequestMethod::GET,
'/customers/{customer_id}/access-tokens/{token_id}'
- )->parameters(TemplateParam::init('customer_id', $customerId), TemplateParam::init('token_id', $tokenId));
+ )
+ ->auth('httpBasic')
+ ->parameters(
+ TemplateParam::init('customer_id', $customerId),
+ TemplateParam::init('token_id', $tokenId)
+ );
$_resHandler = $this->responseHandler()->type(GetAccessTokenResponse::class);
@@ -484,6 +504,7 @@ public function updateCustomerMetadata(
?string $idempotencyKey = null
): GetCustomerResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Customers/{customer_id}/metadata')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
BodyParam::init($request),
@@ -509,6 +530,7 @@ public function updateCustomerMetadata(
public function deleteCard(string $customerId, string $cardId, ?string $idempotencyKey = null): GetCardResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/customers/{customer_id}/cards/{card_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
TemplateParam::init('card_id', $cardId),
@@ -534,6 +556,7 @@ public function deleteCard(string $customerId, string $cardId, ?string $idempote
public function getAddresses(string $customerId, ?int $page = null, ?int $size = null): ListAddressesResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/addresses')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('customer_id', $customerId),
QueryParam::init('page', $page),
@@ -557,6 +580,7 @@ public function getAddresses(string $customerId, ?int $page = null, ?int $size =
public function getCustomer(string $customerId): GetCustomerResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('customer_id', $customerId));
$_resHandler = $this->responseHandler()->type(GetCustomerResponse::class);
@@ -577,6 +601,7 @@ public function getCustomer(string $customerId): GetCustomerResponse
public function getCard(string $customerId, string $cardId): GetCardResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/customers/{customer_id}/cards/{card_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('customer_id', $customerId), TemplateParam::init('card_id', $cardId));
$_resHandler = $this->responseHandler()->type(GetCardResponse::class);
diff --git a/src/Controllers/InvoicesController.php b/src/Controllers/InvoicesController.php
index 375eaa6..b875abc 100644
--- a/src/Controllers/InvoicesController.php
+++ b/src/Controllers/InvoicesController.php
@@ -42,6 +42,7 @@ public function updateInvoiceMetadata(
?string $idempotencyKey = null
): GetInvoiceResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/invoices/{invoice_id}/metadata')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('invoice_id', $invoiceId),
BodyParam::init($request),
@@ -65,7 +66,7 @@ public function getPartialInvoice(string $subscriptionId): GetInvoiceResponse
$_reqBuilder = $this->requestBuilder(
RequestMethod::GET,
'/subscriptions/{subscription_id}/partial-invoice'
- )->parameters(TemplateParam::init('subscription_id', $subscriptionId));
+ )->auth('httpBasic')->parameters(TemplateParam::init('subscription_id', $subscriptionId));
$_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class);
@@ -85,6 +86,7 @@ public function getPartialInvoice(string $subscriptionId): GetInvoiceResponse
public function cancelInvoice(string $invoiceId, ?string $idempotencyKey = null): GetInvoiceResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/invoices/{invoice_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('invoice_id', $invoiceId),
HeaderParam::init('idempotency-key', $idempotencyKey)
@@ -117,6 +119,7 @@ public function createInvoice(
RequestMethod::POST,
'/subscriptions/{subscription_id}/cycles/{cycle_id}/pay'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('cycle_id', $cycleId),
@@ -162,6 +165,7 @@ public function getInvoices(
?string $customerDocument = null
): ListInvoicesResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('page', $page),
QueryParam::init('size', $size),
@@ -195,6 +199,7 @@ public function getInvoices(
public function getInvoice(string $invoiceId): GetInvoiceResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/invoices/{invoice_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('invoice_id', $invoiceId));
$_resHandler = $this->responseHandler()->type(GetInvoiceResponse::class);
@@ -219,6 +224,7 @@ public function updateInvoiceStatus(
?string $idempotencyKey = null
): GetInvoiceResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/invoices/{invoice_id}/status')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('invoice_id', $invoiceId),
BodyParam::init($request),
diff --git a/src/Controllers/OrdersController.php b/src/Controllers/OrdersController.php
index fd63294..71c36cc 100644
--- a/src/Controllers/OrdersController.php
+++ b/src/Controllers/OrdersController.php
@@ -53,6 +53,7 @@ public function getOrders(
?string $customerId = null
): ListOrderResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('page', $page),
QueryParam::init('size', $size),
@@ -87,6 +88,7 @@ public function updateOrderItem(
?string $idempotencyKey = null
): GetOrderItemResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/orders/{orderId}/items/{itemId}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('orderId', $orderId),
TemplateParam::init('itemId', $itemId),
@@ -110,6 +112,7 @@ public function updateOrderItem(
public function deleteAllOrderItems(string $orderId, ?string $idempotencyKey = null): GetOrderResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('orderId', $orderId),
HeaderParam::init('idempotency-key', $idempotencyKey)
@@ -135,6 +138,7 @@ public function deleteOrderItem(
?string $idempotencyKey = null
): GetOrderItemResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/orders/{orderId}/items/{itemId}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('orderId', $orderId),
TemplateParam::init('itemId', $itemId),
@@ -161,6 +165,7 @@ public function closeOrder(
?string $idempotencyKey = null
): GetOrderResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/orders/{id}/closed')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('id', $id),
BodyParam::init($request),
@@ -185,6 +190,7 @@ public function closeOrder(
public function createOrder(CreateOrderRequest $body, ?string $idempotencyKey = null): GetOrderResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders')
+ ->auth('httpBasic')
->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey));
$_resHandler = $this->responseHandler()->type(GetOrderResponse::class);
@@ -207,6 +213,7 @@ public function createOrderItem(
?string $idempotencyKey = null
): GetOrderItemResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/orders/{orderId}/items')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('orderId', $orderId),
BodyParam::init($request),
@@ -229,6 +236,7 @@ public function createOrderItem(
public function getOrderItem(string $orderId, string $itemId): GetOrderItemResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{orderId}/items/{itemId}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('orderId', $orderId), TemplateParam::init('itemId', $itemId));
$_resHandler = $this->responseHandler()->type(GetOrderItemResponse::class);
@@ -253,6 +261,7 @@ public function updateOrderMetadata(
?string $idempotencyKey = null
): GetOrderResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Orders/{order_id}/metadata')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('order_id', $orderId),
BodyParam::init($request),
@@ -276,6 +285,7 @@ public function updateOrderMetadata(
public function getOrder(string $orderId): GetOrderResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/orders/{order_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('order_id', $orderId));
$_resHandler = $this->responseHandler()->type(GetOrderResponse::class);
diff --git a/src/Controllers/PayablesController.php b/src/Controllers/PayablesController.php
index 1573c9b..b16ed8f 100644
--- a/src/Controllers/PayablesController.php
+++ b/src/Controllers/PayablesController.php
@@ -65,6 +65,7 @@ public function getPayables(
?int $gatewayId = null
): ListPayablesResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/payables')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('type', $type),
QueryParam::init('split_id', $splitId),
@@ -106,6 +107,7 @@ public function getPayables(
public function getPayableById(int $id): GetPayableResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/payables/{id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('id', $id));
$_resHandler = $this->responseHandler()->type(GetPayableResponse::class);
diff --git a/src/Controllers/PlansController.php b/src/Controllers/PlansController.php
index 990bdd2..a834244 100644
--- a/src/Controllers/PlansController.php
+++ b/src/Controllers/PlansController.php
@@ -40,6 +40,7 @@ class PlansController extends BaseController
public function getPlan(string $planId): GetPlanResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans/{plan_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('plan_id', $planId));
$_resHandler = $this->responseHandler()->type(GetPlanResponse::class);
@@ -60,6 +61,7 @@ public function getPlan(string $planId): GetPlanResponse
public function deletePlan(string $planId, ?string $idempotencyKey = null): GetPlanResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('plan_id', $planId),
HeaderParam::init('idempotency-key', $idempotencyKey)
@@ -87,6 +89,7 @@ public function updatePlanMetadata(
?string $idempotencyKey = null
): GetPlanResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Plans/{plan_id}/metadata')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('plan_id', $planId),
BodyParam::init($request),
@@ -117,6 +120,7 @@ public function updatePlanItem(
?string $idempotencyKey = null
): GetPlanItemResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}/items/{plan_item_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('plan_id', $planId),
TemplateParam::init('plan_item_id', $planItemId),
@@ -146,6 +150,7 @@ public function createPlanItem(
?string $idempotencyKey = null
): GetPlanItemResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans/{plan_id}/items')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('plan_id', $planId),
BodyParam::init($request),
@@ -170,6 +175,7 @@ public function createPlanItem(
public function getPlanItem(string $planId, string $planItemId): GetPlanItemResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans/{plan_id}/items/{plan_item_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('plan_id', $planId), TemplateParam::init('plan_item_id', $planItemId));
$_resHandler = $this->responseHandler()->type(GetPlanItemResponse::class);
@@ -190,6 +196,7 @@ public function getPlanItem(string $planId, string $planItemId): GetPlanItemResp
public function createPlan(CreatePlanRequest $body, ?string $idempotencyKey = null): GetPlanResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/plans')
+ ->auth('httpBasic')
->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey));
$_resHandler = $this->responseHandler()->type(GetPlanResponse::class);
@@ -214,6 +221,7 @@ public function deletePlanItem(
?string $idempotencyKey = null
): GetPlanItemResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/plans/{plan_id}/items/{plan_item_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('plan_id', $planId),
TemplateParam::init('plan_item_id', $planItemId),
@@ -250,6 +258,7 @@ public function getPlans(
?\DateTime $createdUntil = null
): ListPlansResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/plans')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('page', $page),
QueryParam::init('size', $size),
@@ -284,6 +293,7 @@ public function updatePlan(
?string $idempotencyKey = null
): GetPlanResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/plans/{plan_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('plan_id', $planId),
BodyParam::init($request),
diff --git a/src/Controllers/RecipientsController.php b/src/Controllers/RecipientsController.php
index 0128c99..d5868ad 100644
--- a/src/Controllers/RecipientsController.php
+++ b/src/Controllers/RecipientsController.php
@@ -56,6 +56,7 @@ public function updateRecipient(
?string $idempotencyKey = null
): GetRecipientResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PUT, '/recipients/{recipient_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
BodyParam::init($request),
@@ -84,6 +85,7 @@ public function createAnticipation(
?string $idempotencyKey = null
): GetAnticipationResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/anticipations')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
BodyParam::init($request),
@@ -112,6 +114,7 @@ public function getAnticipationLimits(
\DateTime $paymentDate
): GetAnticipationLimitResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipation_limits')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
QueryParam::init('timeframe', $timeframe),
@@ -137,6 +140,7 @@ public function getAnticipationLimits(
public function getRecipients(?int $page = null, ?int $size = null): ListRecipientResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients')
+ ->auth('httpBasic')
->parameters(QueryParam::init('page', $page), QueryParam::init('size', $size));
$_resHandler = $this->responseHandler()->type(ListRecipientResponse::class);
@@ -158,6 +162,7 @@ public function getWithdrawById(string $recipientId, string $withdrawalId): GetW
RequestMethod::GET,
'/recipients/{recipient_id}/withdrawals/{withdrawal_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
TemplateParam::init('withdrawal_id', $withdrawalId)
@@ -188,6 +193,7 @@ public function updateRecipientDefaultBankAccount(
RequestMethod::PATCH,
'/recipients/{recipient_id}/default-bank-account'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
BodyParam::init($request),
@@ -216,6 +222,7 @@ public function updateRecipientMetadata(
?string $idempotencyKey = null
): GetRecipientResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/metadata')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
BodyParam::init($request),
@@ -250,6 +257,7 @@ public function getTransfers(
?\DateTime $createdUntil = null
): ListTransferResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/transfers')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
QueryParam::init('page', $page),
@@ -282,6 +290,7 @@ public function getTransfer(string $recipientId, string $transferId): GetTransfe
RequestMethod::GET,
'/recipients/{recipient_id}/transfers/{transfer_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
TemplateParam::init('transfer_id', $transferId)
@@ -303,6 +312,7 @@ public function getTransfer(string $recipientId, string $transferId): GetTransfe
public function createWithdraw(string $recipientId, CreateWithdrawRequest $request): GetWithdrawResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/withdrawals')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('recipient_id', $recipientId), BodyParam::init($request));
$_resHandler = $this->responseHandler()->type(GetWithdrawResponse::class);
@@ -330,6 +340,7 @@ public function updateAutomaticAnticipationSettings(
RequestMethod::PATCH,
'/recipients/{recipient_id}/automatic-anticipation-settings'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
BodyParam::init($request),
@@ -357,6 +368,7 @@ public function getAnticipation(string $recipientId, string $anticipationId): Ge
RequestMethod::GET,
'/recipients/{recipient_id}/anticipations/{anticipation_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
TemplateParam::init('anticipation_id', $anticipationId)
@@ -382,6 +394,7 @@ public function updateRecipientTransferSettings(
?string $idempotencyKey = null
): GetRecipientResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/recipients/{recipient_id}/transfer-settings')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
BodyParam::init($request),
@@ -422,6 +435,7 @@ public function getAnticipations(
?\DateTime $createdUntil = null
): ListAnticipationResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/anticipations')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
QueryParam::init('page', $page),
@@ -455,6 +469,7 @@ public function getAnticipations(
public function getRecipient(string $recipientId): GetRecipientResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('recipient_id', $recipientId));
$_resHandler = $this->responseHandler()->type(GetRecipientResponse::class);
@@ -474,6 +489,7 @@ public function getRecipient(string $recipientId): GetRecipientResponse
public function getBalance(string $recipientId): GetBalanceResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/balance')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('recipient_id', $recipientId));
$_resHandler = $this->responseHandler()->type(GetBalanceResponse::class);
@@ -504,6 +520,7 @@ public function getWithdrawals(
?\DateTime $createdUntil = null
): ListWithdrawals {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{recipient_id}/withdrawals')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
QueryParam::init('page', $page),
@@ -537,6 +554,7 @@ public function createTransfer(
?string $idempotencyKey = null
): GetTransferResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients/{recipient_id}/transfers')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('recipient_id', $recipientId),
BodyParam::init($request),
@@ -563,6 +581,7 @@ public function createRecipient(
?string $idempotencyKey = null
): GetRecipientResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/recipients')
+ ->auth('httpBasic')
->parameters(BodyParam::init($request), HeaderParam::init('idempotency-key', $idempotencyKey));
$_resHandler = $this->responseHandler()->type(GetRecipientResponse::class);
@@ -582,6 +601,7 @@ public function createRecipient(
public function getRecipientByCode(string $code): GetRecipientResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/{code}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('code', $code));
$_resHandler = $this->responseHandler()->type(GetRecipientResponse::class);
@@ -596,7 +616,7 @@ public function getRecipientByCode(string $code): GetRecipientResponse
*/
public function getDefaultRecipient(): GetRecipientResponse
{
- $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default');
+ $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/recipients/default')->auth('httpBasic');
$_resHandler = $this->responseHandler()->type(GetRecipientResponse::class);
diff --git a/src/Controllers/SubscriptionsController.php b/src/Controllers/SubscriptionsController.php
index a0641f7..e1df1b4 100644
--- a/src/Controllers/SubscriptionsController.php
+++ b/src/Controllers/SubscriptionsController.php
@@ -62,6 +62,7 @@ class SubscriptionsController extends BaseController
public function renewSubscription(string $subscriptionId, ?string $idempotencyKey = null): GetPeriodResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/cycles')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
HeaderParam::init('idempotency-key', $idempotencyKey)
@@ -89,6 +90,7 @@ public function updateSubscriptionCard(
?string $idempotencyKey = null
): GetSubscriptionResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/card')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -122,6 +124,7 @@ public function deleteUsage(
RequestMethod::DELETE,
'/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('item_id', $itemId),
@@ -151,6 +154,7 @@ public function createDiscount(
?string $idempotencyKey = null
): GetDiscountResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/discounts')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -182,6 +186,7 @@ public function createAnUsage(
RequestMethod::POST,
'/subscriptions/{subscription_id}/items/{item_id}/usages'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('item_id', $itemId),
@@ -209,6 +214,7 @@ public function updateCurrentCycleStatus(
?string $idempotencyKey = null
): void {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/cycle-status')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -238,6 +244,7 @@ public function deleteDiscount(
RequestMethod::DELETE,
'/subscriptions/{subscription_id}/discounts/{discount_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('discount_id', $discountId),
@@ -278,6 +285,7 @@ public function getSubscriptionItems(
?string $createdUntil = null
): ListSubscriptionItemsResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/items')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
QueryParam::init('page', $page),
@@ -316,6 +324,7 @@ public function updateSubscriptionPaymentMethod(
RequestMethod::PATCH,
'/subscriptions/{subscription_id}/payment-method'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -343,6 +352,7 @@ public function getSubscriptionItem(string $subscriptionId, string $itemId): Get
RequestMethod::GET,
'/subscriptions/{subscription_id}/items/{item_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('item_id', $itemId)
@@ -389,6 +399,7 @@ public function getSubscriptions(
?\DateTime $createdUntil = null
): ListSubscriptionsResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions')
+ ->auth('httpBasic')
->parameters(
QueryParam::init('page', $page),
QueryParam::init('size', $size),
@@ -430,6 +441,7 @@ public function cancelSubscription(
?string $idempotencyKey = null
): GetSubscriptionResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/subscriptions/{subscription_id}')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -458,6 +470,7 @@ public function createIncrement(
?string $idempotencyKey = null
): GetIncrementResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/increments')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -491,6 +504,7 @@ public function createUsage(
RequestMethod::POST,
'/subscriptions/{subscription_id}/items/{item_id}/usages'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('item_id', $itemId),
@@ -517,6 +531,7 @@ public function getDiscountById(string $subscriptionId, string $discountId): Get
RequestMethod::GET,
'/subscriptions/{subscription_id}/discounts/{discountId}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('discountId', $discountId)
@@ -542,6 +557,7 @@ public function createSubscription(
?string $idempotencyKey = null
): GetSubscriptionResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions')
+ ->auth('httpBasic')
->parameters(BodyParam::init($body), HeaderParam::init('idempotency-key', $idempotencyKey));
$_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class);
@@ -563,6 +579,7 @@ public function getIncrementById(string $subscriptionId, string $incrementId): G
RequestMethod::GET,
'/subscriptions/{subscription_id}/increments/{increment_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('increment_id', $incrementId)
@@ -592,6 +609,7 @@ public function updateSubscriptionAffiliationId(
RequestMethod::PATCH,
'/subscriptions/{subscription_id}/gateway-affiliation-id'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -620,6 +638,7 @@ public function updateSubscriptionMetadata(
?string $idempotencyKey = null
): GetSubscriptionResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/Subscriptions/{subscription_id}/metadata')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -651,6 +670,7 @@ public function deleteIncrement(
RequestMethod::DELETE,
'/subscriptions/{subscription_id}/increments/{increment_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('increment_id', $incrementId),
@@ -674,6 +694,7 @@ public function deleteIncrement(
public function getSubscriptionCycles(string $subscriptionId, string $page, string $size): ListCyclesResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/cycles')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
QueryParam::init('page', $page),
@@ -697,6 +718,7 @@ public function getSubscriptionCycles(string $subscriptionId, string $page, stri
public function getDiscounts(string $subscriptionId, int $page, int $size): ListDiscountsResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/discounts/')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
QueryParam::init('page', $page),
@@ -726,6 +748,7 @@ public function updateSubscriptionBillingDate(
?string $idempotencyKey = null
): GetSubscriptionResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/billing-date')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -757,6 +780,7 @@ public function deleteSubscriptionItem(
RequestMethod::DELETE,
'/subscriptions/{subscription_id}/items/{subscription_item_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('subscription_item_id', $subscriptionItemId),
@@ -780,6 +804,7 @@ public function deleteSubscriptionItem(
public function getIncrements(string $subscriptionId, ?int $page = null, ?int $size = null): ListIncrementsResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}/increments/')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
QueryParam::init('page', $page),
@@ -811,6 +836,7 @@ public function updateSubscriptionDueDays(
RequestMethod::PATCH,
'/subscriptions/{subscription_id}/boleto-due-days'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -840,6 +866,7 @@ public function updateSubscriptionStartAt(
?string $idempotencyKey = null
): GetSubscriptionResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{subscription_id}/start-at')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -873,6 +900,7 @@ public function updateSubscriptionItem(
RequestMethod::PUT,
'/subscriptions/{subscription_id}/items/{item_id}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('item_id', $itemId),
@@ -902,6 +930,7 @@ public function createSubscriptionItem(
?string $idempotencyKey = null
): GetSubscriptionItemResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/subscriptions/{subscription_id}/items')
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -925,6 +954,7 @@ public function createSubscriptionItem(
public function getSubscription(string $subscriptionId): GetSubscriptionResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/subscriptions/{subscription_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('subscription_id', $subscriptionId));
$_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class);
@@ -962,6 +992,7 @@ public function getUsages(
RequestMethod::GET,
'/subscriptions/{subscription_id}/items/{item_id}/usages'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('item_id', $itemId),
@@ -997,6 +1028,7 @@ public function updateLatestPeriodEndAt(
RequestMethod::PATCH,
'/subscriptions/{subscription_id}/periods/latest/end-at'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -1029,6 +1061,7 @@ public function updateSubscriptionMiniumPrice(
RequestMethod::PATCH,
'/subscriptions/{subscription_id}/minimum_price'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
BodyParam::init($request),
@@ -1054,6 +1087,7 @@ public function getSubscriptionCycleById(string $subscriptionId, string $cycleId
RequestMethod::GET,
'/subscriptions/{subscription_id}/cycles/{cycleId}'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('cycleId', $cycleId)
@@ -1078,6 +1112,7 @@ public function getUsageReport(string $subscriptionId, string $periodId): GetUsa
RequestMethod::GET,
'/subscriptions/{subscription_id}/periods/{period_id}/usages/report'
)
+ ->auth('httpBasic')
->parameters(
TemplateParam::init('subscription_id', $subscriptionId),
TemplateParam::init('period_id', $periodId)
@@ -1101,6 +1136,7 @@ public function updateSplitSubscription(
UpdateSubscriptionSplitRequest $request
): GetSubscriptionResponse {
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/subscriptions/{id}/split')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('id', $id), BodyParam::init($request));
$_resHandler = $this->responseHandler()->type(GetSubscriptionResponse::class);
diff --git a/src/Controllers/TransactionsController.php b/src/Controllers/TransactionsController.php
index 152a9c6..a343692 100644
--- a/src/Controllers/TransactionsController.php
+++ b/src/Controllers/TransactionsController.php
@@ -27,6 +27,7 @@ class TransactionsController extends BaseController
public function getTransaction(string $transactionId): GetTransactionResponse
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transactions/{transaction_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('transaction_id', $transactionId));
$_resHandler = $this->responseHandler()->type(GetTransactionResponse::class);
diff --git a/src/Controllers/TransfersController.php b/src/Controllers/TransfersController.php
index e465ebb..ae71c1e 100644
--- a/src/Controllers/TransfersController.php
+++ b/src/Controllers/TransfersController.php
@@ -30,6 +30,7 @@ class TransfersController extends BaseController
public function getTransferById(string $transferId): GetTransfer
{
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers/{transfer_id}')
+ ->auth('httpBasic')
->parameters(TemplateParam::init('transfer_id', $transferId));
$_resHandler = $this->responseHandler()->type(GetTransfer::class);
@@ -47,6 +48,7 @@ public function getTransferById(string $transferId): GetTransfer
public function createTransfer(CreateTransfer $request): GetTransfer
{
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/transfers/recipients')
+ ->auth('httpBasic')
->parameters(BodyParam::init($request));
$_resHandler = $this->responseHandler()->type(GetTransfer::class);
@@ -63,7 +65,7 @@ public function createTransfer(CreateTransfer $request): GetTransfer
*/
public function getTransfers(): ListTransfers
{
- $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers');
+ $_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/transfers')->auth('httpBasic');
$_resHandler = $this->responseHandler()->type(ListTransfers::class);
diff --git a/src/PagarmeApiSDKClient.php b/src/PagarmeApiSDKClient.php
index 7fa5f1a..b1bcdde 100644
--- a/src/PagarmeApiSDKClient.php
+++ b/src/PagarmeApiSDKClient.php
@@ -14,6 +14,8 @@
use Core\Request\Parameters\HeaderParam;
use Core\Response\Types\ErrorType;
use Core\Utils\CoreHelper;
+use PagarmeApiSDKLib\Authentication\BasicAuthCredentialsBuilder;
+use PagarmeApiSDKLib\Authentication\BasicAuthManager;
use PagarmeApiSDKLib\Controllers\BalanceOperationsController;
use PagarmeApiSDKLib\Controllers\ChargesController;
use PagarmeApiSDKLib\Controllers\CustomersController;
@@ -57,6 +59,8 @@ class PagarmeApiSDKClient implements ConfigurationInterface
private $balanceOperations;
+ private $basicAuthManager;
+
private $config;
private $client;
@@ -70,14 +74,19 @@ class PagarmeApiSDKClient implements ConfigurationInterface
public function __construct(array $config = [])
{
$this->config = array_merge(ConfigurationDefaults::_ALL, CoreHelper::clone($config));
+ $this->basicAuthManager = new BasicAuthManager(
+ $this->config['basicAuthUserName'] ?? ConfigurationDefaults::BASIC_AUTH_USER_NAME,
+ $this->config['basicAuthPassword'] ?? ConfigurationDefaults::BASIC_AUTH_PASSWORD
+ );
$this->client = ClientBuilder::init(new HttpClient(Configuration::init($this)))
->converter(new CompatibilityConverter())
->jsonHelper(ApiHelper::getJsonHelper())
->apiCallback($this->config['httpCallback'] ?? null)
- ->userAgent('PagarmeApiSDK - PHP 6.8.5')
+ ->userAgent('PagarmeApiSDK - PHP 6.8.6')
->globalConfig($this->getGlobalConfiguration())
->globalErrors($this->getGlobalErrors())
->serverUrls(self::ENVIRONMENT_MAP[$this->getEnvironment()], Server::DEFAULT_)
+ ->authManagers(['httpBasic' => $this->basicAuthManager])
->build();
}
@@ -88,7 +97,7 @@ public function __construct(array $config = [])
*/
public function toBuilder(): PagarmeApiSDKClientBuilder
{
- return PagarmeApiSDKClientBuilder::init()
+ $builder = PagarmeApiSDKClientBuilder::init()
->timeout($this->getTimeout())
->enableRetries($this->shouldEnableRetries())
->numberOfRetries($this->getNumberOfRetries())
@@ -101,6 +110,12 @@ public function toBuilder(): PagarmeApiSDKClientBuilder
->serviceRefererName($this->getServiceRefererName())
->environment($this->getEnvironment())
->httpCallback($this->config['httpCallback'] ?? null);
+
+ $basicAuth = $this->getBasicAuthCredentialsBuilder();
+ if ($basicAuth != null) {
+ $builder->basicAuthCredentials($basicAuth);
+ }
+ return $builder;
}
public function getTimeout(): int
@@ -158,6 +173,25 @@ public function getEnvironment(): string
return $this->config['environment'] ?? ConfigurationDefaults::ENVIRONMENT;
}
+ public function getBasicAuthCredentials(): BasicAuthCredentials
+ {
+ return $this->basicAuthManager;
+ }
+
+ public function getBasicAuthCredentialsBuilder(): ?BasicAuthCredentialsBuilder
+ {
+ if (
+ empty($this->basicAuthManager->getBasicAuthUserName()) &&
+ empty($this->basicAuthManager->getBasicAuthPassword())
+ ) {
+ return null;
+ }
+ return BasicAuthCredentialsBuilder::init(
+ $this->basicAuthManager->getBasicAuthUserName(),
+ $this->basicAuthManager->getBasicAuthPassword()
+ );
+ }
+
/**
* Get the client configuration as an associative array
*
diff --git a/src/PagarmeApiSDKClientBuilder.php b/src/PagarmeApiSDKClientBuilder.php
index 2576358..cff686d 100644
--- a/src/PagarmeApiSDKClientBuilder.php
+++ b/src/PagarmeApiSDKClientBuilder.php
@@ -12,6 +12,7 @@
use Core\Types\Sdk\CoreCallback;
use Core\Utils\CoreHelper;
+use PagarmeApiSDKLib\Authentication\BasicAuthCredentialsBuilder;
class PagarmeApiSDKClientBuilder
{
@@ -113,6 +114,44 @@ public function environment(string $environment): self
return $this;
}
+ /**
+ * @see PagarmeApiSDKClientBuilder::basicAuthCredentials
+ *
+ * @deprecated This builder setter is deprecated. Checkout the see also section for its
+ * alternate.
+ *
+ * @param string $basicAuthUserName
+ *
+ * @return $this
+ */
+ public function basicAuthUserName(string $basicAuthUserName): self
+ {
+ $this->config['basicAuthUserName'] = $basicAuthUserName;
+ return $this;
+ }
+
+ /**
+ * @see PagarmeApiSDKClientBuilder::basicAuthCredentials
+ *
+ * @deprecated This builder setter is deprecated. Checkout the see also section for its
+ * alternate.
+ *
+ * @param string $basicAuthPassword
+ *
+ * @return $this
+ */
+ public function basicAuthPassword(string $basicAuthPassword): self
+ {
+ $this->config['basicAuthPassword'] = $basicAuthPassword;
+ return $this;
+ }
+
+ public function basicAuthCredentials(BasicAuthCredentialsBuilder $basicAuth): self
+ {
+ $this->config = array_merge($this->config, $basicAuth->getConfiguration());
+ return $this;
+ }
+
public function httpCallback($httpCallback): self
{
if (!$httpCallback instanceof CoreCallback) {