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.MessageType; 020 021/** 022 * See <a href=https://developer.vonage.com/en/messages/concepts/whatsapp-stickers>the documentation</a> 023 * for more information on sending stickers. 024 * 025 * @since 7.2.0 026 */ 027public final class WhatsappStickerRequest extends WhatsappRequest { 028 final Sticker sticker; 029 030 WhatsappStickerRequest(Builder builder) { 031 super(builder, MessageType.STICKER); 032 sticker = new Sticker(builder.url, builder.id); 033 } 034 035 @JsonProperty("sticker") 036 public Sticker getSticker() { 037 return sticker; 038 } 039 040 public static Builder builder() { 041 return new Builder(); 042 } 043 044 public static final class Builder extends WhatsappRequest.Builder<WhatsappStickerRequest, Builder> { 045 String url, id; 046 047 Builder() {} 048 049 /** 050 * (REQUIRED if {@link #id(String)} is not specified) 051 * The publicly accessible URL of the sticker image. Must be in {@code .webp} format. 052 * You must specify only the ID or the URL, but not both. 053 * 054 * @param url The sticker URL as a string. 055 * @return This builder. 056 */ 057 public Builder url(String url) { 058 this.url = url; 059 return this; 060 } 061 062 /** 063 * (REQUIRED if {@link #url(String)} is not specified) 064 * The ID of the sticker in relation to a specific WhatsApp deployment. 065 * You must specify only the ID or the URL, but not both. 066 * 067 * @param id The sticker's unique identifier as a string. 068 * @return This builder. 069 */ 070 public Builder id(String id) { 071 this.id = id; 072 return this; 073 } 074 075 @Override 076 public WhatsappStickerRequest build() { 077 return new WhatsappStickerRequest(this); 078 } 079 } 080}