|
| 1 | +/* |
| 2 | + * This code was generated by |
| 3 | + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ |
| 4 | + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ |
| 5 | + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ |
| 6 | + * |
| 7 | + * Organization Public API |
| 8 | + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) |
| 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.previewiam.organizations; |
| 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.noauth.Resource; |
| 26 | +import com.twilio.converter.Converter; |
| 27 | +import java.util.Currency; |
| 28 | +import com.twilio.converter.DateConverter; |
| 29 | +import com.twilio.converter.Promoter; |
| 30 | +import com.twilio.converter.PrefixedCollapsibleMap; |
| 31 | +import com.twilio.converter.CurrencyDeserializer; |
| 32 | +import com.twilio.exception.ApiConnectionException; |
| 33 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 34 | + |
| 35 | +import com.twilio.exception.ApiException; |
| 36 | +import com.twilio.exception.RestException; |
| 37 | +import com.twilio.http.HttpMethod; |
| 38 | +import com.twilio.http.Request; |
| 39 | +import com.twilio.http.Response; |
| 40 | +import com.twilio.http.TwilioRestClient; |
| 41 | +import com.twilio.rest.Domains; |
| 42 | + |
| 43 | +import lombok.ToString; |
| 44 | + |
| 45 | +import java.io.IOException; |
| 46 | +import java.io.InputStream; |
| 47 | +import java.net.URI; |
| 48 | +import java.time.ZonedDateTime; |
| 49 | + |
| 50 | +import java.util.ArrayList; |
| 51 | +import java.util.HashMap; |
| 52 | +import java.util.List; |
| 53 | +import java.util.Map; |
| 54 | +import java.util.Objects; |
| 55 | + |
| 56 | +import lombok.Getter; |
| 57 | +import lombok.Setter; |
| 58 | +import lombok.ToString; |
| 59 | + |
| 60 | +import java.util.Map; |
| 61 | +import java.time.LocalDate; |
| 62 | +import java.math.BigDecimal; |
| 63 | +import com.twilio.type.PhoneNumberCapabilities; |
| 64 | +import com.twilio.type.FeedbackIssue; |
| 65 | +import com.twilio.type.IceServer; |
| 66 | +import com.twilio.type.InboundCallPrice; |
| 67 | +import com.twilio.type.OutboundPrefixPriceWithOrigin; |
| 68 | +import com.twilio.type.OutboundPrefixPrice; |
| 69 | +import com.twilio.type.OutboundCallPriceWithOrigin; |
| 70 | +import com.twilio.type.PhoneNumberPrice; |
| 71 | +import com.twilio.type.InboundSmsPrice; |
| 72 | +import com.twilio.type.OutboundSmsPrice; |
| 73 | +import com.twilio.type.OutboundCallPrice; |
| 74 | +import com.twilio.type.RecordingRule; |
| 75 | +import com.twilio.type.SubscribeRule; |
| 76 | + |
| 77 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 78 | +@ToString |
| 79 | +public class Token extends Resource { |
| 80 | + private static final long serialVersionUID = 258139119277894L; |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + public static TokenCreator creator(final String grantType, final String clientId){ |
| 85 | + return new TokenCreator(grantType, clientId); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Converts a JSON String into a Token object using the provided ObjectMapper. |
| 90 | + * |
| 91 | + * @param json Raw JSON String |
| 92 | + * @param objectMapper Jackson ObjectMapper |
| 93 | + * @return Token object represented by the provided JSON |
| 94 | + */ |
| 95 | + public static Token fromJson(final String json, final ObjectMapper objectMapper) { |
| 96 | + // Convert all checked exceptions to Runtime |
| 97 | + try { |
| 98 | + return objectMapper.readValue(json, Token.class); |
| 99 | + } catch (final JsonMappingException | JsonParseException e) { |
| 100 | + throw new ApiException(e.getMessage(), e); |
| 101 | + } catch (final IOException e) { |
| 102 | + throw new ApiConnectionException(e.getMessage(), e); |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Converts a JSON InputStream into a Token object using the provided |
| 108 | + * ObjectMapper. |
| 109 | + * |
| 110 | + * @param json Raw JSON InputStream |
| 111 | + * @param objectMapper Jackson ObjectMapper |
| 112 | + * @return Token object represented by the provided JSON |
| 113 | + */ |
| 114 | + public static Token fromJson(final InputStream json, final ObjectMapper objectMapper) { |
| 115 | + // Convert all checked exceptions to Runtime |
| 116 | + try { |
| 117 | + return objectMapper.readValue(json, Token.class); |
| 118 | + } catch (final JsonMappingException | JsonParseException e) { |
| 119 | + throw new ApiException(e.getMessage(), e); |
| 120 | + } catch (final IOException e) { |
| 121 | + throw new ApiConnectionException(e.getMessage(), e); |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + private final String accessToken; |
| 126 | + private final String refreshToken; |
| 127 | + private final String idToken; |
| 128 | + private final String tokenType; |
| 129 | + private final Long expiresIn; |
| 130 | + |
| 131 | + @JsonCreator |
| 132 | + private Token( |
| 133 | + @JsonProperty("access_token") |
| 134 | + final String accessToken, |
| 135 | + |
| 136 | + @JsonProperty("refresh_token") |
| 137 | + final String refreshToken, |
| 138 | + |
| 139 | + @JsonProperty("id_token") |
| 140 | + final String idToken, |
| 141 | + |
| 142 | + @JsonProperty("token_type") |
| 143 | + final String tokenType, |
| 144 | + |
| 145 | + @JsonProperty("expires_in") |
| 146 | + final Long expiresIn |
| 147 | + ) { |
| 148 | + this.accessToken = accessToken; |
| 149 | + this.refreshToken = refreshToken; |
| 150 | + this.idToken = idToken; |
| 151 | + this.tokenType = tokenType; |
| 152 | + this.expiresIn = expiresIn; |
| 153 | + } |
| 154 | + |
| 155 | + public final String getAccessToken() { |
| 156 | + return this.accessToken; |
| 157 | + } |
| 158 | + public final String getRefreshToken() { |
| 159 | + return this.refreshToken; |
| 160 | + } |
| 161 | + public final String getIdToken() { |
| 162 | + return this.idToken; |
| 163 | + } |
| 164 | + public final String getTokenType() { |
| 165 | + return this.tokenType; |
| 166 | + } |
| 167 | + public final Long getExpiresIn() { |
| 168 | + return this.expiresIn; |
| 169 | + } |
| 170 | + |
| 171 | + @Override |
| 172 | + public boolean equals(final Object o) { |
| 173 | + if (this==o) { |
| 174 | + return true; |
| 175 | + } |
| 176 | + |
| 177 | + if (o == null || getClass() != o.getClass()) { |
| 178 | + return false; |
| 179 | + } |
| 180 | + |
| 181 | + Token other = (Token) o; |
| 182 | + |
| 183 | + return Objects.equals(accessToken, other.accessToken) && Objects.equals(refreshToken, other.refreshToken) && Objects.equals(idToken, other.idToken) && Objects.equals(tokenType, other.tokenType) && Objects.equals(expiresIn, other.expiresIn) ; |
| 184 | + } |
| 185 | + |
| 186 | + @Override |
| 187 | + public int hashCode() { |
| 188 | + return Objects.hash(accessToken, refreshToken, idToken, tokenType, expiresIn); |
| 189 | + } |
| 190 | + |
| 191 | + |
| 192 | +} |
| 193 | + |
0 commit comments