60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
namespace PWAPPv2.Source.DataObjects
|
|
{
|
|
public class Attachment
|
|
{
|
|
APICredentials Credentials;
|
|
public PWImage image { get; set; }
|
|
public PWPdf pdf { get; set; }
|
|
public string Token;
|
|
|
|
private string fileType { get; set; }
|
|
|
|
public Attachment(APICredentials credentials, PWImage pwImage)
|
|
{
|
|
Credentials = credentials;
|
|
image = pwImage;
|
|
//Token = token;
|
|
pdf = null;
|
|
fileType = "image/jpeg";
|
|
}
|
|
|
|
public Attachment(APICredentials credentials, PWPdf pwPdf)
|
|
{
|
|
Credentials = credentials;
|
|
pdf = pwPdf;
|
|
image = null;
|
|
fileType = "application/pdf";
|
|
}
|
|
|
|
public string ToJsonString()
|
|
{
|
|
if (image != null)
|
|
{
|
|
return "\"{" + Credentials.BuildJsonBodyContents() +
|
|
",'UserNum':'API'," +
|
|
"'AttToken':'" + Token.Replace("\"", "") + "'," +
|
|
"'FileName':'" + image.ShortFileName() + "'," +
|
|
"'ThumbExists':'1'," +
|
|
"'ZoomExists':'1'," +
|
|
"'FileDate':''," +
|
|
"'FileType':'" + image.FileType + "'," +
|
|
image.GetJsonContents() + "}\"";
|
|
}
|
|
else
|
|
{
|
|
return "\"{" + Credentials.BuildJsonBodyContents() +
|
|
",'UserNum':'API'," +
|
|
"'AttToken':'" + Token.Replace("\"", "") + "'," +
|
|
"'FileName':'" + pdf.ShortFileName() + "'," +
|
|
"'ThumbExists':'0'," +
|
|
"'ZoomExists':'0'," +
|
|
"'FileDate':''," +
|
|
"'FileType':'" + fileType + "'," +
|
|
"'Base64FileContents':'" + pdf.GetBase64String() + "',\n" +
|
|
"'Base64ThumbContents':'',\n" +
|
|
"'Base64ZoomContents':''}\"";
|
|
}
|
|
}
|
|
}
|
|
}
|