| 
									
										
										
										
											2020-11-29 18:35:49 +01:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2021-01-29 18:50:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * WebhookTransformer.php | 
					
						
							|  |  |  |  * Copyright (c) 2021 james@firefly-iii.org | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of Firefly III (https://github.com/firefly-iii). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU Affero General Public License as | 
					
						
							|  |  |  |  * published by the Free Software Foundation, either version 3 of the | 
					
						
							|  |  |  |  * License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-22 05:35:06 +01:00
										 |  |  | declare(strict_types=1); | 
					
						
							| 
									
										
										
										
											2020-11-29 18:35:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace FireflyIII\Transformers; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use FireflyIII\Models\Webhook; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Class WebhookTransformer | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class WebhookTransformer extends AbstractTransformer | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * WebhookTransformer constructor. | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2023-12-10 06:51:59 +01:00
										 |  |  |     public function __construct() {} | 
					
						
							| 
									
										
										
										
											2020-11-29 18:35:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Transform webhook. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function transform(Webhook $webhook): array | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return [ | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |             'id'         => $webhook->id, | 
					
						
							| 
									
										
										
										
											2020-11-29 18:35:49 +01:00
										 |  |  |             'created_at' => $webhook->created_at->toAtomString(), | 
					
						
							|  |  |  |             'updated_at' => $webhook->updated_at->toAtomString(), | 
					
						
							|  |  |  |             'active'     => $webhook->active, | 
					
						
							| 
									
										
										
										
											2020-12-03 06:54:42 +01:00
										 |  |  |             'title'      => $webhook->title, | 
					
						
							| 
									
										
										
										
											2021-01-15 21:01:53 +01:00
										 |  |  |             'secret'     => $webhook->secret, | 
					
						
							| 
									
										
										
										
											2025-08-22 07:04:13 +02:00
										 |  |  |             'triggers'   => $webhook->meta['triggers'], | 
					
						
							| 
									
										
										
										
											2025-08-19 19:35:12 +02:00
										 |  |  |             'deliveries' => $webhook->meta['deliveries'], | 
					
						
							| 
									
										
										
										
											2025-08-22 07:04:13 +02:00
										 |  |  |             'responses'  => $webhook->meta['responses'], | 
					
						
							| 
									
										
										
										
											2020-11-29 18:35:49 +01:00
										 |  |  |             'url'        => $webhook->url, | 
					
						
							|  |  |  |             'links'      => [ | 
					
						
							|  |  |  |                 [ | 
					
						
							|  |  |  |                     'rel' => 'self', | 
					
						
							|  |  |  |                     'uri' => sprintf('/webhooks/%d', $webhook->id), | 
					
						
							|  |  |  |                 ], | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-12-22 05:35:06 +01:00
										 |  |  | } |