]> git.basschouten.com Git - openhab-addons.git/blob
eefa6a53815b123e4c3e84b9667238c953ee5020
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.netatmo.internal.api.dto;
14
15 import java.time.ZonedDateTime;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.netatmo.internal.api.data.EventType;
20 import org.openhab.binding.netatmo.internal.deserialization.NAObjectMap;
21 import org.openhab.binding.netatmo.internal.deserialization.NAPushType;
22
23 /**
24  * The {@link WebhookEvent} is responsible to hold
25  * data given back by the Netatmo API when calling the webhook
26  *
27  * @author GaĆ«l L'hopital - Initial contribution
28  *
29  */
30 @NonNullByDefault
31 public class WebhookEvent extends Event {
32     private @NonNullByDefault({}) NAPushType pushType;
33     private String homeId = "";
34     private @Nullable String snapshotUrl;
35     private NAObjectMap<Person> persons = new NAObjectMap<>();
36     // Webhook does not provide the event generation time, so we'll use the event reception time
37     private ZonedDateTime time = ZonedDateTime.now();
38
39     public String getHomeId() {
40         return homeId;
41     }
42
43     public NAObjectMap<Person> getPersons() {
44         return persons;
45     }
46
47     @Override
48     public EventType getEventType() {
49         return pushType.getEvent();
50     }
51
52     @Override
53     public ZonedDateTime getTime() {
54         return time;
55     }
56
57     @Override
58     public @Nullable String getPersonId() {
59         return persons.size() > 0 ? persons.keySet().iterator().next() : null;
60     }
61
62     @Override
63     public @Nullable String getSnapshotUrl() {
64         return snapshotUrl;
65     }
66 }