-
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.
Add category create endpoint & move UpdateCustomerResponse
- Loading branch information
Showing
8 changed files
with
112 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace DREID\LaravelJtlApi\Helpers; | ||
|
||
use DREID\LaravelJtlApi\Exceptions\ConnectionException; | ||
use DREID\LaravelJtlApi\Exceptions\MissingApiKeyException; | ||
use DREID\LaravelJtlApi\Exceptions\MissingLicenseException; | ||
use DREID\LaravelJtlApi\Exceptions\MissingPermissionException; | ||
use DREID\LaravelJtlApi\Exceptions\UnauthorizedException; | ||
use DREID\LaravelJtlApi\Exceptions\UnhandledResponseException; | ||
use DREID\LaravelJtlApi\Modules\Category\CategoryRepository; | ||
use DREID\LaravelJtlApi\Modules\Category\Requests\QueryCategoriesRequest; | ||
|
||
class CategoryHelper | ||
{ | ||
/** | ||
* @throws UnhandledResponseException | ||
* @throws UnauthorizedException | ||
* @throws ConnectionException | ||
* @throws MissingLicenseException | ||
* @throws MissingApiKeyException | ||
* @throws MissingPermissionException | ||
*/ | ||
public function loadAllCategories(): array | ||
{ | ||
$categories = []; | ||
$repository = app(CategoryRepository::class); | ||
|
||
$page = 1; | ||
$hasMore = true; | ||
|
||
while ($hasMore) { | ||
$response = $repository->queryCategories(new QueryCategoriesRequest(pageNumber: $page)); | ||
array_push($categories, ...$response->items); | ||
|
||
$hasMore = $response->hasNextPage; | ||
$page++; | ||
} | ||
|
||
return $categories; | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
|
||
namespace DREID\LaravelJtlApi\Modules\Category\Requests; | ||
|
||
readonly class CreateCategoryRequest | ||
{ | ||
public function __construct( | ||
public string $name, | ||
public ?string $description = null, | ||
public ?int $parentCategoryId = null, | ||
public ?int $sortNumber = null, | ||
public ?string $activeSalesChannels = null, | ||
) {} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace DREID\LaravelJtlApi\Modules\Category\Responses; | ||
|
||
use DREID\LaravelJtlApi\ApiResponse; | ||
use DREID\LaravelJtlApi\Modules\Category\DataTransferObjects\CategoryDto; | ||
|
||
readonly class CreateCategoryResponse | ||
{ | ||
public CategoryDto $category; | ||
|
||
public function __construct(public ApiResponse $response) | ||
{ | ||
$this->category = CategoryDto::fromResponse($this->response->json); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...dules/Customer/UpdateCustomerResponse.php → ...omer/Responses/UpdateCustomerResponse.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