-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add credit memo transaction allocations
- Loading branch information
Boyd Bueno de Mesquita
committed
Sep 6, 2022
1 parent
6cd1f9b
commit a74b6c4
Showing
6 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* This source file is proprietary and part of Rebilly. | ||
* | ||
* (c) Rebilly SRL | ||
* Rebilly Ltd. | ||
* Rebilly Inc. | ||
* | ||
* @see https://www.rebilly.com | ||
*/ | ||
|
||
namespace Rebilly\Entities; | ||
|
||
use Rebilly\Rest\Entity; | ||
|
||
/** | ||
* Class CreditMemoTransactionAllocation. | ||
*/ | ||
final class CreditMemoTransactionAllocation extends Entity | ||
{ | ||
/** | ||
* @return float | ||
*/ | ||
public function getAmount() | ||
{ | ||
return $this->getAttribute('amount'); | ||
} | ||
|
||
/** | ||
* @param float $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setAmount($value) | ||
{ | ||
return $this->setAttribute('amount', $value); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCreditMemoId() | ||
{ | ||
return $this->getAttribute('creditMemoId'); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTransactionId() | ||
{ | ||
return $this->getAttribute('transactionId'); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCurrency() | ||
{ | ||
return $this->getAttribute('currency'); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCreatedTime() | ||
{ | ||
return $this->getAttribute('createdTime'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/Services/CreditMemoTransactionAllocationService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
/** | ||
* This source file is proprietary and part of Rebilly. | ||
* | ||
* (c) Rebilly SRL | ||
* Rebilly Ltd. | ||
* Rebilly Inc. | ||
* | ||
* @see https://www.rebilly.com | ||
*/ | ||
|
||
namespace Rebilly\Services; | ||
|
||
use ArrayObject; | ||
use JsonSerializable; | ||
use Rebilly\Entities\CreditMemoTransactionAllocation; | ||
use Rebilly\Http\Exception\DataValidationException; | ||
use Rebilly\Http\Exception\NotFoundException; | ||
use Rebilly\Paginator; | ||
use Rebilly\Rest\Collection; | ||
use Rebilly\Rest\Service; | ||
|
||
/** | ||
* Class CreditMemoTransactionAllocationService. | ||
*/ | ||
final class CreditMemoTransactionAllocationService extends Service | ||
{ | ||
/** | ||
* @param string $creditMemoId | ||
* @param array|ArrayObject $params | ||
* | ||
* @return CreditMemoTransactionAllocation[][]|Collection[]|Paginator | ||
*/ | ||
public function paginator($creditMemoId, $params = []) | ||
{ | ||
return new Paginator( | ||
$this->client(), | ||
'credit-memos/{creditMemoId}/transaction-allocations', | ||
['creditMemoId' => $creditMemoId] + (array) $params | ||
); | ||
} | ||
|
||
/** | ||
* @param string $creditMemoId | ||
* @param array|ArrayObject $params | ||
* | ||
* @return CreditMemoTransactionAllocation[]|Collection | ||
*/ | ||
public function search($creditMemoId, $params = []) | ||
{ | ||
return $this->client()->get( | ||
'credit-memos/{creditMemoId}/transaction-allocations', | ||
['creditMemoId' => $creditMemoId] + (array) $params | ||
); | ||
} | ||
|
||
/** | ||
* @param string $creditMemoId | ||
* @param string $transactionId | ||
* | ||
* @return CreditMemoTransactionAllocation | ||
*@throws NotFoundException if resource does not exist | ||
* | ||
*/ | ||
public function load($creditMemoId, $transactionId) | ||
{ | ||
return $this->client()->get( | ||
'credit-memos/{creditMemoId}/transaction-allocations/{transactionId}', | ||
['transactionId' => $transactionId, 'creditMemoId' => $creditMemoId] | ||
); | ||
} | ||
|
||
/** | ||
* @param string $creditMemoId | ||
* @param string $transactionId | ||
* @param array|JsonSerializable|CreditMemoTransactionAllocation $data | ||
* | ||
* @return CreditMemoTransactionAllocation | ||
* @throws DataValidationException if input data is not valid | ||
* | ||
*/ | ||
public function update($creditMemoId, $transactionId, $data) | ||
{ | ||
return $this->client()->put( | ||
$data, | ||
'credit-memos/{creditMemoId}/transaction-allocations/{transactionId}', | ||
['transactionId' => $transactionId, 'creditMemoId' => $creditMemoId] | ||
); | ||
} | ||
|
||
/** | ||
* @param string $creditMemoId | ||
* @param string $transactionId | ||
*/ | ||
public function delete($creditMemoId, $transactionId) | ||
{ | ||
$this->client()->delete( | ||
'credit-memos/{creditMemoId}/transaction-allocations/{transactionId}', | ||
['transactionId' => $transactionId, 'creditMemoId' => $creditMemoId] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters