]> git.basschouten.com Git - openhab-addons.git/blob
5bd5fa6c4172a834b4d7272fa0b1551ed674ed46
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.freebox.internal.api.model;
14
15 import java.util.Calendar;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * The {@link FreeboxCallEntry} is the Java class used to map the "CallEntry"
21  * structure used by the call API
22  * https://dev.freebox.fr/sdk/os/call/#
23  *
24  * @author Laurent Garnier - Initial contribution
25  */
26 public class FreeboxCallEntry {
27     private static final String CALL_ENTRY_TYPE_ACCEPTED = "accepted";
28     private static final String CALL_ENTRY_TYPE_MISSED = "missed";
29     private static final String CALL_ENTRY_TYPE_OUTGOING = "outgoing";
30
31     private int id;
32     private String type;
33     private long datetime;
34     private String number;
35     private String name;
36     private int duration;
37     @SerializedName("new")
38     private boolean newCall;
39     private int contactId;
40
41     public Calendar getTimeStamp() {
42         Calendar c = Calendar.getInstance();
43         c.setTimeInMillis(datetime * 1000);
44         return c;
45     }
46
47     public boolean isAccepted() {
48         return CALL_ENTRY_TYPE_ACCEPTED.equalsIgnoreCase(type);
49     }
50
51     public boolean isMissed() {
52         return CALL_ENTRY_TYPE_MISSED.equalsIgnoreCase(type);
53     }
54
55     public boolean isOutGoing() {
56         return CALL_ENTRY_TYPE_OUTGOING.equalsIgnoreCase(type);
57     }
58
59     public int getId() {
60         return id;
61     }
62
63     public String getType() {
64         return type;
65     }
66
67     public long getDatetime() {
68         return datetime;
69     }
70
71     public String getNumber() {
72         return number;
73     }
74
75     public String getName() {
76         return name;
77     }
78
79     public int getDuration() {
80         return duration;
81     }
82
83     public boolean isNewCall() {
84         return newCall;
85     }
86
87     public int getContactId() {
88         return contactId;
89     }
90 }