Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/remove bulkantecipation routes v3 #423

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ Integração em PHP para a [Pagar.me API](https://docs.pagar.me/)
- [Antecipações](#Antecipações)
- [Criando uma antecipação](#Criando-uma-antecipação)
- [Obtendo os limites de antecipação](#Obtendo-os-limites-de-antecipação)
- [Confirmando uma antecipação building](#Confirmando-uma-antecipação-building)
- [Cancelando uma antecipação pending](#Cancelando-uma-antecipação-pending)
- [Deletando uma antecipação building](#Deletando-uma-antecipação-building)
- [Retornando antecipações](#Retornando-antecipações)
- [Contas bancárias](#Contas-bancárias)
- [Criando uma conta bancária](#Criando-uma-conta-bancária)
Expand Down Expand Up @@ -848,13 +846,11 @@ $date = new \DateTime();
$date->add(new \DateInterval("P10D"));
$timeframe = 'end';
$requestedAmount = 13000;
$build = true;
$anticipation = $pagarMe->bulkAnticipation()->create(
$recipient,
$date,
$timeframe,
$requestedAmount,
$build
$requestedAmount
);
```

Expand All @@ -877,24 +873,6 @@ $limits = $pagarMe->bulkAnticipation()->limits(
);
```

### Confirmando uma antecipação building

```php
<?php
$recipient = new \PagarMe\Sdk\Recipient\Recipient([
"id" => "re_ciu4jif1j007td56dsm17yew9"
]);

$anticipation = new PagarMe\Sdk\BulkAnticipation\BulkAnticipation([
"id" => "ba_cj3uppown001gvm6dqgmjw2ce"
]);

$anticipation = $pagarMe->bulkAnticipation()->confirm(
$recipient,
$anticipation
);
```

### Cancelando uma antecipação pending

```php
Expand All @@ -913,24 +891,6 @@ $anticipation = $pagarMe->bulkAnticipation()->cancel(
);
```

### Deletando uma antecipação building

```php
<?php
$recipient = new \PagarMe\Sdk\Recipient\Recipient([
"id" => "re_ciu4jif1j007td56dsm17yew9"
]);

$anticipation = new PagarMe\Sdk\BulkAnticipation\BulkAnticipation([
"id" => "ba_cj3us6nal0022v86daxfamp4t"
]);

$anticipation = $pagarMe->bulkAnticipation()->delete(
$recipient,
$anticipation
);
```

### Retornando antecipações

```php
Expand Down
35 changes: 1 addition & 34 deletions lib/BulkAnticipation/BulkAnticipationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@ class BulkAnticipationHandler extends AbstractHandler
* @param DateTime $paymentDate
* @param string $timeframe
* @param int $requestedAmount
* @param boolean $building
* @return BulkAnticipation
*/
public function create(
Recipient $recipient,
\DateTime $paymentDate,
$timeframe,
$requestedAmount,
$building
$requestedAmount
) {
$request = new BulkAnticipationCreate(
$recipient,
$paymentDate,
$timeframe,
$requestedAmount,
$building
);

$response = $this->client->send($request);
Expand All @@ -58,22 +55,6 @@ public function limits($recipient, $paymentDate, $timeframe)
return $this->client->send($request);
}

/**
* @param Recipient $recipient
* @param BulkAnticipation $bulkAnticipation
* @return BulkAnticipation
*/
public function confirm(
Recipient $recipient,
BulkAnticipation $bulkAnticipation
) {
$request = new BulkAnticipationConfirm($recipient, $bulkAnticipation);

$response = $this->client->send($request);

return $this->buildBulkAnticipation($response);
}

/**
* @param Recipient $recipient
* @param BulkAnticipation $bulkAnticipation
Expand All @@ -90,20 +71,6 @@ public function cancel(
return $this->buildBulkAnticipation($response);
}

/**
* @param Recipient $recipient
* @param BulkAnticipation $bulkAnticipation
* @return array
*/
public function delete(
Recipient $recipient,
BulkAnticipation $bulkAnticipation
) {
$request = new BulkAnticipationDelete($recipient, $bulkAnticipation);

return $this->client->send($request);
}

/**
* @param Recipient $recipient
* @param int $page
Expand Down
59 changes: 0 additions & 59 deletions lib/BulkAnticipation/Request/BulkAnticipationConfirm.php

This file was deleted.

13 changes: 2 additions & 11 deletions lib/BulkAnticipation/Request/BulkAnticipationCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,22 @@ class BulkAnticipationCreate implements RequestInterface
*/
private $requestedAmount;

/**
* @var boolean
*/
private $building;

/**
* @param Recipient $recipient
* @param \DateTime $paymentDate
* @param string $timeframe
* @param int $requestedAmount
* @param boolean $building
*/
public function __construct(
Recipient $recipient,
\DateTime $paymentDate,
$timeframe,
$requestedAmount,
$building
$requestedAmount
) {
$this->recipient = $recipient;
$this->paymentDate = $paymentDate;
$this->timeframe = $timeframe;
$this->requestedAmount = $requestedAmount;
$this->building = $building;
}

/**
Expand All @@ -65,8 +57,7 @@ public function getPayload()
$this->paymentDate
),
'timeframe' => $this->timeframe,
'requested_amount' => $this->requestedAmount,
'build' => $this->building
'requested_amount' => $this->requestedAmount
];
}

Expand Down
59 changes: 0 additions & 59 deletions lib/BulkAnticipation/Request/BulkAnticipationDelete.php

This file was deleted.

49 changes: 3 additions & 46 deletions tests/acceptance/BulkAnticipationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class BulkAnticipationContext extends BasicContext
private $recipient;
private $anticipation;
private $expectedPaymentDate;
private $expectedStatus;
private $expectedTimeframe;
private $expectedRequestedAmount;

Expand Down Expand Up @@ -60,12 +59,10 @@ public function whichCompanyHasTransactionPaidWith($amount)
}

/**
* @When register a anticipation with :paymentDate, :timeframe, :requestedAmount, :build
* @When register a anticipation with :paymentDate, :timeframe, :requestedAmount
*/
public function registerAAnticipationWith($paymentDate, $timeframe, $requestedAmount, $build)
public function registerAAnticipationWith($paymentDate, $timeframe, $requestedAmount)
{
$build = filter_var($build, FILTER_VALIDATE_BOOLEAN);

$paymentDate = new \Datetime($paymentDate, new \DateTimeZone('UTC'));

$weekday = $paymentDate->format('w');
Expand All @@ -79,16 +76,14 @@ public function registerAAnticipationWith($paymentDate, $timeframe, $requestedAm
$this->expectedPaymentDate = $paymentDate;
$this->expectedTimeframe = $timeframe;
$this->expectedRequestedAmount = $requestedAmount;
$this->expectedStatus = ($build) ? 'building' : 'pending';

$this->anticipation = self::getPagarMe()
->BulkAnticipation()
->create(
$this->recipient,
$paymentDate,
$timeframe,
$requestedAmount,
$build
$requestedAmount
);
}

Expand All @@ -108,43 +103,5 @@ public function mustAnticipationContainSameData()
{
assertEquals($this->expectedPaymentDate, $this->anticipation->getPaymentDate());
assertEquals($this->expectedTimeframe, $this->anticipation->getTimeframe());

assertEquals($this->expectedStatus, $this->anticipation->getStatus());
}

/**
* @Then when I delete the previously created Anticipation
*/
public function iDeleteThePreviouslyCreatedAnticipation()
{
assertEquals(3, $this->countAnticipations());

$result = self::getPagarMe()
->bulkAnticipation()
->delete(
$this->recipient,
$this->anticipation
);

assertEquals([], $result);
}

/**
* @Then the Anticipation should no longer exist
*/
public function theAnticipationShouldNoLongerExist()
{
assertEquals(2, $this->countAnticipations());
}

private function countAnticipations()
{
return count(
self::getPagarMe()
->bulkAnticipation()
->getList(
$this->recipient
)
);
}
}
Loading