Skip to content

Commit 419f70b

Browse files
authored
Merge pull request #4 from coderflexx/feat/dto-handling
Feat - DTO Handling.
2 parents 18c07fc + 26aad50 commit 419f70b

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

src/DTOs/CompaignDTO.php

+43-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,52 @@
33
namespace Coderflex\LaravelSendy\DTOs;
44

55
use Spatie\LaravelData\Data;
6+
use Spatie\LaravelData\Support\Validation\ValidationContext;
67

78
class CompaignDTO extends Data
89
{
910
public function __construct(
10-
//
11+
public string $from_name,
12+
public string $from_email,
13+
public string $reply_to,
14+
public string $title,
15+
public string $subject,
16+
public ?string $plain_text,
17+
public string $html_text,
18+
public string $list_ids,
19+
public string $segment_ids,
20+
public ?string $exclude_list_ids,
21+
public ?string $exclude_segment_ids,
22+
public string $brand_id,
23+
public ?string $query_string,
24+
public ?int $track_opens,
25+
public ?int $track_clicks,
26+
public ?int $send_compaign,
27+
public ?string $schedule_date_time,
28+
public ?string $schedule_timezone,
1129
) {}
30+
31+
public static function rules(ValidationContext $context): array
32+
{
33+
return [
34+
'from_name' => ['required', 'string'],
35+
'from_email' => ['required', 'email'],
36+
'reply_to' => ['required', 'email'],
37+
'title' => ['required', 'string'],
38+
'subject' => ['required', 'string'],
39+
'plain_text' => ['string', 'nullable'],
40+
'html_text' => ['required', 'string'],
41+
'list_ids' => ['required', 'string'],
42+
'segment_ids' => ['required', 'string'],
43+
'exclude_list_ids' => ['string', 'nullable'],
44+
'exclude_segment_ids' => ['string', 'nullable'],
45+
'brand_id' => ['required', 'string'],
46+
'query_string' => ['string', 'nullable'],
47+
'track_opens' => ['integer', 'nullable', 'in:0,1,2'],
48+
'track_clicks' => ['integer', 'nullable', 'in:0,1,2'],
49+
'send_compaign' => ['integer', 'nullable', 'in:0,1'],
50+
'schedule_date_time' => ['date', 'nullable'],
51+
'schedule_timezone' => ['date', 'nullable'],
52+
];
53+
}
1254
}

src/DTOs/SubscribersDTO.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,34 @@
33
namespace Coderflex\LaravelSendy\DTOs;
44

55
use Spatie\LaravelData\Data;
6+
use Spatie\LaravelData\Support\Validation\ValidationContext;
67

78
class SubscribersDTO extends Data
89
{
910
public function __construct(
10-
//
11+
public ?string $name,
12+
public string $email,
13+
public string $list,
14+
public string $country,
15+
public ?string $ipaddress,
16+
public ?string $referrer,
17+
public ?bool $gdpr,
18+
public ?bool $silent,
19+
public ?bool $boolean,
1120
) {}
21+
22+
public static function rules(ValidationContext $context): array
23+
{
24+
return [
25+
'name' => ['string', 'nullable'],
26+
'email' => ['required', 'string', 'email'],
27+
'list' => ['required', 'string'],
28+
'country' => ['string', 'nullable'],
29+
'ipaddress' => ['string', 'nullable', 'ip'],
30+
'referrer' => ['string', 'nullable'],
31+
'gdpr' => ['boolean', 'nullable'],
32+
'silent' => ['boolean', 'nullable'],
33+
'boolean' => ['boolean', 'nullable'],
34+
];
35+
}
1236
}

0 commit comments

Comments
 (0)