Skip to content

Commit 6a09564

Browse files
committed
initial form and popups requests
1 parent 98a3c5e commit 6a09564

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ziming\LaravelGetResponse\Requests\FormsAndPopups;
6+
7+
use Saloon\Enums\Method;
8+
use Saloon\Http\Request;
9+
10+
class GetAllPopupsRequest extends Request
11+
{
12+
protected Method $method = Method::GET;
13+
14+
public function __construct(
15+
protected readonly array $queryParameters = [],
16+
protected readonly array $statsParameters = [],
17+
protected readonly array $sortParameters = [],
18+
protected readonly array $fields = [],
19+
protected readonly int $page = 1,
20+
protected readonly int $perPage = 100,
21+
protected readonly bool $withStatistics = false,
22+
) {
23+
}
24+
25+
protected function defaultQuery(): array
26+
{
27+
return array_filter([
28+
'query' => $this->queryParameters,
29+
'stats' => $this->statsParameters,
30+
'sort' => $this->sortParameters,
31+
'fields' => implode(',', $this->fields),
32+
'page' => $this->page,
33+
'perPage' => $this->perPage,
34+
]);
35+
}
36+
37+
public function resolveEndpoint(): string
38+
{
39+
return '/popups';
40+
}
41+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ziming\LaravelGetResponse\Requests\FormsAndPopups;
6+
7+
use Saloon\Enums\Method;
8+
use Saloon\Http\Request;
9+
10+
class GetPopupByIdRequest extends Request
11+
{
12+
protected Method $method = Method::GET;
13+
14+
public function __construct(
15+
protected readonly string $popupId,
16+
protected readonly array $fields = [],
17+
) {
18+
}
19+
20+
protected function defaultQuery(): array
21+
{
22+
return array_filter([
23+
'fields' => implode(',', $this->fields),
24+
]);
25+
}
26+
27+
public function resolveEndpoint(): string
28+
{
29+
return '/popups/' . $this->popupId;
30+
}
31+
}

0 commit comments

Comments
 (0)