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.messages.whatsapp;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.messages.CaptionMediaMessageRequest;
020import com.vonage.client.messages.MediaMessageRequest;
021import com.vonage.client.messages.internal.MessagePayload;
022import com.vonage.client.messages.MessageType;
023
024public final class WhatsappFileRequest extends WhatsappRequest implements CaptionMediaMessageRequest {
025
026        WhatsappFileRequest(Builder builder) {
027                super(builder, MessageType.FILE);
028        }
029
030        @JsonProperty("file")
031        public MessagePayload getFile() {
032                return media;
033        }
034
035        public static Builder builder() {
036                return new Builder();
037        }
038
039        public static final class Builder extends WhatsappRequest.Builder<WhatsappFileRequest, Builder> implements CaptionMediaMessageRequest.Builder<Builder> {
040
041                Builder() {}
042
043                /**
044                 * (REQUIRED)
045                 * Sets the URL of the file attachment. Supports a wide range of attachments including
046                 * {@code .zip}, {@code .csv} and {@code .pdf.}.
047                 *
048                 * @param url The URL as a string.
049                 * @return This builder.
050                 */
051                @Override
052                public Builder url(String url) {
053                        return super.url(url);
054                }
055
056                /**
057                 * (OPTIONAL)
058                 * Additional text to accompany the file.
059                 *
060                 * @param caption The caption string.
061                 * @return This builder.
062                 */
063                @Override
064                public Builder caption(String caption) {
065                        return super.caption(caption);
066                }
067
068                /**
069                 * (OPTIONAL)
070                 * Specifies the name of the file being sent. If not included, the value for caption will be used as
071                 * the file name. If neither name nor caption are included, the file name will be parsed from the url.
072                 *
073                 * @param name The file name.
074                 * @return This builder.
075                 *
076                 * @since 8.1.0
077                 */
078                @Override
079                public Builder name(String name) {
080                        return super.name(name);
081                }
082
083                @Override
084                public WhatsappFileRequest build() {
085                        return new WhatsappFileRequest(this);
086                }
087        }
088}