001/* 002 * Copyright 2024 Vonage 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.vonage.client.proactiveconnect; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.vonage.client.Jsonable; 020import com.vonage.client.JsonableBaseObject; 021import java.time.Instant; 022import java.util.Map; 023import java.util.UUID; 024 025/** 026 * Represents an event in the Proactive Connect API. 027 */ 028public class Event extends JsonableBaseObject { 029 private UUID id, actionId, invocationId, runItemId, runId, jobId; 030 private String recipientId, sourceContext; 031 private EventType type; 032 private Instant occurredAt; 033 private Map<String, ?> data; 034 035 protected Event() { 036 } 037 038 /** 039 * Custom data as key-value pairs for this event. 040 * 041 * @return The event data as a Map, or {@code null} if absent. 042 */ 043 @JsonProperty("data") 044 public Map<String, ?> getData() { 045 return data; 046 } 047 048 /** 049 * Unique identifier for this item. 050 * 051 * @return The item ID or {@code null} if unknown. 052 */ 053 @JsonProperty("id") 054 public UUID getId() { 055 return id; 056 } 057 058 /** 059 * Unique identifier for the job. 060 * 061 * @return The job ID or {@code null} if unknown. 062 */ 063 @JsonProperty("job_id") 064 public UUID getJobId() { 065 return jobId; 066 } 067 068 /** 069 * Unique identifier for the run. 070 * 071 * @return The run ID or {@code null} if unknown. 072 */ 073 @JsonProperty("run_id") 074 public UUID getRunId() { 075 return runId; 076 } 077 078 /** 079 * Identifier for the item ID during a job run - this is the list item ID which is copied 080 * while taking the list snapshot. 081 * 082 * @return The run's item ID or {@code null} if unknown. 083 */ 084 @JsonProperty("run_item_id") 085 public UUID getRunItemId() { 086 return runItemId; 087 } 088 089 /** 090 * Unique identifier for the action. 091 * 092 * @return The action ID or {@code null} if unknown. 093 */ 094 @JsonProperty("action_id") 095 public UUID getActionId() { 096 return actionId; 097 } 098 099 /** 100 * Unique identifier for the action invocation. 101 * 102 * @return The action invocation ID or {@code null} if unknown. 103 */ 104 @JsonProperty("invocation_id") 105 public UUID getInvocationId() { 106 return invocationId; 107 } 108 109 /** 110 * String identifier of a recipient, for example their email, phone number etc. 111 * 112 * @return The recipient ID or {@code null} if unknown. 113 */ 114 @JsonProperty("recipient_id") 115 public String getRecipientId() { 116 return recipientId; 117 } 118 119 /** 120 * The name of the segment or matcher. 121 * 122 * @return The source context or {@code null} if unknown. 123 */ 124 @JsonProperty("src_ctx") 125 public String getSourceContext() { 126 return sourceContext; 127 } 128 129 /** 130 * Date and time the event occurred in ISO 8601 format. 131 * 132 * @return The event timestamp or {@code null} if unknown. 133 */ 134 @JsonProperty("occurred_at") 135 public Instant getOccurredAt() { 136 return occurredAt; 137 } 138 139 /** 140 * Classification of the event. 141 * 142 * @return The event type as an enum. 143 */ 144 @JsonProperty("type") 145 public EventType getType() { 146 return type; 147 } 148 149 /** 150 * Creates an instance of this class from a JSON payload. 151 * 152 * @param json The JSON string to parse. 153 * @return An instance of this class with the fields populated, if present. 154 */ 155 public static Event fromJson(String json) { 156 return Jsonable.fromJson(json); 157 } 158}