package synapticloop.b2.response;

import org.json.JSONObject;

import synapticloop.b2.Action;
import synapticloop.b2.exception.B2Exception;

public class B2FileInfoResponse extends BaseB2Response {
	private final String fileId;
	private final String fileName;
	private final Action action;
	private final Integer size;
	private final Long uploadTimestamp;

    public B2FileInfoResponse(final JSONObject response) throws B2Exception {
        super(response);

        this.fileId = response.optString(B2ResponseProperties.KEY_FILE_ID);
		this.fileName = response.optString(B2ResponseProperties.KEY_FILE_NAME);

		String action = response.optString(B2ResponseProperties.KEY_ACTION);
        if(null != action) {
            this.action = Action.valueOf(action);
        }
        else {
            // Default
            this.action = Action.upload;
        }
		this.size = response.optInt(B2ResponseProperties.KEY_SIZE);
		this.uploadTimestamp = response.optLong(B2ResponseProperties.KEY_UPLOAD_TIMESTAMP);
	}

	public String getFileId() { return this.fileId; }
	public String getFileName() { return this.fileName; }
	public Action getAction() { return this.action; }
	public int getSize() { return this.size; }
	public long getUploadTimestamp() { return this.uploadTimestamp; }

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder("B2FileInfoResponse{");
		sb.append("fileId='").append(fileId).append('\'');
		sb.append(", fileName='").append(fileName).append('\'');
		sb.append(", action=").append(action);
		sb.append(", size=").append(size);
		sb.append(", uploadTimestamp=").append(uploadTimestamp);
		sb.append('}');
		return sb.toString();
	}
}

@@ -57,16 +57,92 @@
 bject;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Iterator;%0Aimport java.util.Map;%0A%0A
 import s
@@ -164,16 +164,16 @@
 Action;%0A
-
 import s
@@ -330,16 +330,131 @@
 leName;%0A
+%09private final Long contentLength;%0A%09private final String contentSha1;%0A%09private final Map%3CString, Object%3E fileInfo;%0A
 %09private
@@ -795,16 +795,500 @@
 E_NAME);
+%0A%09%09this.contentLength = response.optLong(B2ResponseProperties.KEY_CONTENT_LENGTH);%0A%09%09this.contentSha1 = response.optString(B2ResponseProperties.KEY_CONTENT_SHA1);%0A%09%09this.fileInfo = new HashMap%3C%3E();%0A%09%09JSONObject fileInfoObject = response.optJSONObject(B2ResponseProperties.KEY_FILE_INFO);%0A%09%09if(null != fileInfoObject) %7B%0A%09%09%09Iterator keys = fileInfoObject.keys();%0A%09%09%09while (keys.hasNext()) %7B%0A%09%09%09%09String key = (String) keys.next();%0A%09%09%09%09fileInfo.put(key, fileInfoObject.opt(key));%0A%09%09%09%7D%0A%09%09%7D
 %0A%0A%09%09Stri
@@ -1784,24 +1784,216 @@
 fileName; %7D%0A
+%09public long getContentLength() %7B return this.contentLength; %7D%0A%09public String getContentSha1() %7B return this.contentSha1; %7D%0A%09public Map%3CString, Object%3E getFileInfo() %7B return this.fileInfo; %7D%0A
 %09public Acti
@@ -2296,32 +2296,32 @@
 ).append('%5C'');%0A
-
 %09%09sb.append(%22, f
@@ -2355,32 +2355,197 @@
 ).append('%5C'');%0A
+%09%09sb.append(%22, contentLength=%22).append(contentLength);%0A%09%09sb.append(%22, contentSha1='%22).append(contentSha1).append('%5C'');%0A%09%09sb.append(%22, fileInfo=%22).append(fileInfo);%0A
 %09%09sb.append(%22, a

Add new supported properties for b2_list_file_versions and b2_list_file_names response.