-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZuoraGenerateQuotePdfController.cls
55 lines (46 loc) · 1.59 KB
/
ZuoraGenerateQuotePdfController.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
public class ZuoraGenerateQuotePdfController
{
public Id quoteId { get; set; }
public String status { get; private set; }
public String errorMessage { get; private set; }
public String zuoraPdfUrl { get; private set; }
private final ILog m_Log;
private final ZuoraQuoteDocumentUtil m_docUtil;
public ZuoraGenerateQuotePdfController()
{
m_Log = LogFactory.CreateDefaultLog();
m_Log.debug('ZuoraGenerateQuotePdfController()');
m_docUtil = new ZuoraQuoteDocumentUtil( new ZuoraApiRequestSender(), m_Log );
status = 'initialized';
}
public PageReference generatePdf()
{
m_Log.debug('Will generate for ' + quoteId);
try
{
zuoraPdfUrl = m_docUtil.generatePdfForQuote(quoteId);
status = 'generated';
}
catch( Exception ex )
{
m_Log.error('Exception getting JSON ' + ex.getMessage());
errorMessage = 'There was an error generating the PDF. ' + ex.getMessage();
}
return null; // Re-render same page
}
public PageReference downloadPdf()
{
m_Log.debug('Will download ' + zuoraPdfUrl);
try
{
m_docUtil.downloadPdfUrlAndAttachToQuote(zuoraPdfUrl, quoteId);
status = 'downloaded';
}
catch( Exception ex )
{
m_Log.error('Exception downloading PDF ' + ex.getMessage());
errorMessage = 'There was an error downloading the PDF. ' + ex.getMessage();
}
return null;
}
}