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.conversations;
017
018import com.fasterxml.jackson.annotation.JsonIgnore;
019import com.fasterxml.jackson.annotation.JsonProperty;
020import com.vonage.client.JsonableBaseObject;
021import java.util.UUID;
022
023/**
024 * Represents an {@link EventType#AUDIO_RECORD_STOP} event.
025 */
026public final class AudioRecordStopEvent extends EventWithBody<AudioRecordStopEvent.Body> {
027
028    private AudioRecordStopEvent() {}
029
030    private AudioRecordStopEvent(Builder builder) {
031        super(builder);
032        (body = new Body()).recordId = builder.recordId;
033    }
034
035    static class Body extends JsonableBaseObject {
036        @JsonProperty("record_id") private UUID recordId;
037    }
038
039    /**
040     * Unique recording identifier.
041     *
042     * @return The recording ID, or {@code null} if unknown.
043     */
044    @JsonIgnore
045    public UUID getRecordId() {
046        return body != null ? body.recordId : null;
047    }
048
049    /**
050     * Entry point for constructing an instance of this class.
051     *
052     * @return A new Builder.
053     */
054    public static Builder builder() {
055        return new Builder();
056    }
057
058    public static final class Builder extends EventWithBody.Builder<AudioRecordStopEvent, Builder> {
059        private UUID recordId;
060
061        Builder() {
062            super(EventType.AUDIO_RECORD_STOP);
063        }
064
065        /**
066         * Unique recording identifier.
067         *
068         * @param recordId The recording ID as a string.
069         *
070         * @return This builder.
071         */
072        public Builder recordId(String recordId) {
073            return recordId(UUID.fromString(recordId));
074        }
075
076        /**
077         * Unique recording identifier.
078         *
079         * @param recordId The recording ID.
080         *
081         * @return This builder.
082         */
083        public Builder recordId(UUID recordId) {
084            this.recordId = recordId;
085            return this;
086        }
087
088        @Override
089        public AudioRecordStopEvent build() {
090            return new AudioRecordStopEvent(this);
091        }
092    }
093}