2 * Copyright (c) 2010-2021 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.amazonechocontrol.internal.jsons;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
18 import com.google.gson.Gson;
19 import com.google.gson.JsonSyntaxException;
22 * The {@link JsonActivities} encapsulate the GSON data of the push command for push activity
24 * @author Michael Geramb - Initial contribution
27 public class JsonActivities {
29 public @Nullable Activity @Nullable [] activities;
31 public static class Activity {
32 public @Nullable String activityStatus;
33 public @Nullable Long creationTimestamp;
34 public @Nullable String description;
35 public @Nullable Object domainAttributes;
36 public @Nullable Object domainType;
37 public @Nullable Object feedbackAttributes;
38 public @Nullable String id;
39 public @Nullable String intentType;
40 public @Nullable String providerInfoDescription;
41 public @Nullable String registeredCustomerId;
42 public @Nullable Object sourceActiveUsers;
43 public @Nullable SourceDeviceId @Nullable [] sourceDeviceIds;
44 public @Nullable String utteranceId;
45 public @Nullable Long version;
47 public static class SourceDeviceId {
48 public @Nullable String deviceAccountId;
49 public @Nullable String deviceType;
50 public @Nullable String serialNumber;
53 public static class Description {
55 public @Nullable String summary;
56 public @Nullable String firstUtteranceId;
57 public @Nullable String firstStreamId;
60 public Description parseDescription() {
61 String description = this.description;
62 if (description == null || description.isEmpty() || !description.startsWith("{")
63 || !description.endsWith("}")) {
64 return new Description();
66 Gson gson = new Gson();
68 Description description1 = gson.fromJson(description, Description.class);
69 return description1 != null ? description1 : new Description();
70 } catch (JsonSyntaxException e) {
71 return new Description();