-
Notifications
You must be signed in to change notification settings - Fork 1
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 #62 from deanblackborough/main
v1.07.0
- Loading branch information
Showing
119 changed files
with
3,758 additions
and
665 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
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class ChangePassword extends Action | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class DeleteAccount | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class DeleteBudgetAccount | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Reset | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class UpdateProfile extends Action | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
abstract class Action | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Create extends Action | ||
|
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,81 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Budget\Account; | ||
|
||
use App\Actions\Action; | ||
use App\Api\Service; | ||
use Illuminate\Support\Facades\Validator; | ||
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class SetBalances extends Action | ||
{ | ||
public function __invoke( | ||
Service $api, | ||
string $resource_type_id, | ||
string $resource_id, | ||
array $input | ||
): int | ||
{ | ||
$resource = $api->getResource($resource_type_id, $resource_id); | ||
if ($resource['status'] !== 200) { | ||
$this->message = 'Unable to fetch the resource for your Budget, please try again'; | ||
return $resource['status']; | ||
} | ||
|
||
$rules = []; | ||
$messages = []; | ||
|
||
$data = $resource['content']['data'] ?? []; | ||
foreach ($data['accounts'] as $id => $account) { | ||
$rules[$id] = [ | ||
'required', | ||
'string', | ||
'regex:/^\d+\.\d{2}$/', | ||
'max:16' | ||
]; | ||
$messages[$id . '.required'] = 'Please enter the balance for the account'; | ||
$messages[$id . '.regex'] = 'The value should be in the format 0.00'; | ||
$messages[$id . '.max'] = 'The balance value is too big'; | ||
} | ||
|
||
Validator::make( | ||
$input, | ||
$rules, | ||
$messages | ||
)->validate(); | ||
|
||
foreach ($data['accounts'] as $id => $account) { | ||
$data['accounts'][$id]['balance'] = $input[$id]; | ||
} | ||
|
||
try { | ||
$data = json_encode($data, JSON_THROW_ON_ERROR); | ||
} catch (\JsonException $e) { | ||
abort(500, $e->getMessage()); | ||
} | ||
|
||
$patch_resource_response = $api->patchResource( | ||
$resource_type_id, | ||
$resource_id, | ||
['data' => $data] | ||
); | ||
|
||
if ($patch_resource_response['status'] === 204) { | ||
return $patch_resource_response['status']; | ||
} | ||
|
||
$this->message = $patch_resource_response['content']; | ||
|
||
if ($patch_resource_response['status'] === 422) { | ||
$this->validation_errors = $patch_resource_response['fields']; | ||
return $patch_resource_response['status']; | ||
} | ||
|
||
return $patch_resource_response['status']; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Update extends Action | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class AdoptDemo extends Action | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Demo extends Action | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Adjust extends Action | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Create extends Action | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Delete extends Action | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Disable extends Action | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Enable extends Action | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Reset extends Action | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Restore extends Action | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class SetAsNotPaid extends Action | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class SetAsPaid extends Action | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Update extends Action | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Start extends Action | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Helper | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Http | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Response | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2023 | ||
* @license https://github.com/costs-to-expect/budget/blob/main/LICENSE | ||
*/ | ||
class Service | ||
|
@@ -43,6 +43,19 @@ public function authSignIn(string $email, string $password): array | |
); | ||
} | ||
|
||
#[ArrayShape(['status' => "integer", 'content' => "array", 'fields' => "array"])] | ||
public function forgotPassword(array $payload): array | ||
{ | ||
$uri = Uri::forgotPassword(); | ||
|
||
return $this->http->post( | ||
$uri['uri'], | ||
[ | ||
'email' => $payload['email'] | ||
] | ||
); | ||
} | ||
|
||
#[ArrayShape(['status' => "integer", 'content' => "array"])] | ||
public function getAuthUser(): array | ||
{ | ||
|
@@ -152,6 +165,20 @@ public function createPassword(array $payload): array | |
); | ||
} | ||
|
||
#[ArrayShape(['status' => "integer", 'content' => "array", 'fields' => "array"])] | ||
public function createNewPassword(array $payload): array | ||
{ | ||
$uri = Uri::createNewPassword($payload['token'], $payload['email']); | ||
|
||
return $this->http->post( | ||
$uri['uri'], | ||
[ | ||
'password' => $payload['password'], | ||
'password_confirmation' => $payload['password_confirmation'] | ||
] | ||
); | ||
} | ||
|
||
#[ArrayShape(['status' => "integer", 'content' => "array"])] | ||
public function createResource(string $resource_type_id): array | ||
{ | ||
|
Oops, something went wrong.