File tree Expand file tree Collapse file tree 4 files changed +11
-11
lines changed Expand file tree Collapse file tree 4 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -46,12 +46,12 @@ public function paginate(Request $request): Paginator
4646 {
4747 protected function isLastPage (Response $ response ): bool
4848 {
49- return is_null ( $ response ->json ( ' next_page_url ' ) );
49+ return $ response ->header ( ' X-Pagination-Page-Count ' ) === $ response -> header ( ' X-Pagination-Current-Page ' );
5050 }
5151
5252 protected function getPageItems (Response $ response , Request $ request ): array
5353 {
54- return $ response ->json (' items ' );
54+ return $ response ->json ();
5555 }
5656
5757 protected function applyPagination (Request $ request ): Request
Original file line number Diff line number Diff line change 33namespace Spatie \FloatSdk \Groups ;
44
55use Generator ;
6- use Saloon \Http \BaseResource ;
76use Saloon \Http \Response ;
8- use Spatie \FloatSdk \QueryParameters \GetProjectsParams ;
7+ use Saloon \Http \BaseResource ;
8+ use Saloon \PaginationPlugin \Paginator ;
99use Spatie \FloatSdk \Requests \GetProject ;
1010use Spatie \FloatSdk \Requests \GetProjects ;
11+ use Saloon \PaginationPlugin \Contracts \Paginatable ;
12+ use Spatie \FloatSdk \QueryParameters \GetProjectsParams ;
1113
1214class ProjectsGroup extends BaseResource
1315{
@@ -16,12 +18,8 @@ public function get(int $projectId): Response
1618 return $ this ->connector ->send (new GetProject ($ projectId ));
1719 }
1820
19- public function all (?GetProjectsParams $ parameters = null ): Generator
21+ public function all (?GetProjectsParams $ parameters = null ): Paginator
2022 {
21- $ paginator = $ this ->connector ->paginate (new GetProjects ($ parameters ));
22-
23- foreach ($ paginator ->paginate () as $ response ) {
24- yield $ response ;
25- }
23+ return $ this ->connector ->paginate (new GetProjects ($ parameters ));
2624 }
2725}
Original file line number Diff line number Diff line change 77use Saloon \Http \Response ;
88use Saloon \PaginationPlugin \Contracts \Paginatable ;
99use Spatie \FloatSdk \QueryParameters \GetAllocationsParams ;
10+ use Spatie \FloatSdk \Resources \AllocationResource ;
1011use Spatie \FloatSdk \Resources \ProjectTaskResource ;
1112
1213class GetAllocations extends Request implements Paginatable
@@ -31,7 +32,7 @@ public function resolveEndpoint(): string
3132 public function createDtoFromResponse (Response $ response ): array
3233 {
3334 return array_map (
34- fn (array $ object ) => ProjectTaskResource ::createFromResponse ($ object ),
35+ fn (array $ object ) => AllocationResource ::createFromResponse ($ object ),
3536 $ response ->json ()
3637 );
3738 }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public function __construct(
1313 /** @param array<string, mixed> $response */
1414 public static function createFromResponse (array $ response ): self
1515 {
16+ ray ('createFromResponse ' , $ response );
1617 return new self (
1718 id: $ response ['task_meta_id ' ],
1819 name: $ response ['task_name ' ],
You can’t perform that action at this time.
0 commit comments