-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from andreciornavei/develop
deploy frontend ci
- Loading branch information
Showing
62 changed files
with
1,334 additions
and
187 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,40 @@ | ||
<?php | ||
|
||
namespace App\Domain\Entities; | ||
|
||
|
||
class BalanceSummaryEntity | ||
{ | ||
private $incomes; | ||
private $expenses; | ||
private $net; | ||
|
||
public function __construct(array | object $data) | ||
{ | ||
foreach ($data as $key => $value) { | ||
if (property_exists($this, $key)) { | ||
$this->$key = $value; | ||
} | ||
} | ||
} | ||
|
||
public function toJson() | ||
{ | ||
return get_object_vars($this); | ||
} | ||
|
||
public function getIncomes() | ||
{ | ||
return $this->incomes; | ||
} | ||
|
||
public function getExpenses() | ||
{ | ||
return $this->expenses; | ||
} | ||
|
||
public function getNet() | ||
{ | ||
return $this->net; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
backend/app/Domain/Repositories/IBalanceSummaryRepository/IBalanceSummaryDto.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,35 @@ | ||
<?php | ||
|
||
namespace App\Domain\Repositories\IBalanceSummaryRepository; | ||
|
||
|
||
class IBalanceSummaryDto | ||
{ | ||
private $user_id; | ||
private $period_from; | ||
private $period_to; | ||
|
||
public function __construct(array $data) | ||
{ | ||
foreach ($data as $key => $value) { | ||
if (property_exists($this, $key)) { | ||
$this->$key = $value; | ||
} | ||
} | ||
} | ||
|
||
public function getUserId() | ||
{ | ||
return $this->user_id ?? null; | ||
} | ||
|
||
public function getPeriodFrom() | ||
{ | ||
return $this->period_from ?? null; | ||
} | ||
|
||
public function getPeriodTo() | ||
{ | ||
return $this->period_to ?? null; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
backend/app/Domain/Repositories/IBalanceSummaryRepository/IBalanceSummaryRepository.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,10 @@ | ||
<?php | ||
|
||
namespace App\Domain\Repositories\IBalanceSummaryRepository; | ||
|
||
use App\Domain\Entities\BalanceSummaryEntity; | ||
|
||
interface IBalanceSummaryRepository | ||
{ | ||
public function handler(IBalanceSummaryDto $dto): BalanceSummaryEntity; | ||
} |
23 changes: 23 additions & 0 deletions
23
backend/app/Domain/Usecases/TransactionCheckUrl/TransactionCheckUrlDto.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,23 @@ | ||
<?php | ||
|
||
namespace App\Domain\Usecases\TransactionCheckUrl; | ||
|
||
class TransactionCheckUrlDto | ||
{ | ||
|
||
private $transaction_id; | ||
|
||
public function __construct(array $data) | ||
{ | ||
foreach ($data as $key => $value) { | ||
if (property_exists($this, $key)) { | ||
$this->$key = $value; | ||
} | ||
} | ||
} | ||
|
||
public function getTransactionId() | ||
{ | ||
return $this->transaction_id ?? null; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
backend/app/Domain/Usecases/TransactionCheckUrl/TransactionCheckUrlUseCase.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,70 @@ | ||
<?php | ||
|
||
namespace App\Domain\Usecases\TransactionCheckUrl; | ||
|
||
use App\Exceptions\JsonException; | ||
use Illuminate\Support\Facades\Validator; | ||
use App\Domain\Providers\IStorageProvider; | ||
use App\Domain\Entities\TransactionEntity; | ||
use App\Domain\Repositories\IFindTransactionRepository\IFindTransactionDto; | ||
use App\Domain\Repositories\IFindTransactionRepository\IFindTransactionRepository; | ||
|
||
class TransactionCheckUrlUseCase | ||
{ | ||
public function __construct( | ||
private readonly IFindTransactionRepository $findTransactionRepository, | ||
private readonly IStorageProvider $storageProvider | ||
) { | ||
} | ||
|
||
public function handler(TransactionCheckUrlDto $dto): string | ||
{ | ||
// create validate schema | ||
$validator = Validator::make( | ||
['transaction_id' => $dto->getTransactionId()], | ||
['transaction_id' => 'required|string'] | ||
); | ||
|
||
// validate provided data | ||
if ($validator->fails()) { | ||
throw new JsonException([ | ||
"error" => [ | ||
"message" => "Validation failed", | ||
"fields" => $validator->errors() | ||
] | ||
]); | ||
} | ||
|
||
// find transaction by provided transactionId | ||
$transactions = $this->findTransactionRepository->handler(new IFindTransactionDto([ | ||
"filter_id" => $dto->getTransactionId() | ||
])); | ||
|
||
// throws an error if was not possible to find transaction | ||
if (sizeof($transactions) === 0) { | ||
throw new JsonException([ | ||
"error" => [ | ||
"message" => "Transaction not founded" | ||
] | ||
]); | ||
} | ||
|
||
// store transaction on entity variable | ||
$transaction = new TransactionEntity($transactions[0]); | ||
|
||
// retrieve document url | ||
$url = $this->storageProvider->generateReadableUrl("deposits" . "/" . $transaction->getDocument()); | ||
|
||
// throw an error if was not possible to generate url | ||
if (!$url) { | ||
throw new JsonException([ | ||
"error" => [ | ||
"message" => "Was not possible top generate document url" | ||
] | ||
]); | ||
} | ||
|
||
// return generated url | ||
return $url; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
backend/app/Domain/Usecases/UserBalanceSummary/UserBalanceSummaryDto.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,35 @@ | ||
<?php | ||
|
||
namespace App\Domain\Usecases\UserBalanceSummary; | ||
|
||
|
||
class UserBalanceSummaryDto | ||
{ | ||
private $user_id; | ||
private $period_from; | ||
private $period_to; | ||
|
||
public function __construct(array $data) | ||
{ | ||
foreach ($data as $key => $value) { | ||
if (property_exists($this, $key)) { | ||
$this->$key = $value; | ||
} | ||
} | ||
} | ||
|
||
public function getUserId() | ||
{ | ||
return $this->user_id ?? null; | ||
} | ||
|
||
public function getPeriodFrom() | ||
{ | ||
return $this->period_from ?? null; | ||
} | ||
|
||
public function getPeriodTo() | ||
{ | ||
return $this->period_to ?? null; | ||
} | ||
} |
Oops, something went wrong.