// The MIT License
//
// Copyright (c) 2010 Jared Holdcroft
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package com.postmark.java;

/**
 * Attachment for a message.<p/>
 * Sample code:
 * <pre>
 * {@code
 * Attachment attachment = new Attachment();
 * attachment.setContentType("application/pdf");
 * attachment.setName("SomethingAwesome.pdf");
 *
 * // convert file contents to base64
 * File file = new File("SomethingAwesome.pdf");
 * byte[] ba = new byte[(int) file.length()];
 * FileInputStream fis = new FileInputStream(file);
 * Fileis.read(ba);
 * fis.close();
 * attachment.setContent(new Base64().encodeToString(ba));
 *
 * // can handle multiple attachments
 * Vector<Attachment> v = new Vector<Attachment>();
 * v.add(attachment);
 * message.setAttachments(v);
 * }
 * </pre>
 */
public class Attachment {
	private String name;
	private String contentType;
	private String content;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Override
	public String toString() {
		return "Attachment [name=" + name + ", contentType=" + contentType + ", content=" + content + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((content == null) ? 0 : content.hashCode());
		result = prime * result + ((contentType == null) ? 0 : contentType.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Attachment other = (Attachment) obj;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content))
			return false;
		if (contentType == null) {
			if (other.contentType != null)
				return false;
		} else if (!contentType.equals(other.contentType))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
@@ -1157,16 +1157,68 @@
 .java;%0A%0A
+import com.google.gson.annotations.SerializedName;%0A%0A
 /**%0A * A
@@ -1900,81 +1900,223 @@
  %7B%0A%09
-private String name;%0A%09private String contentType;%0A%09private String content
+@SerializedName(%22Name%22)%0A%09private String name;%0A%09@SerializedName(%22ContentType%22)%0A%09private String contentType;%0A%09@SerializedName(%22Content%22)%0A%09private String content;%0A%09@SerializedName(%22ContentID%22)%0A%09private String contentID
 ;%0A%0A%09
@@ -2488,24 +2488,160 @@
 ontent;%0A%09%7D%0A%0A
+%09public String getContentID() %7B%0A%09%09return contentID;%0A%09%7D%0A%0A%09public void setContentID(String contentID) %7B%0A%09%09this.contentID = contentID;%0A%09%7D%0A%0A
 %09@Override%0A%09

support for inline images (with content id)