All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twilio.rest.taskrouter.v1.workspace.Worker Maven / Gradle / Ivy

There is a newer version: 10.7.0
Show newest version
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

package com.twilio.rest.taskrouter.v1.workspace;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.MoreObjects;
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
import com.twilio.http.HttpMethod;
import com.twilio.http.Request;
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
import org.joda.time.DateTime;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.Map;
import java.util.Objects;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Worker extends Resource {
    private static final long serialVersionUID = 71992031157502L;

    /**
     * Create a WorkerReader to execute read.
     * 
     * @param pathWorkspaceSid The workspace_sid
     * @return WorkerReader capable of executing the read
     */
    public static WorkerReader reader(final String pathWorkspaceSid) {
        return new WorkerReader(pathWorkspaceSid);
    }

    /**
     * Create a WorkerCreator to execute create.
     * 
     * @param pathWorkspaceSid The workspace_sid
     * @param friendlyName String representing user-friendly name for the Worker.
     * @return WorkerCreator capable of executing the create
     */
    public static WorkerCreator creator(final String pathWorkspaceSid, 
                                        final String friendlyName) {
        return new WorkerCreator(pathWorkspaceSid, friendlyName);
    }

    /**
     * Create a WorkerFetcher to execute fetch.
     * 
     * @param pathWorkspaceSid The workspace_sid
     * @param pathSid The sid
     * @return WorkerFetcher capable of executing the fetch
     */
    public static WorkerFetcher fetcher(final String pathWorkspaceSid, 
                                        final String pathSid) {
        return new WorkerFetcher(pathWorkspaceSid, pathSid);
    }

    /**
     * Create a WorkerUpdater to execute update.
     * 
     * @param pathWorkspaceSid The workspace_sid
     * @param pathSid The sid
     * @return WorkerUpdater capable of executing the update
     */
    public static WorkerUpdater updater(final String pathWorkspaceSid, 
                                        final String pathSid) {
        return new WorkerUpdater(pathWorkspaceSid, pathSid);
    }

    /**
     * Create a WorkerDeleter to execute delete.
     * 
     * @param pathWorkspaceSid The workspace_sid
     * @param pathSid The sid
     * @return WorkerDeleter capable of executing the delete
     */
    public static WorkerDeleter deleter(final String pathWorkspaceSid, 
                                        final String pathSid) {
        return new WorkerDeleter(pathWorkspaceSid, pathSid);
    }

    /**
     * Converts a JSON String into a Worker object using the provided ObjectMapper.
     * 
     * @param json Raw JSON String
     * @param objectMapper Jackson ObjectMapper
     * @return Worker object represented by the provided JSON
     */
    public static Worker fromJson(final String json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, Worker.class);
        } catch (final JsonMappingException | JsonParseException e) {
            throw new ApiException(e.getMessage(), e);
        } catch (final IOException e) {
            throw new ApiConnectionException(e.getMessage(), e);
        }
    }

    /**
     * Converts a JSON InputStream into a Worker object using the provided
     * ObjectMapper.
     * 
     * @param json Raw JSON InputStream
     * @param objectMapper Jackson ObjectMapper
     * @return Worker object represented by the provided JSON
     */
    public static Worker fromJson(final InputStream json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, Worker.class);
        } catch (final JsonMappingException | JsonParseException e) {
            throw new ApiException(e.getMessage(), e);
        } catch (final IOException e) {
            throw new ApiConnectionException(e.getMessage(), e);
        }
    }

    private final String accountSid;
    private final String activityName;
    private final String activitySid;
    private final String attributes;
    private final Boolean available;
    private final DateTime dateCreated;
    private final DateTime dateStatusChanged;
    private final DateTime dateUpdated;
    private final String friendlyName;
    private final String sid;
    private final String workspaceSid;
    private final URI url;
    private final Map links;

    @JsonCreator
    private Worker(@JsonProperty("account_sid")
                   final String accountSid, 
                   @JsonProperty("activity_name")
                   final String activityName, 
                   @JsonProperty("activity_sid")
                   final String activitySid, 
                   @JsonProperty("attributes")
                   final String attributes, 
                   @JsonProperty("available")
                   final Boolean available, 
                   @JsonProperty("date_created")
                   final String dateCreated, 
                   @JsonProperty("date_status_changed")
                   final String dateStatusChanged, 
                   @JsonProperty("date_updated")
                   final String dateUpdated, 
                   @JsonProperty("friendly_name")
                   final String friendlyName, 
                   @JsonProperty("sid")
                   final String sid, 
                   @JsonProperty("workspace_sid")
                   final String workspaceSid, 
                   @JsonProperty("url")
                   final URI url, 
                   @JsonProperty("links")
                   final Map links) {
        this.accountSid = accountSid;
        this.activityName = activityName;
        this.activitySid = activitySid;
        this.attributes = attributes;
        this.available = available;
        this.dateCreated = DateConverter.iso8601DateTimeFromString(dateCreated);
        this.dateStatusChanged = DateConverter.iso8601DateTimeFromString(dateStatusChanged);
        this.dateUpdated = DateConverter.iso8601DateTimeFromString(dateUpdated);
        this.friendlyName = friendlyName;
        this.sid = sid;
        this.workspaceSid = workspaceSid;
        this.url = url;
        this.links = links;
    }

    /**
     * Returns The The ID of the account that owns this worker.
     * 
     * @return The ID of the account that owns this worker
     */
    public final String getAccountSid() {
        return this.accountSid;
    }

    /**
     * Returns The Filter by workers that are in a particular Activity by Friendly
     * Name.
     * 
     * @return Filter by workers that are in a particular Activity by Friendly Name
     */
    public final String getActivityName() {
        return this.activityName;
    }

    /**
     * Returns The Filter by workers that are in a particular Activity by SID.
     * 
     * @return Filter by workers that are in a particular Activity by SID
     */
    public final String getActivitySid() {
        return this.activitySid;
    }

    /**
     * Returns The JSON object describing this worker..
     * 
     * @return JSON object describing this worker.
     */
    public final String getAttributes() {
        return this.attributes;
    }

    /**
     * Returns The Filter by workers that are available or unavailable..
     * 
     * @return Filter by workers that are available or unavailable.
     */
    public final Boolean getAvailable() {
        return this.available;
    }

    /**
     * Returns The DateTime this worker was created.
     * 
     * @return DateTime this worker was created
     */
    public final DateTime getDateCreated() {
        return this.dateCreated;
    }

    /**
     * Returns The DateTime of the last change to the Worker's activity..
     * 
     * @return DateTime of the last change to the Worker's activity.
     */
    public final DateTime getDateStatusChanged() {
        return this.dateStatusChanged;
    }

    /**
     * Returns The DateTime of the last update.
     * 
     * @return DateTime of the last update
     */
    public final DateTime getDateUpdated() {
        return this.dateUpdated;
    }

    /**
     * Returns The Filter by a worker’s friendly name.
     * 
     * @return Filter by a worker’s friendly name
     */
    public final String getFriendlyName() {
        return this.friendlyName;
    }

    /**
     * Returns The The unique ID of the worker.
     * 
     * @return The unique ID of the worker
     */
    public final String getSid() {
        return this.sid;
    }

    /**
     * Returns The The ID of the Workflow this worker is associated with.
     * 
     * @return The ID of the Workflow this worker is associated with
     */
    public final String getWorkspaceSid() {
        return this.workspaceSid;
    }

    /**
     * Returns The The url.
     * 
     * @return The url
     */
    public final URI getUrl() {
        return this.url;
    }

    /**
     * Returns The The links.
     * 
     * @return The links
     */
    public final Map getLinks() {
        return this.links;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Worker other = (Worker) o;

        return Objects.equals(accountSid, other.accountSid) && 
               Objects.equals(activityName, other.activityName) && 
               Objects.equals(activitySid, other.activitySid) && 
               Objects.equals(attributes, other.attributes) && 
               Objects.equals(available, other.available) && 
               Objects.equals(dateCreated, other.dateCreated) && 
               Objects.equals(dateStatusChanged, other.dateStatusChanged) && 
               Objects.equals(dateUpdated, other.dateUpdated) && 
               Objects.equals(friendlyName, other.friendlyName) && 
               Objects.equals(sid, other.sid) && 
               Objects.equals(workspaceSid, other.workspaceSid) && 
               Objects.equals(url, other.url) && 
               Objects.equals(links, other.links);
    }

    @Override
    public int hashCode() {
        return Objects.hash(accountSid,
                            activityName,
                            activitySid,
                            attributes,
                            available,
                            dateCreated,
                            dateStatusChanged,
                            dateUpdated,
                            friendlyName,
                            sid,
                            workspaceSid,
                            url,
                            links);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                          .add("accountSid", accountSid)
                          .add("activityName", activityName)
                          .add("activitySid", activitySid)
                          .add("attributes", attributes)
                          .add("available", available)
                          .add("dateCreated", dateCreated)
                          .add("dateStatusChanged", dateStatusChanged)
                          .add("dateUpdated", dateUpdated)
                          .add("friendlyName", friendlyName)
                          .add("sid", sid)
                          .add("workspaceSid", workspaceSid)
                          .add("url", url)
                          .add("links", links)
                          .toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy