Skip to content

Commit 8ddf7bc

Browse files
authored
Merge pull request #8 from jayanratna/add-created-at
Add `created_at` to Sent response class
2 parents 9b8f08e + daf892d commit 8ddf7bc

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/Responses/Email/Sent.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ final class Sent implements Response
1515
public function __construct(
1616
public readonly string $id,
1717
public readonly string $from,
18-
public readonly string $to
18+
public readonly string $to,
19+
public readonly string $createdAt
1920
) {
2021
//
2122
}
@@ -28,7 +29,8 @@ public static function from(array $attributes): self
2829
return new self(
2930
$attributes['id'],
3031
$attributes['from'],
31-
$attributes['to']
32+
$attributes['to'],
33+
$attributes['created_at']
3234
);
3335
}
3436

@@ -41,6 +43,7 @@ public function toArray(): array
4143
'id' => $this->id,
4244
'from' => $this->from,
4345
'to' => $this->to,
46+
'created_at' => $this->createdAt,
4447
];
4548
}
4649
}

tests/Fixtures/Email.php

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ function email(): array
66
'id' => '49a3999c-0ce1-4ea6-ab68-afcd6dc2e794',
77
'from' => '[email protected]',
88
'to' => '[email protected]',
9+
'created_at' => '2022-07-25T00:28:32.493138+00:00',
910
];
1011
}

tests/Responses/Email/Sent.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
test('as array accessible', function () {
1414
$email = Sent::from(email());
1515

16-
expect($email['id'])->toBe('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794');
16+
expect($email['id'])->toBe('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794')
17+
->and(isset($email['created_at']))->toBeTrue()
18+
->and($email['created_at'])->toBe('2022-07-25T00:28:32.493138+00:00');
1719
});
1820

1921
test('to array', function () {

0 commit comments

Comments
 (0)