|
| 1 | +/* |
| 2 | + * This code was generated by |
| 3 | + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ |
| 4 | + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ |
| 5 | + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ |
| 6 | + * |
| 7 | + * Twilio API definition for public-api voice |
| 8 | + * Powers Twilio public-api voice |
| 9 | + * |
| 10 | + * NOTE: This class is auto generated by OpenAPI Generator. |
| 11 | + * https://openapi-generator.tech |
| 12 | + * Do not edit the class manually. |
| 13 | + */ |
| 14 | + |
| 15 | +package com.twilio.rest.voice.v2; |
| 16 | + |
| 17 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 18 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 19 | +import com.fasterxml.jackson.annotation.JsonInclude; |
| 20 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 21 | +import com.fasterxml.jackson.core.JsonParseException; |
| 22 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 23 | +import com.fasterxml.jackson.databind.JsonMappingException; |
| 24 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 25 | +import com.twilio.base.Resource; |
| 26 | +import com.twilio.exception.ApiConnectionException; |
| 27 | +import com.twilio.exception.ApiException; |
| 28 | +import com.twilio.http.HttpMethod; |
| 29 | +import java.io.IOException; |
| 30 | +import java.io.InputStream; |
| 31 | +import java.net.URI; |
| 32 | +import java.util.Objects; |
| 33 | +import lombok.Getter; |
| 34 | +import lombok.Setter; |
| 35 | +import lombok.ToString; |
| 36 | +import lombok.ToString; |
| 37 | + |
| 38 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 39 | +@ToString |
| 40 | +public class Client extends Resource { |
| 41 | + |
| 42 | + private static final long serialVersionUID = 20407420146524L; |
| 43 | + |
| 44 | + @ToString |
| 45 | + public static class VoiceV2ClientConfigurationResponseConfigurationCallnotification { |
| 46 | + |
| 47 | + @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| 48 | + @JsonProperty("url") |
| 49 | + @Getter |
| 50 | + @Setter |
| 51 | + private URI url; |
| 52 | + |
| 53 | + @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| 54 | + @JsonProperty("method") |
| 55 | + @Getter |
| 56 | + @Setter |
| 57 | + private HttpMethod method; |
| 58 | + |
| 59 | + public static VoiceV2ClientConfigurationResponseConfigurationCallnotification fromJson( |
| 60 | + String jsonString, |
| 61 | + ObjectMapper mapper |
| 62 | + ) throws IOException { |
| 63 | + return mapper.readValue( |
| 64 | + jsonString, |
| 65 | + VoiceV2ClientConfigurationResponseConfigurationCallnotification.class |
| 66 | + ); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + @ToString |
| 71 | + public static class VoiceV2ClientConfigurationResponseConfiguration { |
| 72 | + |
| 73 | + @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| 74 | + @JsonProperty("callnotification") |
| 75 | + @Getter |
| 76 | + @Setter |
| 77 | + private VoiceV2ClientConfigurationResponseConfigurationCallnotification callnotification; |
| 78 | + |
| 79 | + public static VoiceV2ClientConfigurationResponseConfiguration fromJson( |
| 80 | + String jsonString, |
| 81 | + ObjectMapper mapper |
| 82 | + ) throws IOException { |
| 83 | + return mapper.readValue( |
| 84 | + jsonString, |
| 85 | + VoiceV2ClientConfigurationResponseConfiguration.class |
| 86 | + ); |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + @ToString |
| 91 | + public static class VoiceV2ClientConfigurationRequest { |
| 92 | + |
| 93 | + @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| 94 | + @JsonProperty("friendly_name") |
| 95 | + @Getter |
| 96 | + @Setter |
| 97 | + private String friendlyName; |
| 98 | + |
| 99 | + @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| 100 | + @JsonProperty("description") |
| 101 | + @Getter |
| 102 | + @Setter |
| 103 | + private String description; |
| 104 | + |
| 105 | + @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| 106 | + @JsonProperty("configuration") |
| 107 | + @Getter |
| 108 | + @Setter |
| 109 | + private VoiceV2ClientConfigurationResponseConfiguration configuration; |
| 110 | + |
| 111 | + public VoiceV2ClientConfigurationRequest() {} |
| 112 | + |
| 113 | + public static VoiceV2ClientConfigurationRequest fromJson( |
| 114 | + String jsonString, |
| 115 | + ObjectMapper mapper |
| 116 | + ) throws IOException { |
| 117 | + return mapper.readValue( |
| 118 | + jsonString, |
| 119 | + VoiceV2ClientConfigurationRequest.class |
| 120 | + ); |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + public static ClientCreator creator() { |
| 125 | + return new ClientCreator(); |
| 126 | + } |
| 127 | + |
| 128 | + public static ClientDeleter deleter(final String pathIdOrFriendlyName) { |
| 129 | + return new ClientDeleter(pathIdOrFriendlyName); |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * Converts a JSON String into a Client object using the provided ObjectMapper. |
| 134 | + * |
| 135 | + * @param json Raw JSON String |
| 136 | + * @param objectMapper Jackson ObjectMapper |
| 137 | + * @return Client object represented by the provided JSON |
| 138 | + */ |
| 139 | + public static Client fromJson( |
| 140 | + final String json, |
| 141 | + final ObjectMapper objectMapper |
| 142 | + ) { |
| 143 | + // Convert all checked exceptions to Runtime |
| 144 | + try { |
| 145 | + return objectMapper.readValue(json, Client.class); |
| 146 | + } catch (final JsonMappingException | JsonParseException e) { |
| 147 | + throw new ApiException(e.getMessage(), e); |
| 148 | + } catch (final IOException e) { |
| 149 | + throw new ApiConnectionException(e.getMessage(), e); |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * Converts a JSON InputStream into a Client object using the provided |
| 155 | + * ObjectMapper. |
| 156 | + * |
| 157 | + * @param json Raw JSON InputStream |
| 158 | + * @param objectMapper Jackson ObjectMapper |
| 159 | + * @return Client object represented by the provided JSON |
| 160 | + */ |
| 161 | + public static Client fromJson( |
| 162 | + final InputStream json, |
| 163 | + final ObjectMapper objectMapper |
| 164 | + ) { |
| 165 | + // Convert all checked exceptions to Runtime |
| 166 | + try { |
| 167 | + return objectMapper.readValue(json, Client.class); |
| 168 | + } catch (final JsonMappingException | JsonParseException e) { |
| 169 | + throw new ApiException(e.getMessage(), e); |
| 170 | + } catch (final IOException e) { |
| 171 | + throw new ApiConnectionException(e.getMessage(), e); |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + public static String toJson(Object object, ObjectMapper mapper) { |
| 176 | + try { |
| 177 | + return mapper.writeValueAsString(object); |
| 178 | + } catch (final JsonMappingException e) { |
| 179 | + throw new ApiException(e.getMessage(), e); |
| 180 | + } catch (JsonProcessingException e) { |
| 181 | + throw new ApiException(e.getMessage(), e); |
| 182 | + } catch (final IOException e) { |
| 183 | + throw new ApiConnectionException(e.getMessage(), e); |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + private final String id; |
| 188 | + private final String accountSid; |
| 189 | + private final String friendlyName; |
| 190 | + private final String description; |
| 191 | + private final VoiceV2ClientConfigurationResponseConfiguration configuration; |
| 192 | + |
| 193 | + @JsonCreator |
| 194 | + private Client( |
| 195 | + @JsonProperty("id") final String id, |
| 196 | + @JsonProperty("account_sid") final String accountSid, |
| 197 | + @JsonProperty("friendly_name") final String friendlyName, |
| 198 | + @JsonProperty("description") final String description, |
| 199 | + @JsonProperty( |
| 200 | + "configuration" |
| 201 | + ) final VoiceV2ClientConfigurationResponseConfiguration configuration |
| 202 | + ) { |
| 203 | + this.id = id; |
| 204 | + this.accountSid = accountSid; |
| 205 | + this.friendlyName = friendlyName; |
| 206 | + this.description = description; |
| 207 | + this.configuration = configuration; |
| 208 | + } |
| 209 | + |
| 210 | + public final String getId() { |
| 211 | + return this.id; |
| 212 | + } |
| 213 | + |
| 214 | + public final String getAccountSid() { |
| 215 | + return this.accountSid; |
| 216 | + } |
| 217 | + |
| 218 | + public final String getFriendlyName() { |
| 219 | + return this.friendlyName; |
| 220 | + } |
| 221 | + |
| 222 | + public final String getDescription() { |
| 223 | + return this.description; |
| 224 | + } |
| 225 | + |
| 226 | + public final VoiceV2ClientConfigurationResponseConfiguration getConfiguration() { |
| 227 | + return this.configuration; |
| 228 | + } |
| 229 | + |
| 230 | + @Override |
| 231 | + public boolean equals(final Object o) { |
| 232 | + if (this == o) { |
| 233 | + return true; |
| 234 | + } |
| 235 | + |
| 236 | + if (o == null || getClass() != o.getClass()) { |
| 237 | + return false; |
| 238 | + } |
| 239 | + |
| 240 | + Client other = (Client) o; |
| 241 | + |
| 242 | + return ( |
| 243 | + Objects.equals(id, other.id) && |
| 244 | + Objects.equals(accountSid, other.accountSid) && |
| 245 | + Objects.equals(friendlyName, other.friendlyName) && |
| 246 | + Objects.equals(description, other.description) && |
| 247 | + Objects.equals(configuration, other.configuration) |
| 248 | + ); |
| 249 | + } |
| 250 | + |
| 251 | + @Override |
| 252 | + public int hashCode() { |
| 253 | + return Objects.hash( |
| 254 | + id, |
| 255 | + accountSid, |
| 256 | + friendlyName, |
| 257 | + description, |
| 258 | + configuration |
| 259 | + ); |
| 260 | + } |
| 261 | +} |
0 commit comments