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.viber; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.vonage.client.JsonableBaseObject; 020 021public final class ViberService extends JsonableBaseObject { 022 private final Category category; 023 private final Integer ttl, duration, fileSize; 024 private final String type; 025 private final Action action; 026 027 private ViberService(Category category, Integer ttl, String type, Action action, Integer duration, Integer fileSize) { 028 this.category = category; 029 this.ttl = ttl; 030 this.type = type; 031 this.action = action; 032 this.duration = duration; 033 this.fileSize = fileSize; 034 } 035 036 static ViberService construct(Category category, Integer ttl, String type, Action action, Integer duration, Integer fileSize) { 037 if (category == null && ttl == null && type == null && action == null && duration == null && fileSize == null) { 038 return null; 039 } 040 if (ttl != null && (ttl < 30 || ttl > 259200)) { 041 throw new IllegalArgumentException("Time-to-live (ttl) must be between 30 and 259200 seconds"); 042 } 043 if (duration != null && (duration < 1 || duration > 600)) { 044 throw new IllegalArgumentException("Duration must be between 1 and 600 seconds."); 045 } 046 if (fileSize != null && (fileSize < 1 || fileSize > 200)) { 047 throw new IllegalArgumentException("File size must be between 1 and 200 MB."); 048 } 049 return new ViberService(category, ttl, type, action, duration, fileSize); 050 } 051 052 @JsonProperty("category") 053 public Category getCategory() { 054 return category; 055 } 056 057 @JsonProperty("ttl") 058 public Integer getTtl() { 059 return ttl; 060 } 061 062 @JsonProperty("type") 063 public String getType() { 064 return type; 065 } 066 067 @JsonProperty("action") 068 public Action getAction() { 069 return action; 070 } 071 072 @JsonProperty("duration") 073 public Integer getDuration() { 074 return duration; 075 } 076 077 @JsonProperty("file_size") 078 public Integer getFileSize() { 079 return fileSize; 080 } 081}