
com.lob.model.Area Maven / Gradle / Ivy
package com.lob.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.lob.exception.APIException;
import com.lob.exception.AuthenticationException;
import com.lob.exception.InvalidRequestException;
import com.lob.exception.RateLimitException;
import com.lob.net.APIResource;
import com.lob.net.LobResponse;
import com.lob.net.RequestOptions;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Area extends APIResource {
public static final String RESOURCE = "areas";
public static class Tracking {
@JsonProperty private final String id;
@JsonProperty private final String tracking_number;
@JsonProperty private final String carrier;
@JsonProperty private final List events;
@JsonProperty private final String object;
@JsonCreator
public Tracking(
@JsonProperty("id") final String id,
@JsonProperty("tracking_number") final String tracking_number,
@JsonProperty("carrier") final String carrier,
@JsonProperty("events") final List events,
@JsonProperty("object") final String object) {
this.id = id;
this.tracking_number = tracking_number;
this.carrier = carrier;
this.events = events;
this.object = object;
}
public String getId() {
return id;
}
public String getTracking_number() {
return tracking_number;
}
public String getCarrier() {
return carrier;
}
public List getEvents() {
return events;
}
public String getObject() {
return object;
}
}
@JsonProperty private final String id;
@JsonProperty private final String description;
@JsonProperty private final String price;
@JsonProperty private final String url;
@JsonProperty private final String targetType;
@JsonProperty private final int addresses;
@JsonProperty private final List zipCodes;
@JsonProperty private final List thumbnails;
@JsonProperty private final List trackings;
@JsonProperty private final String expectedDeliveryDate;
@JsonProperty private final Map metadata;
@JsonProperty private final String dateCreated;
@JsonProperty private final String dateModified;
@JsonProperty private final boolean deleted;
@JsonProperty private final String object;
@JsonCreator
public Area(@JsonProperty("id") final String id,
@JsonProperty("description") final String description,
@JsonProperty("price") final String price,
@JsonProperty("url") final String url,
@JsonProperty("addresses") final int addresses,
@JsonProperty("target_type") final String targetType,
@JsonProperty("zip_codes") final List zipCodes,
@JsonProperty("thumbnails") final List thumbnails,
@JsonProperty("trackings") final List trackings,
@JsonProperty("expected_delivery_date") final String expectedDeliveryDate,
@JsonProperty("metadata") final Map metadata,
@JsonProperty("date_created") final String dateCreated,
@JsonProperty("date_modified") final String dateModified,
@JsonProperty("deleted") final boolean deleted,
@JsonProperty("object") final String object) {
this.id = id;
this.description = description;
this.metadata = metadata;
this.zipCodes = zipCodes;
this.addresses = addresses;
this.price = price;
this.url = url;
this.targetType = targetType;
this.thumbnails = thumbnails;
this.expectedDeliveryDate = expectedDeliveryDate;
this.trackings = trackings;
this.dateCreated = dateCreated;
this.dateModified = dateModified;
this.deleted = deleted;
this.object = object;
}
public String getId() {
return id;
}
public String getDescription() {
return description;
}
public String getPrice() {
return price;
}
public String getUrl() {
return url;
}
public String getTargetType() {
return targetType;
}
public int getAddresses() {
return addresses;
}
public List getZipCodes() {
return zipCodes;
}
public List getThumbnails() {
return thumbnails;
}
public List getTrackings() {
return trackings;
}
public String getExpectedDeliveryDate() {
return expectedDeliveryDate;
}
public Map getMetadata() {
return metadata;
}
public String getDateCreated() {
return dateCreated;
}
public String getDateModified() {
return dateModified;
}
public boolean isDeleted() {
return deleted;
}
public String getObject() {
return object;
}
@Override
public String toString() {
return "Area{" +
"id=" + id +
", description='" + description + '\'' +
", zipCodes='" + zipCodes + '\'' +
", addresses='" + addresses + '\'' +
", price='" + price + '\'' +
", url='" + url + '\'' +
", targetType='" + targetType + '\'' +
", thumbnails='" + thumbnails + '\'' +
", expectedDeliveryDate='" + expectedDeliveryDate + '\'' +
", trackings='" + trackings + '\'' +
", thumbnails='" + thumbnails + '\'' +
", expectedDeliveryDate='" + expectedDeliveryDate + '\'' +
", dateCreated='" + dateCreated + '\'' +
", dateModified='" + dateModified + '\'' +
", metadata='" + metadata + '\'' +
", object='" + object + '\'' +
'}';
}
public static final class RequestBuilder {
private Map params = new HashMap();
private boolean isMultipart = false;
public RequestBuilder() {
}
public RequestBuilder setDescription(String description) {
params.put("description", description);
return this;
}
public RequestBuilder setRoutes(String routes) {
params.put("routes", routes);
return this;
}
public RequestBuilder setRoutes(List routes) {
params.put("routes", routes);
return this;
}
public RequestBuilder setTargetType(String targeType) {
params.put("target_type", targeType);
return this;
}
public RequestBuilder setFront(String front) {
params.put("front", front);
return this;
}
public RequestBuilder setFront(File front) {
isMultipart = true;
params.put("front", front);
return this;
}
public RequestBuilder setBack(String back) {
params.put("back", back);
return this;
}
public RequestBuilder setBack(File back) {
isMultipart = true;
params.put("back", back);
return this;
}
public RequestBuilder setMergeVariables(Map mergeVariables) {
params.put("merge_variables", mergeVariables);
return this;
}
public RequestBuilder setMetadata(Map metadata) {
params.put("metadata", metadata);
return this;
}
public LobResponse create() throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
return create(null);
}
public LobResponse create(RequestOptions options) throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
if (isMultipart) {
return request(RequestMethod.POST, RequestType.MULTIPART, RESOURCE, params, Area.class, options);
}
return request(RequestMethod.POST, RequestType.NORMAL, RESOURCE, params, Area.class, options);
}
}
public static LobResponse retrieve(String id) throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
return retrieve(id, null);
}
public static LobResponse retrieve(String id, RequestOptions options) throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
return request(RequestMethod.GET, RequestType.NORMAL, String.format("%s/%s", RESOURCE, id), null, Area.class, options);
}
public static LobResponse list() throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
return list(null, null);
}
public static LobResponse list(Map params) throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
return list(params, null);
}
public static LobResponse list(RequestOptions options) throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
return list(null, options);
}
public static LobResponse list(Map params, RequestOptions options) throws APIException, IOException, AuthenticationException, InvalidRequestException, RateLimitException {
return request(RequestMethod.GET, RequestType.NORMAL, RESOURCE, params, AreaCollection.class, options);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy