Skip to content

Commit f4fc2be

Browse files
authored
Merge pull request #7 from Doczilla-APP/improvements
Improvements
2 parents 02f4f05 + f1fd96c commit f4fc2be

18 files changed

+106
-20
lines changed

src/__tests__/pdf.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,27 @@ describe('PDF', () => {
1111

1212
axiosMock.onAny().reply(200, Buffer.from(''))
1313

14-
test('it should encode the pdf.headerTemplate and pdf.footerTemplate options', async () => {
14+
test('it should encode the page.html, page.htmlTemplate, pdf.headerHtml and pdf.footerHtml options', async () => {
1515
await client.pdf.direct({
1616
page: {
17-
html: '<div>Your first Doczilla PDF</div>'
17+
html: '<div>Your first Doczilla PDF</div>',
18+
htmlTemplate: '<div>Your first Doczilla {{ type }}</div>',
1819
},
1920
pdf: {
20-
headerTemplate: '<div>Header template</div>',
21-
footerTemplate: '<div>Footer template</div>'
21+
headerHtml: '<div>Header template</div>',
22+
footerHtml: '<div>Footer template</div>'
2223
}
2324
})
2425

2526
expect(axiosMock.history.post.length).toBe(1)
2627
expect(axiosMock.history.post[0].data).toEqual(JSON.stringify({
2728
page: {
28-
html: 'PGRpdj5Zb3VyIGZpcnN0IERvY3ppbGxhIFBERjwvZGl2Pg=='
29+
html: 'PGRpdj5Zb3VyIGZpcnN0IERvY3ppbGxhIFBERjwvZGl2Pg==',
30+
htmlTemplate: 'PGRpdj5Zb3VyIGZpcnN0IERvY3ppbGxhIHt7IHR5cGUgfX08L2Rpdj4='
2931
},
3032
pdf: {
31-
headerTemplate: 'PGRpdj5IZWFkZXIgdGVtcGxhdGU8L2Rpdj4=',
32-
footerTemplate: 'PGRpdj5Gb290ZXIgdGVtcGxhdGU8L2Rpdj4='
33+
headerHtml: 'PGRpdj5IZWFkZXIgdGVtcGxhdGU8L2Rpdj4=',
34+
footerHtml: 'PGRpdj5Gb290ZXIgdGVtcGxhdGU8L2Rpdj4='
3335
}
3436
}))
3537
})

src/generated/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@
66
export { AsyncJob } from './models/AsyncJob';
77
export type { AsyncPdf } from './models/AsyncPdf';
88
export type { AsyncScreenshot } from './models/AsyncScreenshot';
9+
export type { BadRequestResponse } from './models/BadRequestResponse';
910
export type { CreatePdf } from './models/CreatePdf';
1011
export type { CreateScreenshot } from './models/CreateScreenshot';
12+
export type { ForbiddenResponse } from './models/ForbiddenResponse';
13+
export type { InternalServerErrorResponse } from './models/InternalServerErrorResponse';
1114
export type { PageAuthentication } from './models/PageAuthentication';
1215
export { PageCookie } from './models/PageCookie';
1316
export { PageOptions } from './models/PageOptions';
17+
export type { PayloadTooLargeResponse } from './models/PayloadTooLargeResponse';
1418
export type { PDFMargin } from './models/PDFMargin';
1519
export { PdfOptions } from './models/PdfOptions';
1620
export type { ScreenshotClip } from './models/ScreenshotClip';
1721
export { ScreenshotOptions } from './models/ScreenshotOptions';
1822
export { ScreenshotOverlay } from './models/ScreenshotOverlay';
1923
export type { ScreenshotViewport } from './models/ScreenshotViewport';
2024
export type { StorageOptions } from './models/StorageOptions';
25+
export type { SubscriptionLimitReachedResponse } from './models/SubscriptionLimitReachedResponse';
2126
export { SyncJob } from './models/SyncJob';
2227
export type { SyncPdf } from './models/SyncPdf';
2328
export type { SyncScreenshot } from './models/SyncScreenshot';
29+
export type { TooManyRequestsResponse } from './models/TooManyRequestsResponse';
30+
export type { UnauthorizedResponse } from './models/UnauthorizedResponse';
2431
export { WebhookEvent } from './models/WebhookEvent';
2532
export { WebhookOptions } from './models/WebhookOptions';

src/generated/models/AsyncPdf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { WebhookOptions } from './WebhookOptions';
1010

1111
export type AsyncPdf = {
1212
/**
13-
* Page options, either provide the `url` or `html` option.
13+
* Page options, either provide the `url`, `html` or `htmlTemplate` option.
1414
*/
1515
page: PageOptions;
1616
pdf?: PdfOptions | null;

src/generated/models/AsyncScreenshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { WebhookOptions } from './WebhookOptions';
1010

1111
export type AsyncScreenshot = {
1212
/**
13-
* Page options, either provide the `url` or `html` option.
13+
* Page options, either provide the `url`, `html` or `htmlTemplate` option.
1414
*/
1515
page: PageOptions;
1616
screenshot?: ScreenshotOptions | null;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
6+
export type BadRequestResponse = {
7+
message: string;
8+
code: string;
9+
fields: Record<string, string>;
10+
};
11+

src/generated/models/CreatePdf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { PdfOptions } from './PdfOptions';
88

99
export type CreatePdf = {
1010
/**
11-
* Page options, either provide the `url` or `html` option.
11+
* Page options, either provide the `url`, `html` or `htmlTemplate` option.
1212
*/
1313
page: PageOptions;
1414
pdf?: PdfOptions | null;

src/generated/models/CreateScreenshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { ScreenshotOptions } from './ScreenshotOptions';
88

99
export type CreateScreenshot = {
1010
/**
11-
* Page options, either provide the `url` or `html` option.
11+
* Page options, either provide the `url`, `html` or `htmlTemplate` option.
1212
*/
1313
page: PageOptions;
1414
screenshot?: ScreenshotOptions | null;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
6+
export type ForbiddenResponse = {
7+
message: string;
8+
};
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
6+
export type InternalServerErrorResponse = {
7+
message: string;
8+
};
9+

src/generated/models/PageOptions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export type PageOptions = {
1515
* HTML to render. Needs to be base64 encoded!
1616
*/
1717
html?: string | null;
18+
/**
19+
* HTML template to render. Needs to be base64 encoded!
20+
*/
21+
htmlTemplate?: string | null;
22+
/**
23+
* Template data, only used in combination with `page.htmlTemplate`.
24+
*/
25+
templateData?: Record<string, any> | null;
1826
/**
1927
* When to consider waiting succeeds.
2028
* - `auto` our smart waiting option that can handle 90% of the cases.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
6+
export type PayloadTooLargeResponse = {
7+
message: string;
8+
};
9+

src/generated/models/PdfOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export type PdfOptions = {
2222
* - `pageNumber` current page number
2323
* - `totalPages` total pages in the document
2424
*/
25-
headerTemplate?: string | null;
25+
headerHtml?: string | null;
2626
/**
27-
* HTML template for the print footer. Has the same constraints and support for special classes as `headerTemplate`.
27+
* HTML template for the print footer. Has the same constraints and support for special classes as `headerHtml`.
2828
*/
29-
footerTemplate?: string | null;
29+
footerHtml?: string | null;
3030
/**
3131
* Set to `true` to print background graphics.
3232
*/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
6+
export type SubscriptionLimitReachedResponse = {
7+
message: string;
8+
};
9+

src/generated/models/SyncPdf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { StorageOptions } from './StorageOptions';
99

1010
export type SyncPdf = {
1111
/**
12-
* Page options, either provide the `url` or `html` option.
12+
* Page options, either provide the `url`, `html` or `htmlTemplate` option.
1313
*/
1414
page: PageOptions;
1515
pdf?: PdfOptions | null;

src/generated/models/SyncScreenshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { StorageOptions } from './StorageOptions';
99

1010
export type SyncScreenshot = {
1111
/**
12-
* Page options, either provide the `url` or `html` option.
12+
* Page options, either provide the `url`, `html` or `htmlTemplate` option.
1313
*/
1414
page: PageOptions;
1515
screenshot?: ScreenshotOptions | null;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
6+
export type TooManyRequestsResponse = {
7+
message: string;
8+
};
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
6+
export type UnauthorizedResponse = {
7+
message: string;
8+
};
9+

src/services/BaseService.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ export class BaseService {
4848
requestBody.page.html = this.baseEncodeContent(requestBody.page.html)
4949
}
5050

51-
if (requestBody.pdf?.headerTemplate) {
52-
requestBody.pdf.headerTemplate = this.baseEncodeContent(requestBody.pdf.headerTemplate)
51+
if (requestBody.page.htmlTemplate) {
52+
requestBody.page.htmlTemplate = this.baseEncodeContent(requestBody.page.htmlTemplate)
5353
}
5454

55-
if (requestBody.pdf?.footerTemplate) {
56-
requestBody.pdf.footerTemplate = this.baseEncodeContent(requestBody.pdf.footerTemplate)
55+
if (requestBody.pdf?.headerHtml) {
56+
requestBody.pdf.headerHtml = this.baseEncodeContent(requestBody.pdf.headerHtml)
57+
}
58+
59+
if (requestBody.pdf?.footerHtml) {
60+
requestBody.pdf.footerHtml = this.baseEncodeContent(requestBody.pdf.footerHtml)
5761
}
5862

5963
return requestBody

0 commit comments

Comments
 (0)