![JAR search and dependency download from the Maven repository](/logo.png)
com.lob.model.CreativeWritable Maven / Gradle / Ivy
Show all versions of lob-java Show documentation
/*
* Lob
* The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors. Looking for our [previous documentation](https://lob.github.io/legacy-docs/)?
*
* The version of the OpenAPI document: 1.3.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.lob.model;
import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openapitools.jackson.nullable.JsonNullable;
import com.google.gson.Gson;
import java.util.HashMap;
import java.util.Map;
/**
* CreativeWritable
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class CreativeWritable {
public static final String SERIALIZED_NAME_FROM = "from";
@SerializedName(SERIALIZED_NAME_FROM)
private String from;
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public void setFrom(AddressEditable from) {
Gson gson = new Gson();
this.from = gson.toJson(from);
}
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
/**
* An internal description that identifies this resource. Must be no longer than 255 characters.
* @return description
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "An internal description that identifies this resource. Must be no longer than 255 characters. ")
public String getDescription() {
return description;
}
public static final String SERIALIZED_NAME_METADATA = "metadata";
@SerializedName(SERIALIZED_NAME_METADATA)
private Map metadata = null;
public Map getMetadata() {
if (this.metadata == null) {
this.metadata = new HashMap();
}
return this.metadata;
}
/**
* Mailpiece type for the creative
*/
@JsonAdapter(ResourceTypeEnum.Adapter.class)
public enum ResourceTypeEnum {
LETTER("letter"),
POSTCARD("postcard");
private String value;
ResourceTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static ResourceTypeEnum fromValue(String value) {
for (ResourceTypeEnum b : ResourceTypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final ResourceTypeEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public ResourceTypeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return ResourceTypeEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_RESOURCE_TYPE = "resource_type";
@SerializedName(SERIALIZED_NAME_RESOURCE_TYPE)
private ResourceTypeEnum resourceType;
/**
* Mailpiece type for the creative
* @return resourceType
**/
@javax.annotation.Nonnull
@ApiModelProperty(required = true, value = "Mailpiece type for the creative")
public ResourceTypeEnum getResourceType() {
return resourceType;
}
public static final String SERIALIZED_NAME_CAMPAIGN_ID = "campaign_id";
@SerializedName(SERIALIZED_NAME_CAMPAIGN_ID)
private String campaignId;
/**
* Unique identifier prefixed with `cmp_`.
* @return campaignId
**/
@javax.annotation.Nonnull
public String getCampaignId() { return campaignId; }
public void setCampaignId (String campaignId) throws IllegalArgumentException {
if(!campaignId.matches("^cmp_[a-zA-Z0-9]+$")) {
throw new IllegalArgumentException("Invalid campaign_id provided");
}
this.campaignId = campaignId;
}
public static final String SERIALIZED_NAME_DETAILS = "details";
@SerializedName(SERIALIZED_NAME_DETAILS)
private String details;
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public void setDetails(PostcardDetailsWritable details) {
Gson gson = new Gson();
this.details = gson.toJson(details);
}
public void setDetails(LetterDetailsWritable details) {
Gson gson = new Gson();
this.details = gson.toJson(details);
}
public static final String SERIALIZED_NAME_FILE = "file";
@SerializedName(SERIALIZED_NAME_FILE)
private String file;
/**
* PDF file containing the letter's formatting. Do not include for resource_type = postcard.
* @return file
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "PDF file containing the letter's formatting. Do not include for resource_type = postcard.")
public String getFile() {
return file;
}
public static final String SERIALIZED_NAME_FRONT = "front";
@SerializedName(SERIALIZED_NAME_FRONT)
private String front;
/**
* The artwork to use as the front of your postcard. Do not include for resource_type = letter.
* @return front
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "The artwork to use as the front of your postcard. Do not include for resource_type = letter. ")
public String getFront() {
return front;
}
public static final String SERIALIZED_NAME_BACK = "back";
@SerializedName(SERIALIZED_NAME_BACK)
private String back;
/**
* The artwork to use as the back of your postcard. Do not include for resource_type = letter.
* @return back
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "The artwork to use as the back of your postcard. Do not include for resource_type = letter. ")
public String getBack() {
return back;
}
/*
public CreativeWritable from(Object from) {
this.from = from;
return this;
}
*/
/*
public CreativeWritable description(String description) {
this.description = description;
return this;
}
*/
public void setDescription(String description) {
this.description = description;
}
/*
public CreativeWritable metadata(Map metadata) {
this.metadata = metadata;
return this;
}
*/
public CreativeWritable putMetadataItem(String key, String metadataItem) {
if (this.metadata == null) {
this.metadata = new HashMap();
}
this.metadata.put(key, metadataItem);
return this;
}
public void setMetadata(Map metadata) {
this.metadata = metadata;
}
/*
public CreativeWritable resourceType(ResourceTypeEnum resourceType) {
this.resourceType = resourceType;
return this;
}
*/
public void setResourceType(ResourceTypeEnum resourceType) {
this.resourceType = resourceType;
}
/*
public CreativeWritable campaignId(String campaignId) {
this.campaignId = campaignId;
return this;
}
*/
/*
public CreativeWritable details(Object details) {
this.details = details;
return this;
}
*/
/*
public CreativeWritable file(String file) {
this.file = file;
return this;
}
*/
public void setFile(String file) {
this.file = file;
}
/*
public CreativeWritable front(String front) {
this.front = front;
return this;
}
*/
public void setFront(String front) {
this.front = front;
}
/*
public CreativeWritable back(String back) {
this.back = back;
return this;
}
*/
public void setBack(String back) {
this.back = back;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CreativeWritable creativeWritable = (CreativeWritable) o;
return Objects.equals(this.from, creativeWritable.from) &&
Objects.equals(this.description, creativeWritable.description) &&
Objects.equals(this.metadata, creativeWritable.metadata) &&
Objects.equals(this.resourceType, creativeWritable.resourceType) &&
Objects.equals(this.campaignId, creativeWritable.campaignId) &&
Objects.equals(this.details, creativeWritable.details) &&
Objects.equals(this.file, creativeWritable.file) &&
Objects.equals(this.front, creativeWritable.front) &&
Objects.equals(this.back, creativeWritable.back);
}
private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
}
@Override
public int hashCode() {
return Objects.hash(from, description, metadata, resourceType, campaignId, details, file, front, back);
}
private static int hashCodeNullable(JsonNullable a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{\n");
sb.append(" from: ").append(toIndentedString(from)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
sb.append(" resourceType: ").append(toIndentedString(resourceType)).append("\n");
sb.append(" campaignId: ").append(toIndentedString(campaignId)).append("\n");
sb.append(" details: ").append(toIndentedString(details)).append("\n");
sb.append(" file: ").append(toIndentedString(file)).append("\n");
sb.append(" front: ").append(toIndentedString(front)).append("\n");
sb.append(" back: ").append(toIndentedString(back)).append("\n");
sb.append("}");
return sb.toString();
}
public Map toMap() {
Map localMap = new HashMap();
localMap.put("from", from);
localMap.put("description", description);
localMap.put("metadata", metadata);
localMap.put("resource_type", resourceType);
localMap.put("campaign_id", campaignId);
localMap.put("details", details);
localMap.put("file", file);
localMap.put("front", front);
localMap.put("back", back);
return localMap;
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}