|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Resend\Service; |
| 4 | + |
| 5 | +use Resend\ValueObjects\Transporter\Payload; |
| 6 | + |
| 7 | +class Audience extends Service |
| 8 | +{ |
| 9 | + /** |
| 10 | + * Retrieve a single audience by the given ID. |
| 11 | + * |
| 12 | + * @see https://resend.com/docs/api-reference/audiences/get-audience |
| 13 | + */ |
| 14 | + public function get(string $id): \Resend\Audience |
| 15 | + { |
| 16 | + $payload = Payload::get('audiences', $id); |
| 17 | + |
| 18 | + $result = $this->transporter->request($payload); |
| 19 | + |
| 20 | + return $this->createResource('audiences', $result); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Add a new audience. |
| 25 | + * |
| 26 | + * @see https://resend.com/docs/api-reference/audiences/create-audience |
| 27 | + */ |
| 28 | + public function create(array $parameters): \Resend\Audience |
| 29 | + { |
| 30 | + $payload = Payload::create('audiences', $parameters); |
| 31 | + |
| 32 | + $result = $this->transporter->request($payload); |
| 33 | + |
| 34 | + return $this->createResource('audiences', $result); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * List all audiences. |
| 39 | + * |
| 40 | + * @return \Resend\Collection<\Resend\Audience> |
| 41 | + * |
| 42 | + * @see https://resend.com/docs/api-reference/audiences/list-audiences |
| 43 | + */ |
| 44 | + public function list(): \Resend\Collection |
| 45 | + { |
| 46 | + $payload = Payload::list('audiences'); |
| 47 | + |
| 48 | + $result = $this->transporter->request($payload); |
| 49 | + |
| 50 | + return $this->createResource('audiences', $result); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Remove a audience with the given ID. |
| 55 | + * |
| 56 | + * @see https://resend.com/docs/api-reference/audiences/delete-audience |
| 57 | + */ |
| 58 | + public function remove(string $id): \Resend\Audience |
| 59 | + { |
| 60 | + $payload = Payload::delete('audiences', $id); |
| 61 | + |
| 62 | + $result = $this->transporter->request($payload); |
| 63 | + |
| 64 | + return $this->createResource('audiences', $result); |
| 65 | + } |
| 66 | +} |
0 commit comments