1+ /**
2+ * This code was generated by
3+ * \ / _ _ _| _ _
4+ * | (_)\/(_)(_|\/| |(/_ v1.0.0
5+ * / /
6+ */
7+
8+ package com .twilio .rest .accounts .v1 .credential ;
9+
10+ import com .fasterxml .jackson .annotation .JsonCreator ;
11+ import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
12+ import com .fasterxml .jackson .annotation .JsonProperty ;
13+ import com .fasterxml .jackson .core .JsonParseException ;
14+ import com .fasterxml .jackson .databind .JsonMappingException ;
15+ import com .fasterxml .jackson .databind .ObjectMapper ;
16+ import com .google .common .base .MoreObjects ;
17+ import com .twilio .base .Resource ;
18+ import com .twilio .converter .DateConverter ;
19+ import com .twilio .exception .ApiConnectionException ;
20+ import com .twilio .exception .ApiException ;
21+ import com .twilio .exception .RestException ;
22+ import com .twilio .http .HttpMethod ;
23+ import com .twilio .http .Request ;
24+ import com .twilio .http .Response ;
25+ import com .twilio .http .TwilioRestClient ;
26+ import com .twilio .rest .Domains ;
27+ import org .joda .time .DateTime ;
28+
29+ import java .io .IOException ;
30+ import java .io .InputStream ;
31+ import java .net .URI ;
32+ import java .util .Map ;
33+ import java .util .Objects ;
34+
35+ @ JsonIgnoreProperties (ignoreUnknown = true )
36+ public class PublicKey extends Resource {
37+ private static final long serialVersionUID = 108884981918794L ;
38+
39+ /**
40+ * Create a PublicKeyReader to execute read.
41+ *
42+ * @return PublicKeyReader capable of executing the read
43+ */
44+ public static PublicKeyReader reader () {
45+ return new PublicKeyReader ();
46+ }
47+
48+ /**
49+ * Create a PublicKeyCreator to execute create.
50+ *
51+ * @param publicKey The public_key
52+ * @return PublicKeyCreator capable of executing the create
53+ */
54+ public static PublicKeyCreator creator (final String publicKey ) {
55+ return new PublicKeyCreator (publicKey );
56+ }
57+
58+ /**
59+ * Create a PublicKeyFetcher to execute fetch.
60+ *
61+ * @param sid The sid
62+ * @return PublicKeyFetcher capable of executing the fetch
63+ */
64+ public static PublicKeyFetcher fetcher (final String sid ) {
65+ return new PublicKeyFetcher (sid );
66+ }
67+
68+ /**
69+ * Create a PublicKeyUpdater to execute update.
70+ *
71+ * @param sid The sid
72+ * @return PublicKeyUpdater capable of executing the update
73+ */
74+ public static PublicKeyUpdater updater (final String sid ) {
75+ return new PublicKeyUpdater (sid );
76+ }
77+
78+ /**
79+ * Create a PublicKeyDeleter to execute delete.
80+ *
81+ * @param sid The sid
82+ * @return PublicKeyDeleter capable of executing the delete
83+ */
84+ public static PublicKeyDeleter deleter (final String sid ) {
85+ return new PublicKeyDeleter (sid );
86+ }
87+
88+ /**
89+ * Converts a JSON String into a PublicKey object using the provided
90+ * ObjectMapper.
91+ *
92+ * @param json Raw JSON String
93+ * @param objectMapper Jackson ObjectMapper
94+ * @return PublicKey object represented by the provided JSON
95+ */
96+ public static PublicKey fromJson (final String json , final ObjectMapper objectMapper ) {
97+ // Convert all checked exceptions to Runtime
98+ try {
99+ return objectMapper .readValue (json , PublicKey .class );
100+ } catch (final JsonMappingException | JsonParseException e ) {
101+ throw new ApiException (e .getMessage (), e );
102+ } catch (final IOException e ) {
103+ throw new ApiConnectionException (e .getMessage (), e );
104+ }
105+ }
106+
107+ /**
108+ * Converts a JSON InputStream into a PublicKey object using the provided
109+ * ObjectMapper.
110+ *
111+ * @param json Raw JSON InputStream
112+ * @param objectMapper Jackson ObjectMapper
113+ * @return PublicKey object represented by the provided JSON
114+ */
115+ public static PublicKey fromJson (final InputStream json , final ObjectMapper objectMapper ) {
116+ // Convert all checked exceptions to Runtime
117+ try {
118+ return objectMapper .readValue (json , PublicKey .class );
119+ } catch (final JsonMappingException | JsonParseException e ) {
120+ throw new ApiException (e .getMessage (), e );
121+ } catch (final IOException e ) {
122+ throw new ApiConnectionException (e .getMessage (), e );
123+ }
124+ }
125+
126+ private final String sid ;
127+ private final String accountSid ;
128+ private final String friendlyName ;
129+ private final DateTime dateCreated ;
130+ private final DateTime dateUpdated ;
131+ private final URI url ;
132+
133+ @ JsonCreator
134+ private PublicKey (@ JsonProperty ("sid" )
135+ final String sid ,
136+ @ JsonProperty ("account_sid" )
137+ final String accountSid ,
138+ @ JsonProperty ("friendly_name" )
139+ final String friendlyName ,
140+ @ JsonProperty ("date_created" )
141+ final String dateCreated ,
142+ @ JsonProperty ("date_updated" )
143+ final String dateUpdated ,
144+ @ JsonProperty ("url" )
145+ final URI url ) {
146+ this .sid = sid ;
147+ this .accountSid = accountSid ;
148+ this .friendlyName = friendlyName ;
149+ this .dateCreated = DateConverter .iso8601DateTimeFromString (dateCreated );
150+ this .dateUpdated = DateConverter .iso8601DateTimeFromString (dateUpdated );
151+ this .url = url ;
152+ }
153+
154+ /**
155+ * Returns The The sid.
156+ *
157+ * @return The sid
158+ */
159+ public final String getSid () {
160+ return this .sid ;
161+ }
162+
163+ /**
164+ * Returns The The account_sid.
165+ *
166+ * @return The account_sid
167+ */
168+ public final String getAccountSid () {
169+ return this .accountSid ;
170+ }
171+
172+ /**
173+ * Returns The The friendly_name.
174+ *
175+ * @return The friendly_name
176+ */
177+ public final String getFriendlyName () {
178+ return this .friendlyName ;
179+ }
180+
181+ /**
182+ * Returns The The date_created.
183+ *
184+ * @return The date_created
185+ */
186+ public final DateTime getDateCreated () {
187+ return this .dateCreated ;
188+ }
189+
190+ /**
191+ * Returns The The date_updated.
192+ *
193+ * @return The date_updated
194+ */
195+ public final DateTime getDateUpdated () {
196+ return this .dateUpdated ;
197+ }
198+
199+ /**
200+ * Returns The The url.
201+ *
202+ * @return The url
203+ */
204+ public final URI getUrl () {
205+ return this .url ;
206+ }
207+
208+ @ Override
209+ public boolean equals (final Object o ) {
210+ if (this == o ) {
211+ return true ;
212+ }
213+
214+ if (o == null || getClass () != o .getClass ()) {
215+ return false ;
216+ }
217+
218+ PublicKey other = (PublicKey ) o ;
219+
220+ return Objects .equals (sid , other .sid ) &&
221+ Objects .equals (accountSid , other .accountSid ) &&
222+ Objects .equals (friendlyName , other .friendlyName ) &&
223+ Objects .equals (dateCreated , other .dateCreated ) &&
224+ Objects .equals (dateUpdated , other .dateUpdated ) &&
225+ Objects .equals (url , other .url );
226+ }
227+
228+ @ Override
229+ public int hashCode () {
230+ return Objects .hash (sid ,
231+ accountSid ,
232+ friendlyName ,
233+ dateCreated ,
234+ dateUpdated ,
235+ url );
236+ }
237+
238+ @ Override
239+ public String toString () {
240+ return MoreObjects .toStringHelper (this )
241+ .add ("sid" , sid )
242+ .add ("accountSid" , accountSid )
243+ .add ("friendlyName" , friendlyName )
244+ .add ("dateCreated" , dateCreated )
245+ .add ("dateUpdated" , dateUpdated )
246+ .add ("url" , url )
247+ .toString ();
248+ }
249+ }
0 commit comments