]> git.basschouten.com Git - openhab-addons.git/blob
fe4f219f556fc21ec55cfecbe88cc10737d26f51
[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.vigicrues.internal.dto.vigicrues;
14
15 import static org.openhab.binding.vigicrues.internal.VigiCruesBindingConstants.*;
16
17 import java.util.HashMap;
18 import java.util.List;
19 import java.util.Locale;
20 import java.util.Map;
21
22 import com.google.gson.annotations.SerializedName;
23
24 /**
25  * The {@link CdStationHydro} is the Java class used to map the JSON
26  * response to a vigicrue api endpoint request.
27  *
28  * @author Gaël L'hopital - Initial contribution
29  */
30 public class CdStationHydro {
31
32     public class PereBoitEntVigiCru {
33         @SerializedName("CdEntVigiCru")
34         public String cdEntVigiCru;
35     }
36
37     public class CruesHistorique {
38         @SerializedName("LbUsuel")
39         private String name;
40         @SerializedName("ValHauteur")
41         private double height;
42         @SerializedName("ValDebit")
43         private double flow;
44
45         public Map<String, String> getDescription() {
46             Map<String, String> result = new HashMap<>();
47             if (height != 0) {
48                 result.put(String.format("%s %s (%s)", FLOOD, HEIGHT, name),
49                         String.format(Locale.US, "%.2f m", height));
50             }
51             if (flow != 0) {
52                 result.put(String.format("%s %s (%s)", FLOOD, FLOW, name), String.format(Locale.US, "%.2f m³/s", flow));
53             }
54             return result;
55         }
56     }
57
58     public class VigilanceCrues {
59         @SerializedName("PereBoitEntVigiCru")
60         public PereBoitEntVigiCru pereBoitEntVigiCru;
61         @SerializedName("CruesHistoriques")
62         public List<CruesHistorique> cruesHistoriques;
63         /*
64          * Currently unused, maybe interesting in the future
65          *
66          * @SerializedName("StationPrevision")
67          * public String stationPrevision;
68          *
69          * @SerializedName("Photo")
70          * public String photo;
71          *
72          * @SerializedName("ZoomInitial")
73          * public String zoomInitial;
74          */
75     }
76
77     @SerializedName("VigilanceCrues")
78     public VigilanceCrues vigilanceCrues;
79     /*
80      * Currently unused, maybe interesting in the future
81      *
82      * @SerializedName("VersionFlux")
83      * public String versionFlux;
84      *
85      * @SerializedName("CdStationHydro")
86      * public String cdStationHydro;
87      *
88      * @SerializedName("LbStationHydro")
89      * public String lbStationHydro;
90      *
91      * @SerializedName("LbCoursEau")
92      * public String lbCoursEau;
93      *
94      * @SerializedName("CdStationHydroAncienRef")
95      * public String cdStationHydroAncienRef;
96      *
97      * @SerializedName("CdCommune")
98      * public String cdCommune;
99      *
100      * @SerializedName("error_msg")
101      * public String errorMsg;
102      */
103 }