1+ /**
2+ * This code was generated by
3+ * \ / _ _ _| _ _
4+ * | (_)\/(_)(_|\/| |(/_ v1.0.0
5+ * / /
6+ */
7+
8+ package com .twilio .rest .frontlineapi .v1 ;
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 .twilio .base .Resource ;
17+ import com .twilio .converter .Promoter ;
18+ import com .twilio .exception .ApiConnectionException ;
19+ import com .twilio .exception .ApiException ;
20+ import com .twilio .exception .RestException ;
21+ import com .twilio .http .HttpMethod ;
22+ import com .twilio .http .Request ;
23+ import com .twilio .http .Response ;
24+ import com .twilio .http .TwilioRestClient ;
25+ import com .twilio .rest .Domains ;
26+ import lombok .ToString ;
27+
28+ import java .io .IOException ;
29+ import java .io .InputStream ;
30+ import java .net .URI ;
31+ import java .util .Map ;
32+ import java .util .Objects ;
33+
34+ /**
35+ * PLEASE NOTE that this class contains beta products that are subject to
36+ * change. Use them with caution.
37+ */
38+ @ JsonIgnoreProperties (ignoreUnknown = true )
39+ @ ToString
40+ public class User extends Resource {
41+ private static final long serialVersionUID = 146148351923263L ;
42+
43+ public enum StateType {
44+ ACTIVE ("active" ),
45+ DEACTIVATED ("deactivated" );
46+
47+ private final String value ;
48+
49+ private StateType (final String value ) {
50+ this .value = value ;
51+ }
52+
53+ public String toString () {
54+ return value ;
55+ }
56+
57+ /**
58+ * Generate a StateType from a string.
59+ * @param value string value
60+ * @return generated StateType
61+ */
62+ @ JsonCreator
63+ public static StateType forValue (final String value ) {
64+ return Promoter .enumFromString (value , StateType .values ());
65+ }
66+ }
67+
68+ /**
69+ * Create a UserFetcher to execute fetch.
70+ *
71+ * @param pathSid The SID of the User resource to fetch
72+ * @return UserFetcher capable of executing the fetch
73+ */
74+ public static UserFetcher fetcher (final String pathSid ) {
75+ return new UserFetcher (pathSid );
76+ }
77+
78+ /**
79+ * Create a UserUpdater to execute update.
80+ *
81+ * @param pathSid The SID of the User resource to update
82+ * @return UserUpdater capable of executing the update
83+ */
84+ public static UserUpdater updater (final String pathSid ) {
85+ return new UserUpdater (pathSid );
86+ }
87+
88+ /**
89+ * Converts a JSON String into a User object using the provided ObjectMapper.
90+ *
91+ * @param json Raw JSON String
92+ * @param objectMapper Jackson ObjectMapper
93+ * @return User object represented by the provided JSON
94+ */
95+ public static User fromJson (final String json , final ObjectMapper objectMapper ) {
96+ // Convert all checked exceptions to Runtime
97+ try {
98+ return objectMapper .readValue (json , User .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 User object using the provided
108+ * ObjectMapper.
109+ *
110+ * @param json Raw JSON InputStream
111+ * @param objectMapper Jackson ObjectMapper
112+ * @return User object represented by the provided JSON
113+ */
114+ public static User fromJson (final InputStream json , final ObjectMapper objectMapper ) {
115+ // Convert all checked exceptions to Runtime
116+ try {
117+ return objectMapper .readValue (json , User .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 sid ;
126+ private final String identity ;
127+ private final String friendlyName ;
128+ private final String avatar ;
129+ private final User .StateType state ;
130+ private final URI url ;
131+
132+ @ JsonCreator
133+ private User (@ JsonProperty ("sid" )
134+ final String sid ,
135+ @ JsonProperty ("identity" )
136+ final String identity ,
137+ @ JsonProperty ("friendly_name" )
138+ final String friendlyName ,
139+ @ JsonProperty ("avatar" )
140+ final String avatar ,
141+ @ JsonProperty ("state" )
142+ final User .StateType state ,
143+ @ JsonProperty ("url" )
144+ final URI url ) {
145+ this .sid = sid ;
146+ this .identity = identity ;
147+ this .friendlyName = friendlyName ;
148+ this .avatar = avatar ;
149+ this .state = state ;
150+ this .url = url ;
151+ }
152+
153+ /**
154+ * Returns The unique string that identifies the resource.
155+ *
156+ * @return The unique string that identifies the resource
157+ */
158+ public final String getSid () {
159+ return this .sid ;
160+ }
161+
162+ /**
163+ * Returns The string that identifies the resource's User.
164+ *
165+ * @return The string that identifies the resource's User
166+ */
167+ public final String getIdentity () {
168+ return this .identity ;
169+ }
170+
171+ /**
172+ * Returns The string that you assigned to describe the User.
173+ *
174+ * @return The string that you assigned to describe the User
175+ */
176+ public final String getFriendlyName () {
177+ return this .friendlyName ;
178+ }
179+
180+ /**
181+ * Returns The avatar URL which will be shown in Frontline application.
182+ *
183+ * @return The avatar URL which will be shown in Frontline application
184+ */
185+ public final String getAvatar () {
186+ return this .avatar ;
187+ }
188+
189+ /**
190+ * Returns Current state of this user.
191+ *
192+ * @return Current state of this user
193+ */
194+ public final User .StateType getState () {
195+ return this .state ;
196+ }
197+
198+ /**
199+ * Returns An absolute URL for this user..
200+ *
201+ * @return An absolute URL for this user.
202+ */
203+ public final URI getUrl () {
204+ return this .url ;
205+ }
206+
207+ @ Override
208+ public boolean equals (final Object o ) {
209+ if (this == o ) {
210+ return true ;
211+ }
212+
213+ if (o == null || getClass () != o .getClass ()) {
214+ return false ;
215+ }
216+
217+ User other = (User ) o ;
218+
219+ return Objects .equals (sid , other .sid ) &&
220+ Objects .equals (identity , other .identity ) &&
221+ Objects .equals (friendlyName , other .friendlyName ) &&
222+ Objects .equals (avatar , other .avatar ) &&
223+ Objects .equals (state , other .state ) &&
224+ Objects .equals (url , other .url );
225+ }
226+
227+ @ Override
228+ public int hashCode () {
229+ return Objects .hash (sid ,
230+ identity ,
231+ friendlyName ,
232+ avatar ,
233+ state ,
234+ url );
235+ }
236+ }
0 commit comments