Skip to content

Commit 8affe97

Browse files
authored
Merge pull request #1 from flackonInc/new_apis
Add new APIs
2 parents c8f8140 + 1f5091c commit 8affe97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1234
-616
lines changed

api/core/OpenAPI.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* istanbul ignore file */
22
/* tslint:disable */
33
/* eslint-disable */
4-
type Resolver<T> = () => Promise<T>;
4+
import type { ApiRequestOptions } from './ApiRequestOptions';
5+
6+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
57
type Headers = Record<string, string>;
68

79
type Config = {

api/core/request.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
/* istanbul ignore file */
22
/* tslint:disable */
33
/* eslint-disable */
4-
import FormData from 'form-data';
5-
import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch';
6-
import { types } from 'util';
7-
84
import { ApiError } from './ApiError';
95
import type { ApiRequestOptions } from './ApiRequestOptions';
106
import type { ApiResult } from './ApiResult';
@@ -22,11 +18,8 @@ function isStringWithValue(value: any): value is string {
2218
return isString(value) && value !== '';
2319
}
2420

25-
function isBinary(value: any): value is Buffer | ArrayBuffer | ArrayBufferView {
26-
const isBuffer = Buffer.isBuffer(value);
27-
const isArrayBuffer = types.isArrayBuffer(value);
28-
const isArrayBufferView = types.isArrayBufferView(value);
29-
return isBuffer || isArrayBuffer || isArrayBufferView;
21+
function isBlob(value: any): value is Blob {
22+
return value instanceof Blob;
3023
}
3124

3225
function getQueryString(params: Record<string, any>): string {
@@ -70,38 +63,39 @@ function getFormData(params: Record<string, any>): FormData {
7063
return formData;
7164
}
7265

73-
type Resolver<T> = () => Promise<T>;
66+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
7467

75-
async function resolve<T>(resolver?: T | Resolver<T>): Promise<T | undefined> {
68+
async function resolve<T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> {
7669
if (typeof resolver === 'function') {
77-
return (resolver as Resolver<T>)();
70+
return (resolver as Resolver<T>)(options);
7871
}
7972
return resolver;
8073
}
8174

8275
async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
76+
const token = await resolve(options, OpenAPI.TOKEN);
77+
const username = await resolve(options, OpenAPI.USERNAME);
78+
const password = await resolve(options, OpenAPI.PASSWORD);
79+
const defaultHeaders = await resolve(options, OpenAPI.HEADERS);
80+
8381
const headers = new Headers({
8482
Accept: 'application/json',
85-
...OpenAPI.HEADERS,
83+
...defaultHeaders,
8684
...options.headers,
8785
});
8886

89-
const token = await resolve(OpenAPI.TOKEN);
90-
const username = await resolve(OpenAPI.USERNAME);
91-
const password = await resolve(OpenAPI.PASSWORD);
92-
9387
if (isStringWithValue(token)) {
9488
headers.append('Authorization', `Bearer ${token}`);
9589
}
9690

9791
if (isStringWithValue(username) && isStringWithValue(password)) {
98-
const credentials = Buffer.from(`${username}:${password}`).toString('base64');
92+
const credentials = btoa(`${username}:${password}`);
9993
headers.append('Authorization', `Basic ${credentials}`);
10094
}
10195

10296
if (options.body) {
103-
if (isBinary(options.body)) {
104-
headers.append('Content-Type', 'application/octet-stream');
97+
if (isBlob(options.body)) {
98+
headers.append('Content-Type', options.body.type || 'application/octet-stream');
10599
} else if (isString(options.body)) {
106100
headers.append('Content-Type', 'text/plain');
107101
} else {
@@ -116,7 +110,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
116110
return getFormData(options.formData);
117111
}
118112
if (options.body) {
119-
if (isString(options.body) || isBinary(options.body)) {
113+
if (isString(options.body) || isBlob(options.body)) {
120114
return options.body;
121115
} else {
122116
return JSON.stringify(options.body);
@@ -131,6 +125,9 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
131125
headers: await getHeaders(options),
132126
body: getRequestBody(options),
133127
};
128+
if (OpenAPI.WITH_CREDENTIALS) {
129+
request.credentials = 'include';
130+
}
134131
return await fetch(url, request);
135132
}
136133

@@ -184,7 +181,7 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void {
184181
}
185182

186183
/**
187-
* Request using node-fetch client
184+
* Request using fetch client
188185
* @param options The request options from the the service
189186
* @returns ApiResult
190187
* @throws ApiError

api/index.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,46 @@
44
export { ApiError } from './core/ApiError';
55
export { OpenAPI } from './core/OpenAPI';
66

7-
export type { BatchProcess } from './models/BatchProcess';
8-
export { BatchProcessStatusEnum } from './models/BatchProcessStatusEnum';
9-
export type { BatchProcessTask } from './models/BatchProcessTask';
10-
export { BatchProcessTaskStatusEnum } from './models/BatchProcessTaskStatusEnum';
11-
export type { Delivery } from './models/Delivery';
12-
export type { DeliveryAccount } from './models/DeliveryAccount';
7+
export type { AttachmentsConfig } from './models/AttachmentsConfig';
8+
export type { BannerNotification } from './models/BannerNotification';
9+
export type { BannerNotificationAction } from './models/BannerNotificationAction';
10+
export { BatchProcess } from './models/BatchProcess';
11+
export { BatchProcessTask } from './models/BatchProcessTask';
12+
export type { BulkGenerateMeta } from './models/BulkGenerateMeta';
13+
export { ChildTemplate } from './models/ChildTemplate';
14+
export { Delivery } from './models/Delivery';
15+
export { DeliveryAccount } from './models/DeliveryAccount';
1316
export type { DocumentMergeLink } from './models/DocumentMergeLink';
14-
export type { FileInfo } from './models/FileInfo';
17+
export type { File } from './models/File';
18+
export type { FileUploadMeta } from './models/FileUploadMeta';
19+
export type { FillablePdfSettings } from './models/FillablePdfSettings';
1520
export type { Folder } from './models/Folder';
16-
export type { MergeHistory } from './models/MergeHistory';
17-
export { MergeHistoryStatusEnum } from './models/MergeHistoryStatusEnum';
18-
export { MergeTypeEnum } from './models/MergeTypeEnum';
21+
export { MergeHistory } from './models/MergeHistory';
22+
export type { Meta } from './models/Meta';
1923
export type { Organization } from './models/Organization';
2024
export type { PaginatedBatchProcessList } from './models/PaginatedBatchProcessList';
21-
export type { PaginatedDeliveryAccountList } from './models/PaginatedDeliveryAccountList';
2225
export type { PaginatedDeliveryList } from './models/PaginatedDeliveryList';
2326
export type { PaginatedDocumentMergeLinkList } from './models/PaginatedDocumentMergeLinkList';
24-
export type { PaginatedFolderList } from './models/PaginatedFolderList';
2527
export type { PaginatedMergeHistoryList } from './models/PaginatedMergeHistoryList';
2628
export type { PaginatedTemplateList } from './models/PaginatedTemplateList';
27-
export type { Template } from './models/Template';
28-
export { TypeEnum } from './models/TypeEnum';
29-
export type { User } from './models/User';
29+
export { Plan } from './models/Plan';
30+
export type { SubscriptionMeta } from './models/SubscriptionMeta';
31+
export { Template } from './models/Template';
32+
export { TemplateSettings } from './models/TemplateSettings';
33+
export type { Timezone } from './models/Timezone';
34+
export { UpdateDeliveryAccount } from './models/UpdateDeliveryAccount';
35+
export { UpdateTemplate } from './models/UpdateTemplate';
36+
export { User } from './models/User';
37+
export type { UserPersonalization } from './models/UserPersonalization';
3038

31-
export { AccountsService } from './services/AccountsService';
39+
export { FilesService } from './services/FilesService';
3240
export { FoldersService } from './services/FoldersService';
41+
export { GeneralService } from './services/GeneralService';
42+
export { GenerateBulkService } from './services/GenerateBulkService';
43+
export { GenerateService } from './services/GenerateService';
3344
export { HistoryService } from './services/HistoryService';
3445
export { LinkedAccountsService } from './services/LinkedAccountsService';
46+
export { PersonalizationService } from './services/PersonalizationService';
47+
export { TemplateDeliveryService } from './services/TemplateDeliveryService';
3548
export { TemplatesService } from './services/TemplatesService';
49+
export { UsersService } from './services/UsersService';

api/models/AttachmentsConfig.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* istanbul ignore file */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
5+
export type AttachmentsConfig = {
6+
allowed_types: string;
7+
max_files: number;
8+
max_total_size: number;
9+
}

api/models/BannerNotification.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* istanbul ignore file */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
5+
import type { BannerNotificationAction } from './BannerNotificationAction';
6+
7+
export type BannerNotification = {
8+
id: string;
9+
content: string;
10+
action: BannerNotificationAction;
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* istanbul ignore file */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
5+
export type BannerNotificationAction = {
6+
text: string;
7+
attributes: Record<string, any>;
8+
}

api/models/BatchProcess.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22
/* tslint:disable */
33
/* eslint-disable */
44

5-
import type { BatchProcessStatusEnum } from './BatchProcessStatusEnum';
65
import type { BatchProcessTask } from './BatchProcessTask';
7-
import type { FileInfo } from './FileInfo';
86

97
export type BatchProcess = {
108
readonly id: number;
11-
file: FileInfo;
9+
file: Blob;
1210
readonly errors: Array<BatchProcessTask>;
13-
status?: (BatchProcessStatusEnum);
11+
status?: BatchProcess.status;
1412
start_time?: string | null;
1513
end_time?: string | null;
1614
total?: number | null;
1715
success?: number | null;
1816
}
17+
18+
export namespace BatchProcess {
19+
20+
export enum status {
21+
'_0' = 0,
22+
'_1' = 1,
23+
'_2' = 2,
24+
'_3' = 3,
25+
'_4' = 4,
26+
'_5' = 5,
27+
}
28+
29+
30+
}

api/models/BatchProcessStatusEnum.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

api/models/BatchProcessTask.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,28 @@
22
/* tslint:disable */
33
/* eslint-disable */
44

5-
import type { BatchProcessTaskStatusEnum } from './BatchProcessTaskStatusEnum';
6-
import type { MergeTypeEnum } from './MergeTypeEnum';
7-
85
export type BatchProcessTask = {
96
readonly id: number;
10-
merge_type?: MergeTypeEnum;
7+
merge_type?: BatchProcessTask.merge_type;
118
merge_data?: Record<string, any> | null;
12-
status?: (BatchProcessTaskStatusEnum);
9+
status?: BatchProcessTask.status;
1310
status_message?: string | null;
1411
batch_process: number;
1512
document: number;
1613
}
14+
15+
export namespace BatchProcessTask {
16+
17+
export enum merge_type {
18+
ACTIVE = 'active',
19+
TEST = 'test',
20+
}
21+
22+
export enum status {
23+
'_0' = 0,
24+
'_1' = 1,
25+
'_2' = 2,
26+
}
27+
28+
29+
}

api/models/BatchProcessTaskStatusEnum.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)