/src/main/java/com/twilio/rest/api/v2010/account/call/Siprec.java

http://github.com/twilio/twilio-java · Java · 331 lines · 188 code · 39 blank · 104 comment · 6 complexity · 7e2a9de13cffdbfeb9eee10b5f515733 MD5 · raw file

  1. /**
  2. * This code was generated by
  3. * \ / _ _ _| _ _
  4. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  5. * / /
  6. */
  7. package com.twilio.rest.api.v2010.account.call;
  8. import com.fasterxml.jackson.annotation.JsonCreator;
  9. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  10. import com.fasterxml.jackson.annotation.JsonProperty;
  11. import com.fasterxml.jackson.core.JsonParseException;
  12. import com.fasterxml.jackson.databind.JsonMappingException;
  13. import com.fasterxml.jackson.databind.ObjectMapper;
  14. import com.twilio.base.Resource;
  15. import com.twilio.converter.DateConverter;
  16. import com.twilio.converter.Promoter;
  17. import com.twilio.exception.ApiConnectionException;
  18. import com.twilio.exception.ApiException;
  19. import com.twilio.exception.RestException;
  20. import com.twilio.http.HttpMethod;
  21. import com.twilio.http.Request;
  22. import com.twilio.http.Response;
  23. import com.twilio.http.TwilioRestClient;
  24. import com.twilio.rest.Domains;
  25. import lombok.ToString;
  26. import java.io.IOException;
  27. import java.io.InputStream;
  28. import java.time.ZonedDateTime;
  29. import java.util.Map;
  30. import java.util.Objects;
  31. @JsonIgnoreProperties(ignoreUnknown = true)
  32. @ToString
  33. public class Siprec extends Resource {
  34. private static final long serialVersionUID = 120054953189179L;
  35. public enum Track {
  36. INBOUND_TRACK("inbound_track"),
  37. OUTBOUND_TRACK("outbound_track"),
  38. BOTH_TRACKS("both_tracks");
  39. private final String value;
  40. private Track(final String value) {
  41. this.value = value;
  42. }
  43. public String toString() {
  44. return value;
  45. }
  46. /**
  47. * Generate a Track from a string.
  48. * @param value string value
  49. * @return generated Track
  50. */
  51. @JsonCreator
  52. public static Track forValue(final String value) {
  53. return Promoter.enumFromString(value, Track.values());
  54. }
  55. }
  56. public enum Status {
  57. IN_PROGRESS("in-progress"),
  58. STOPPED("stopped");
  59. private final String value;
  60. private Status(final String value) {
  61. this.value = value;
  62. }
  63. public String toString() {
  64. return value;
  65. }
  66. /**
  67. * Generate a Status from a string.
  68. * @param value string value
  69. * @return generated Status
  70. */
  71. @JsonCreator
  72. public static Status forValue(final String value) {
  73. return Promoter.enumFromString(value, Status.values());
  74. }
  75. }
  76. public enum UpdateStatus {
  77. STOPPED("stopped");
  78. private final String value;
  79. private UpdateStatus(final String value) {
  80. this.value = value;
  81. }
  82. public String toString() {
  83. return value;
  84. }
  85. /**
  86. * Generate a UpdateStatus from a string.
  87. * @param value string value
  88. * @return generated UpdateStatus
  89. */
  90. @JsonCreator
  91. public static UpdateStatus forValue(final String value) {
  92. return Promoter.enumFromString(value, UpdateStatus.values());
  93. }
  94. }
  95. /**
  96. * Create a SiprecCreator to execute create.
  97. *
  98. * @param pathAccountSid The SID of the Account that created this resource
  99. * @param pathCallSid The SID of the Call the resource is associated with
  100. * @return SiprecCreator capable of executing the create
  101. */
  102. public static SiprecCreator creator(final String pathAccountSid,
  103. final String pathCallSid) {
  104. return new SiprecCreator(pathAccountSid, pathCallSid);
  105. }
  106. /**
  107. * Create a SiprecCreator to execute create.
  108. *
  109. * @param pathCallSid The SID of the Call the resource is associated with
  110. * @return SiprecCreator capable of executing the create
  111. */
  112. public static SiprecCreator creator(final String pathCallSid) {
  113. return new SiprecCreator(pathCallSid);
  114. }
  115. /**
  116. * Create a SiprecUpdater to execute update.
  117. *
  118. * @param pathAccountSid The SID of the Account that created this resource
  119. * @param pathCallSid The SID of the Call the resource is associated with
  120. * @param pathSid The SID of the Siprec resource, or the `name`
  121. * @param status The status. Must have the value `stopped`
  122. * @return SiprecUpdater capable of executing the update
  123. */
  124. public static SiprecUpdater updater(final String pathAccountSid,
  125. final String pathCallSid,
  126. final String pathSid,
  127. final Siprec.UpdateStatus status) {
  128. return new SiprecUpdater(pathAccountSid, pathCallSid, pathSid, status);
  129. }
  130. /**
  131. * Create a SiprecUpdater to execute update.
  132. *
  133. * @param pathCallSid The SID of the Call the resource is associated with
  134. * @param pathSid The SID of the Siprec resource, or the `name`
  135. * @param status The status. Must have the value `stopped`
  136. * @return SiprecUpdater capable of executing the update
  137. */
  138. public static SiprecUpdater updater(final String pathCallSid,
  139. final String pathSid,
  140. final Siprec.UpdateStatus status) {
  141. return new SiprecUpdater(pathCallSid, pathSid, status);
  142. }
  143. /**
  144. * Converts a JSON String into a Siprec object using the provided ObjectMapper.
  145. *
  146. * @param json Raw JSON String
  147. * @param objectMapper Jackson ObjectMapper
  148. * @return Siprec object represented by the provided JSON
  149. */
  150. public static Siprec fromJson(final String json, final ObjectMapper objectMapper) {
  151. // Convert all checked exceptions to Runtime
  152. try {
  153. return objectMapper.readValue(json, Siprec.class);
  154. } catch (final JsonMappingException | JsonParseException e) {
  155. throw new ApiException(e.getMessage(), e);
  156. } catch (final IOException e) {
  157. throw new ApiConnectionException(e.getMessage(), e);
  158. }
  159. }
  160. /**
  161. * Converts a JSON InputStream into a Siprec object using the provided
  162. * ObjectMapper.
  163. *
  164. * @param json Raw JSON InputStream
  165. * @param objectMapper Jackson ObjectMapper
  166. * @return Siprec object represented by the provided JSON
  167. */
  168. public static Siprec fromJson(final InputStream json, final ObjectMapper objectMapper) {
  169. // Convert all checked exceptions to Runtime
  170. try {
  171. return objectMapper.readValue(json, Siprec.class);
  172. } catch (final JsonMappingException | JsonParseException e) {
  173. throw new ApiException(e.getMessage(), e);
  174. } catch (final IOException e) {
  175. throw new ApiConnectionException(e.getMessage(), e);
  176. }
  177. }
  178. private final String sid;
  179. private final String accountSid;
  180. private final String callSid;
  181. private final String name;
  182. private final Siprec.Status status;
  183. private final ZonedDateTime dateUpdated;
  184. private final String uri;
  185. @JsonCreator
  186. private Siprec(@JsonProperty("sid")
  187. final String sid,
  188. @JsonProperty("account_sid")
  189. final String accountSid,
  190. @JsonProperty("call_sid")
  191. final String callSid,
  192. @JsonProperty("name")
  193. final String name,
  194. @JsonProperty("status")
  195. final Siprec.Status status,
  196. @JsonProperty("date_updated")
  197. final String dateUpdated,
  198. @JsonProperty("uri")
  199. final String uri) {
  200. this.sid = sid;
  201. this.accountSid = accountSid;
  202. this.callSid = callSid;
  203. this.name = name;
  204. this.status = status;
  205. this.dateUpdated = DateConverter.rfc2822DateTimeFromString(dateUpdated);
  206. this.uri = uri;
  207. }
  208. /**
  209. * Returns The SID of the Siprec resource..
  210. *
  211. * @return The SID of the Siprec resource.
  212. */
  213. public final String getSid() {
  214. return this.sid;
  215. }
  216. /**
  217. * Returns The SID of the Account that created this resource.
  218. *
  219. * @return The SID of the Account that created this resource
  220. */
  221. public final String getAccountSid() {
  222. return this.accountSid;
  223. }
  224. /**
  225. * Returns The SID of the Call the resource is associated with.
  226. *
  227. * @return The SID of the Call the resource is associated with
  228. */
  229. public final String getCallSid() {
  230. return this.callSid;
  231. }
  232. /**
  233. * Returns The name of this resource.
  234. *
  235. * @return The name of this resource
  236. */
  237. public final String getName() {
  238. return this.name;
  239. }
  240. /**
  241. * Returns The status - one of `stopped`, `in-progress`.
  242. *
  243. * @return The status - one of `stopped`, `in-progress`
  244. */
  245. public final Siprec.Status getStatus() {
  246. return this.status;
  247. }
  248. /**
  249. * Returns The RFC 2822 date and time in GMT that this resource was last
  250. * updated.
  251. *
  252. * @return The RFC 2822 date and time in GMT that this resource was last updated
  253. */
  254. public final ZonedDateTime getDateUpdated() {
  255. return this.dateUpdated;
  256. }
  257. /**
  258. * Returns The URI of the resource, relative to `https://api.twilio.com`.
  259. *
  260. * @return The URI of the resource, relative to `https://api.twilio.com`
  261. */
  262. public final String getUri() {
  263. return this.uri;
  264. }
  265. @Override
  266. public boolean equals(final Object o) {
  267. if (this == o) {
  268. return true;
  269. }
  270. if (o == null || getClass() != o.getClass()) {
  271. return false;
  272. }
  273. Siprec other = (Siprec) o;
  274. return Objects.equals(sid, other.sid) &&
  275. Objects.equals(accountSid, other.accountSid) &&
  276. Objects.equals(callSid, other.callSid) &&
  277. Objects.equals(name, other.name) &&
  278. Objects.equals(status, other.status) &&
  279. Objects.equals(dateUpdated, other.dateUpdated) &&
  280. Objects.equals(uri, other.uri);
  281. }
  282. @Override
  283. public int hashCode() {
  284. return Objects.hash(sid,
  285. accountSid,
  286. callSid,
  287. name,
  288. status,
  289. dateUpdated,
  290. uri);
  291. }
  292. }