|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Resend\Service; |
| 4 | + |
| 5 | +use Resend\ValueObjects\Transporter\Payload; |
| 6 | + |
| 7 | +class Broadcast extends Service |
| 8 | +{ |
| 9 | + /** |
| 10 | + * Retrieve a single broadcast. |
| 11 | + * |
| 12 | + * @see https://resend.com/docs/api-reference/broadcasts/get-broadcast |
| 13 | + */ |
| 14 | + public function get(string $id): \Resend\Broadcast |
| 15 | + { |
| 16 | + $payload = Payload::get('broadcasts', $id); |
| 17 | + |
| 18 | + $result = $this->transporter->request($payload); |
| 19 | + |
| 20 | + return $this->createResource('broadcasts', $result); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Create a new broadcast to send to your audience. |
| 25 | + * |
| 26 | + * @see https://resend.com/docs/api-reference/broadcasts/create-broadcast |
| 27 | + */ |
| 28 | + public function create(array $parameters): \Resend\Broadcast |
| 29 | + { |
| 30 | + $payload = Payload::create('broadcasts', $parameters); |
| 31 | + |
| 32 | + $result = $this->transporter->request($payload); |
| 33 | + |
| 34 | + return $this->createResource('broadcasts', $result); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * List all domains. |
| 39 | + * |
| 40 | + * @return \Resend\Collection<\Resend\Broadcast> |
| 41 | + * |
| 42 | + * @see https://resend.com/docs/api-reference/broadcasts/list-broadcasts |
| 43 | + */ |
| 44 | + public function list(): \Resend\Collection |
| 45 | + { |
| 46 | + $payload = Payload::list('broadcasts'); |
| 47 | + |
| 48 | + $result = $this->transporter->request($payload); |
| 49 | + |
| 50 | + return $this->createResource('broadcasts', $result); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Start sending broadcasts to your audience. |
| 55 | + * |
| 56 | + * @see https://resend.com/docs/api-reference/broadcasts/send-broadcast |
| 57 | + */ |
| 58 | + public function send(string $broadcastId, array $parameters): \Resend\Broadcast |
| 59 | + { |
| 60 | + $payload = Payload::create("broadcasts/{$broadcastId}/send", $parameters); |
| 61 | + |
| 62 | + $result = $this->transporter->request($payload); |
| 63 | + |
| 64 | + return $this->createResource('broadcasts', $result); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Remove an existing broadcast. |
| 69 | + * |
| 70 | + * @see https://resend.com/docs/api-reference/broadcasts/delete-broadcast |
| 71 | + */ |
| 72 | + public function remove(string $id): \Resend\Broadcast |
| 73 | + { |
| 74 | + $payload = Payload::delete('broadcasts', $id); |
| 75 | + |
| 76 | + $result = $this->transporter->request($payload); |
| 77 | + |
| 78 | + return $this->createResource('broadcasts', $result); |
| 79 | + } |
| 80 | +} |
0 commit comments