diff --git a/src/__tests__/pdf.spec.ts b/src/__tests__/pdf.spec.ts index bf287c7..693d77d 100644 --- a/src/__tests__/pdf.spec.ts +++ b/src/__tests__/pdf.spec.ts @@ -11,25 +11,27 @@ describe('PDF', () => { axiosMock.onAny().reply(200, Buffer.from('')) - test('it should encode the pdf.headerTemplate and pdf.footerTemplate options', async () => { + test('it should encode the page.html, page.htmlTemplate, pdf.headerHtml and pdf.footerHtml options', async () => { await client.pdf.direct({ page: { - html: '
Your first Doczilla PDF
' + html: '
Your first Doczilla PDF
', + htmlTemplate: '
Your first Doczilla {{ type }}
', }, pdf: { - headerTemplate: '
Header template
', - footerTemplate: '
Footer template
' + headerHtml: '
Header template
', + footerHtml: '
Footer template
' } }) expect(axiosMock.history.post.length).toBe(1) expect(axiosMock.history.post[0].data).toEqual(JSON.stringify({ page: { - html: 'PGRpdj5Zb3VyIGZpcnN0IERvY3ppbGxhIFBERjwvZGl2Pg==' + html: 'PGRpdj5Zb3VyIGZpcnN0IERvY3ppbGxhIFBERjwvZGl2Pg==', + htmlTemplate: 'PGRpdj5Zb3VyIGZpcnN0IERvY3ppbGxhIHt7IHR5cGUgfX08L2Rpdj4=' }, pdf: { - headerTemplate: 'PGRpdj5IZWFkZXIgdGVtcGxhdGU8L2Rpdj4=', - footerTemplate: 'PGRpdj5Gb290ZXIgdGVtcGxhdGU8L2Rpdj4=' + headerHtml: 'PGRpdj5IZWFkZXIgdGVtcGxhdGU8L2Rpdj4=', + footerHtml: 'PGRpdj5Gb290ZXIgdGVtcGxhdGU8L2Rpdj4=' } })) }) diff --git a/src/generated/index.ts b/src/generated/index.ts index afbd329..0ed2660 100644 --- a/src/generated/index.ts +++ b/src/generated/index.ts @@ -6,11 +6,15 @@ export { AsyncJob } from './models/AsyncJob'; export type { AsyncPdf } from './models/AsyncPdf'; export type { AsyncScreenshot } from './models/AsyncScreenshot'; +export type { BadRequestResponse } from './models/BadRequestResponse'; export type { CreatePdf } from './models/CreatePdf'; export type { CreateScreenshot } from './models/CreateScreenshot'; +export type { ForbiddenResponse } from './models/ForbiddenResponse'; +export type { InternalServerErrorResponse } from './models/InternalServerErrorResponse'; export type { PageAuthentication } from './models/PageAuthentication'; export { PageCookie } from './models/PageCookie'; export { PageOptions } from './models/PageOptions'; +export type { PayloadTooLargeResponse } from './models/PayloadTooLargeResponse'; export type { PDFMargin } from './models/PDFMargin'; export { PdfOptions } from './models/PdfOptions'; export type { ScreenshotClip } from './models/ScreenshotClip'; @@ -18,8 +22,11 @@ export { ScreenshotOptions } from './models/ScreenshotOptions'; export { ScreenshotOverlay } from './models/ScreenshotOverlay'; export type { ScreenshotViewport } from './models/ScreenshotViewport'; export type { StorageOptions } from './models/StorageOptions'; +export type { SubscriptionLimitReachedResponse } from './models/SubscriptionLimitReachedResponse'; export { SyncJob } from './models/SyncJob'; export type { SyncPdf } from './models/SyncPdf'; export type { SyncScreenshot } from './models/SyncScreenshot'; +export type { TooManyRequestsResponse } from './models/TooManyRequestsResponse'; +export type { UnauthorizedResponse } from './models/UnauthorizedResponse'; export { WebhookEvent } from './models/WebhookEvent'; export { WebhookOptions } from './models/WebhookOptions'; diff --git a/src/generated/models/AsyncPdf.ts b/src/generated/models/AsyncPdf.ts index bc1459c..050ec5a 100644 --- a/src/generated/models/AsyncPdf.ts +++ b/src/generated/models/AsyncPdf.ts @@ -10,7 +10,7 @@ import type { WebhookOptions } from './WebhookOptions'; export type AsyncPdf = { /** - * Page options, either provide the `url` or `html` option. + * Page options, either provide the `url`, `html` or `htmlTemplate` option. */ page: PageOptions; pdf?: PdfOptions | null; diff --git a/src/generated/models/AsyncScreenshot.ts b/src/generated/models/AsyncScreenshot.ts index 7633ef0..0603f6e 100644 --- a/src/generated/models/AsyncScreenshot.ts +++ b/src/generated/models/AsyncScreenshot.ts @@ -10,7 +10,7 @@ import type { WebhookOptions } from './WebhookOptions'; export type AsyncScreenshot = { /** - * Page options, either provide the `url` or `html` option. + * Page options, either provide the `url`, `html` or `htmlTemplate` option. */ page: PageOptions; screenshot?: ScreenshotOptions | null; diff --git a/src/generated/models/BadRequestResponse.ts b/src/generated/models/BadRequestResponse.ts new file mode 100644 index 0000000..de7d5da --- /dev/null +++ b/src/generated/models/BadRequestResponse.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type BadRequestResponse = { + message: string; + code: string; + fields: Record; +}; + diff --git a/src/generated/models/CreatePdf.ts b/src/generated/models/CreatePdf.ts index 4474aac..d73b244 100644 --- a/src/generated/models/CreatePdf.ts +++ b/src/generated/models/CreatePdf.ts @@ -8,7 +8,7 @@ import type { PdfOptions } from './PdfOptions'; export type CreatePdf = { /** - * Page options, either provide the `url` or `html` option. + * Page options, either provide the `url`, `html` or `htmlTemplate` option. */ page: PageOptions; pdf?: PdfOptions | null; diff --git a/src/generated/models/CreateScreenshot.ts b/src/generated/models/CreateScreenshot.ts index 5a83a41..b798518 100644 --- a/src/generated/models/CreateScreenshot.ts +++ b/src/generated/models/CreateScreenshot.ts @@ -8,7 +8,7 @@ import type { ScreenshotOptions } from './ScreenshotOptions'; export type CreateScreenshot = { /** - * Page options, either provide the `url` or `html` option. + * Page options, either provide the `url`, `html` or `htmlTemplate` option. */ page: PageOptions; screenshot?: ScreenshotOptions | null; diff --git a/src/generated/models/ForbiddenResponse.ts b/src/generated/models/ForbiddenResponse.ts new file mode 100644 index 0000000..390cde2 --- /dev/null +++ b/src/generated/models/ForbiddenResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type ForbiddenResponse = { + message: string; +}; + diff --git a/src/generated/models/InternalServerErrorResponse.ts b/src/generated/models/InternalServerErrorResponse.ts new file mode 100644 index 0000000..3c21fa8 --- /dev/null +++ b/src/generated/models/InternalServerErrorResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type InternalServerErrorResponse = { + message: string; +}; + diff --git a/src/generated/models/PageOptions.ts b/src/generated/models/PageOptions.ts index f03cbae..db03bdc 100644 --- a/src/generated/models/PageOptions.ts +++ b/src/generated/models/PageOptions.ts @@ -15,6 +15,14 @@ export type PageOptions = { * HTML to render. Needs to be base64 encoded! */ html?: string | null; + /** + * HTML template to render. Needs to be base64 encoded! + */ + htmlTemplate?: string | null; + /** + * Template data, only used in combination with `page.htmlTemplate`. + */ + templateData?: Record | null; /** * When to consider waiting succeeds. * - `auto` our smart waiting option that can handle 90% of the cases. diff --git a/src/generated/models/PayloadTooLargeResponse.ts b/src/generated/models/PayloadTooLargeResponse.ts new file mode 100644 index 0000000..79a3237 --- /dev/null +++ b/src/generated/models/PayloadTooLargeResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type PayloadTooLargeResponse = { + message: string; +}; + diff --git a/src/generated/models/PdfOptions.ts b/src/generated/models/PdfOptions.ts index afe6072..6f93e9d 100644 --- a/src/generated/models/PdfOptions.ts +++ b/src/generated/models/PdfOptions.ts @@ -22,11 +22,11 @@ export type PdfOptions = { * - `pageNumber` current page number * - `totalPages` total pages in the document */ - headerTemplate?: string | null; + headerHtml?: string | null; /** - * HTML template for the print footer. Has the same constraints and support for special classes as `headerTemplate`. + * HTML template for the print footer. Has the same constraints and support for special classes as `headerHtml`. */ - footerTemplate?: string | null; + footerHtml?: string | null; /** * Set to `true` to print background graphics. */ diff --git a/src/generated/models/SubscriptionLimitReachedResponse.ts b/src/generated/models/SubscriptionLimitReachedResponse.ts new file mode 100644 index 0000000..c31d94a --- /dev/null +++ b/src/generated/models/SubscriptionLimitReachedResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type SubscriptionLimitReachedResponse = { + message: string; +}; + diff --git a/src/generated/models/SyncPdf.ts b/src/generated/models/SyncPdf.ts index ec23b55..82fb9ab 100644 --- a/src/generated/models/SyncPdf.ts +++ b/src/generated/models/SyncPdf.ts @@ -9,7 +9,7 @@ import type { StorageOptions } from './StorageOptions'; export type SyncPdf = { /** - * Page options, either provide the `url` or `html` option. + * Page options, either provide the `url`, `html` or `htmlTemplate` option. */ page: PageOptions; pdf?: PdfOptions | null; diff --git a/src/generated/models/SyncScreenshot.ts b/src/generated/models/SyncScreenshot.ts index f8fefa4..6475049 100644 --- a/src/generated/models/SyncScreenshot.ts +++ b/src/generated/models/SyncScreenshot.ts @@ -9,7 +9,7 @@ import type { StorageOptions } from './StorageOptions'; export type SyncScreenshot = { /** - * Page options, either provide the `url` or `html` option. + * Page options, either provide the `url`, `html` or `htmlTemplate` option. */ page: PageOptions; screenshot?: ScreenshotOptions | null; diff --git a/src/generated/models/TooManyRequestsResponse.ts b/src/generated/models/TooManyRequestsResponse.ts new file mode 100644 index 0000000..58dce09 --- /dev/null +++ b/src/generated/models/TooManyRequestsResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type TooManyRequestsResponse = { + message: string; +}; + diff --git a/src/generated/models/UnauthorizedResponse.ts b/src/generated/models/UnauthorizedResponse.ts new file mode 100644 index 0000000..dfbcd93 --- /dev/null +++ b/src/generated/models/UnauthorizedResponse.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type UnauthorizedResponse = { + message: string; +}; + diff --git a/src/services/BaseService.ts b/src/services/BaseService.ts index 8860bf0..16ef1d9 100644 --- a/src/services/BaseService.ts +++ b/src/services/BaseService.ts @@ -48,12 +48,16 @@ export class BaseService { requestBody.page.html = this.baseEncodeContent(requestBody.page.html) } - if (requestBody.pdf?.headerTemplate) { - requestBody.pdf.headerTemplate = this.baseEncodeContent(requestBody.pdf.headerTemplate) + if (requestBody.page.htmlTemplate) { + requestBody.page.htmlTemplate = this.baseEncodeContent(requestBody.page.htmlTemplate) } - if (requestBody.pdf?.footerTemplate) { - requestBody.pdf.footerTemplate = this.baseEncodeContent(requestBody.pdf.footerTemplate) + if (requestBody.pdf?.headerHtml) { + requestBody.pdf.headerHtml = this.baseEncodeContent(requestBody.pdf.headerHtml) + } + + if (requestBody.pdf?.footerHtml) { + requestBody.pdf.footerHtml = this.baseEncodeContent(requestBody.pdf.footerHtml) } return requestBody