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 boolean qosOverwrite;
44 private Integer qosUsageQuota;
45 private String status;
47 public UniFiVoucher(final UniFiControllerCache cache) {
52 public String getId() {
56 public String getCode() {
60 public Instant getCreateTime() {
64 public Integer getDuration() {
68 public Integer getQuota() {
72 public Integer getUsed() {
76 public boolean isQosOverwrite() {
80 public Integer getQosUsageQuota() {
84 public String getStatus() {
88 public UniFiSite getSite() {
89 return cache.getSite(siteId);
93 public String toString() {
95 "UniFiVoucher{id: '%s', code: '%s', created: '%s', duration: '%s', quota: '%s', used: '%s', qosUsageQuota: '%s', status: '%s', site: %s}",
96 id, code, createTime, duration, quota, used, qosUsageQuota, status, getSite());