2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.unifi.internal.api.dto;
15 import java.time.Instant;
17 import org.openhab.binding.unifi.internal.api.cache.UniFiControllerCache;
18 import org.openhab.binding.unifi.internal.api.util.UniFiTimestampDeserializer;
20 import com.google.gson.annotations.JsonAdapter;
21 import com.google.gson.annotations.SerializedName;
24 * The {@link UniFiVoucher} is the base data model for a guest network voucher
26 * @author Mark Herwege - Initial contribution
28 public class UniFiVoucher implements HasId {
30 private final transient UniFiControllerCache cache;
32 @SerializedName("_id")
35 private String siteId;
38 @JsonAdapter(UniFiTimestampDeserializer.class)
39 private Instant createTime;
40 private Integer duration;
41 private Integer quota;
43 private Integer qosUsageQuota;
44 private Integer qosRateMaxUp;
45 private Integer qosRateMaxDown;
46 private boolean qosOverwrite;
48 private String status;
50 public UniFiVoucher(final UniFiControllerCache cache) {
55 public String getId() {
59 public String getCode() {
63 public Instant getCreateTime() {
67 public Integer getDuration() {
71 public Integer getQuota() {
75 public Integer getUsed() {
79 public Integer getQosUsageQuota() {
83 public Integer getQosRateMaxUp() {
87 public Integer getQosRateMaxDown() {
88 return qosRateMaxDown;
91 public boolean isQosOverwrite() {
95 public String getNote() {
99 public String getStatus() {
103 public UniFiSite getSite() {
104 return cache.getSite(siteId);
108 public String toString() {
109 return String.format(
111 UniFiVoucher{id: '%s', code: '%s', created: '%s', duration: '%s', quota: '%s', used: '%s', qosUsageQuota: '%s', \
112 qosRateMaxUp: '%s', qosRateMaxDown: '%s', qosOverwrite: '%s', note: '%s', status: '%s', site: %s}\
114 id, code, createTime, duration, quota, used, qosUsageQuota, qosRateMaxUp, qosRateMaxDown, qosOverwrite,
115 note, status, getSite());