1 | <?php |
||
10 | class NotificationPreferences extends MoipResource |
||
11 | { |
||
12 | /** |
||
13 | * Path accounts API. |
||
14 | * |
||
15 | * @const string |
||
16 | */ |
||
17 | const PATH = 'preferences'; |
||
18 | |||
19 | /** |
||
20 | * Notification media. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | const NOTIFICATION_MEDIA = 'WEBHOOK'; |
||
25 | |||
26 | /** |
||
27 | * Initialize a new instance. |
||
28 | */ |
||
29 | public function initialize() |
||
30 | { |
||
31 | $this->data = new stdClass(); |
||
32 | $this->data->events = []; |
||
33 | $this->data->media = self::NOTIFICATION_MEDIA; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Add a new address to the account. |
||
38 | * |
||
39 | * @param string $event Webhook. |
||
40 | * |
||
41 | * @return $this |
||
42 | */ |
||
43 | public function addEvent($event) |
||
44 | { |
||
45 | $this->data->events[] = $event; |
||
46 | |||
47 | return $this; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Set target to notification. |
||
52 | * |
||
53 | * @param string $target Notification URL. |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | public function setTarget($target) |
||
58 | { |
||
59 | $this->data->target = $target; |
||
60 | |||
61 | return $this; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Returns target. |
||
66 | * |
||
67 | * @return stdClass |
||
68 | */ |
||
69 | public function getTarget() |
||
70 | { |
||
71 | return $this->data->target; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Returns notification id. |
||
76 | * |
||
77 | * @return stdClass |
||
78 | */ |
||
79 | public function getId() |
||
80 | { |
||
81 | return $this->data->id; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Create a new notification preference. |
||
86 | * |
||
87 | * @return \stdClass |
||
88 | */ |
||
89 | public function create() |
||
90 | { |
||
91 | return $this->createResource($this->generatePath('notifications')); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Get a notification preference. |
||
96 | * |
||
97 | * @param string $notification_id Moip notification id. |
||
98 | * |
||
99 | * @return stdClass |
||
100 | */ |
||
101 | public function get($notification_id) |
||
105 | |||
106 | /** |
||
107 | * Delete. |
||
108 | * |
||
109 | * @param $notification_id |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | public function delete($notification_id) |
||
117 | |||
118 | /** |
||
119 | * Mount the notification preference structure. |
||
120 | * |
||
121 | * @param \stdClass $response |
||
122 | * |
||
123 | * @return \Moip\Resource\NotificationPreferences data |
||
124 | */ |
||
125 | protected function populate(stdClass $response) |
||
136 | } |
||
137 |