@brifle/brifle-sdk 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README +6 -0
- package/dist/cjs/api/api.d.ts +30 -0
- package/dist/cjs/endpoints/v1/apiResponse.d.ts +42 -0
- package/dist/cjs/endpoints/v1/authentication.d.ts +23 -0
- package/dist/cjs/endpoints/v1/content.d.ts +42 -0
- package/dist/cjs/endpoints/v1/requests/authentication.d.ts +7 -0
- package/dist/cjs/endpoints/v1/requests/content.d.ts +50 -0
- package/dist/cjs/endpoints/v1/requests/signatures.d.ts +8 -0
- package/dist/cjs/endpoints/v1/responses/authentication.d.ts +8 -0
- package/dist/cjs/endpoints/v1/responses/content.d.ts +68 -0
- package/dist/cjs/endpoints/v1/responses/signatures.d.ts +10 -0
- package/dist/cjs/endpoints/v1/signatures.d.ts +30 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +306 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/api/api.d.ts +30 -0
- package/dist/esm/endpoints/v1/apiResponse.d.ts +42 -0
- package/dist/esm/endpoints/v1/authentication.d.ts +23 -0
- package/dist/esm/endpoints/v1/content.d.ts +42 -0
- package/dist/esm/endpoints/v1/requests/authentication.d.ts +7 -0
- package/dist/esm/endpoints/v1/requests/content.d.ts +50 -0
- package/dist/esm/endpoints/v1/requests/signatures.d.ts +8 -0
- package/dist/esm/endpoints/v1/responses/authentication.d.ts +8 -0
- package/dist/esm/endpoints/v1/responses/content.d.ts +68 -0
- package/dist/esm/endpoints/v1/responses/signatures.d.ts +10 -0
- package/dist/esm/endpoints/v1/signatures.d.ts +30 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.mjs +300 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/index.d.ts +309 -0
- package/dist/types/api/api.d.ts +30 -0
- package/dist/types/endpoints/v1/apiResponse.d.ts +42 -0
- package/dist/types/endpoints/v1/authentication.d.ts +23 -0
- package/dist/types/endpoints/v1/content.d.ts +42 -0
- package/dist/types/endpoints/v1/requests/authentication.d.ts +7 -0
- package/dist/types/endpoints/v1/requests/content.d.ts +50 -0
- package/dist/types/endpoints/v1/requests/signatures.d.ts +8 -0
- package/dist/types/endpoints/v1/responses/authentication.d.ts +8 -0
- package/dist/types/endpoints/v1/responses/content.d.ts +68 -0
- package/dist/types/endpoints/v1/responses/signatures.d.ts +10 -0
- package/dist/types/endpoints/v1/signatures.d.ts +30 -0
- package/dist/types/index.d.ts +11 -0
- package/package.json +48 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AuthenticationEndpoints } from "../endpoints/v1/authentication";
|
|
2
|
+
import { ContentEndpoints } from "../endpoints/v1/content";
|
|
3
|
+
import { SignaturesEndpoint } from "../endpoints/v1/signatures";
|
|
4
|
+
declare class ApiV1 {
|
|
5
|
+
readonly endpoint: string;
|
|
6
|
+
readonly apiState: ApiV1State;
|
|
7
|
+
constructor(endpoint: string);
|
|
8
|
+
static get sandbox(): ApiV1;
|
|
9
|
+
static get production(): ApiV1;
|
|
10
|
+
/**
|
|
11
|
+
* gets an instance of the AuthenticationEndpoints
|
|
12
|
+
* @returns AuthenticationEndpoints
|
|
13
|
+
*/
|
|
14
|
+
authentication(): AuthenticationEndpoints;
|
|
15
|
+
/**
|
|
16
|
+
* gets an instance of the ContentEndpoints
|
|
17
|
+
* @returns ContentEndpoints
|
|
18
|
+
*/
|
|
19
|
+
content(): ContentEndpoints;
|
|
20
|
+
/**
|
|
21
|
+
* gets an instance of the SignatureEndpoints
|
|
22
|
+
* @returns ContentEndpoints
|
|
23
|
+
*/
|
|
24
|
+
signature(): SignaturesEndpoint;
|
|
25
|
+
}
|
|
26
|
+
export interface ApiV1State {
|
|
27
|
+
auth_token?: string;
|
|
28
|
+
auth_token_expire_date?: Date;
|
|
29
|
+
}
|
|
30
|
+
export { ApiV1 };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AxiosError } from "axios";
|
|
2
|
+
export declare class ApiResponse<ResponseType> {
|
|
3
|
+
private _data?;
|
|
4
|
+
private _error?;
|
|
5
|
+
private constructor();
|
|
6
|
+
/**
|
|
7
|
+
* create a success response from data
|
|
8
|
+
* @param data - The data to return
|
|
9
|
+
*/
|
|
10
|
+
static success<ResponseType>(data: ResponseType): ApiResponse<ResponseType>;
|
|
11
|
+
/**
|
|
12
|
+
* create an error response from an AxiosError
|
|
13
|
+
* @param error - The AxiosError object
|
|
14
|
+
*/
|
|
15
|
+
static error<ResponseType>(error: ErrorResponse): ApiResponse<ResponseType>;
|
|
16
|
+
/**
|
|
17
|
+
* create an error response from an AxiosError
|
|
18
|
+
* @param error - The AxiosError object
|
|
19
|
+
*/
|
|
20
|
+
static errorAxios<ResponseType>(error: AxiosError): ApiResponse<ResponseType>;
|
|
21
|
+
/**
|
|
22
|
+
* check if the response is a success
|
|
23
|
+
*/
|
|
24
|
+
get isSuccess(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* check if the response is an error
|
|
27
|
+
*/
|
|
28
|
+
get isError(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* get the data from the response
|
|
31
|
+
*/
|
|
32
|
+
get data(): ResponseType | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* get the error from the response
|
|
35
|
+
*/
|
|
36
|
+
get error(): ErrorResponse | undefined;
|
|
37
|
+
}
|
|
38
|
+
export interface ErrorResponse {
|
|
39
|
+
code: number;
|
|
40
|
+
message: string;
|
|
41
|
+
status: number;
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ApiV1 } from "../../api/api";
|
|
2
|
+
import { ApiResponse } from "./apiResponse";
|
|
3
|
+
import { LoginRequest } from "./requests/authentication";
|
|
4
|
+
import { LoginResponse } from "./responses/authentication";
|
|
5
|
+
declare class AuthenticationEndpoints {
|
|
6
|
+
private endpoint;
|
|
7
|
+
private readonly VERSION;
|
|
8
|
+
private state;
|
|
9
|
+
constructor(api: ApiV1);
|
|
10
|
+
/**
|
|
11
|
+
* builds the full path
|
|
12
|
+
* @param path - The path to the endpoint, e.g. "authentication/login"
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
private getPath;
|
|
16
|
+
/**
|
|
17
|
+
* login to the API
|
|
18
|
+
* @param loginRequest - The login request object
|
|
19
|
+
* @returns the login response object
|
|
20
|
+
*/
|
|
21
|
+
login(loginRequest: LoginRequest): Promise<ApiResponse<LoginResponse>>;
|
|
22
|
+
}
|
|
23
|
+
export { AuthenticationEndpoints };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ApiResponse } from "./apiResponse";
|
|
2
|
+
import { CheckReceiverResponse, ContentActionsResponse, ContentResponse, SendContentResponse } from "./responses/content";
|
|
3
|
+
import { ApiV1 } from "../../api/api";
|
|
4
|
+
import { ReceiverRequest, SendContentRequest } from "./requests/content";
|
|
5
|
+
declare class ContentEndpoints {
|
|
6
|
+
private endpoint;
|
|
7
|
+
private readonly VERSION;
|
|
8
|
+
private state;
|
|
9
|
+
constructor(api: ApiV1);
|
|
10
|
+
/**
|
|
11
|
+
* builds the full path
|
|
12
|
+
* @param path - The path to the endpoint, e.g. "authentication/login"
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
private getPath;
|
|
16
|
+
/**
|
|
17
|
+
* get the content of a document
|
|
18
|
+
* @param documentId - The id of the document
|
|
19
|
+
* @returns the content of the document
|
|
20
|
+
*/
|
|
21
|
+
getContent(documentId: string): Promise<ApiResponse<ContentResponse>>;
|
|
22
|
+
/**
|
|
23
|
+
* get the actions of a document
|
|
24
|
+
* @param documentId - The id of the document
|
|
25
|
+
* @returns the actions of the document
|
|
26
|
+
*/
|
|
27
|
+
getContentActions(documentId: string): Promise<ApiResponse<ContentActionsResponse>>;
|
|
28
|
+
/**
|
|
29
|
+
* checks if a receiver is existing in Brifle
|
|
30
|
+
* @param receiver - The receiver object to check
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
checkReceiver(receiver: ReceiverRequest): Promise<ApiResponse<CheckReceiverResponse>>;
|
|
34
|
+
/**
|
|
35
|
+
* send a content to a receiver
|
|
36
|
+
* @param tenantId - The tenant id of the receiver
|
|
37
|
+
* @param request - The request object to send
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
sendContent(tenantId: string, request: SendContentRequest): Promise<ApiResponse<SendContentResponse>>;
|
|
41
|
+
}
|
|
42
|
+
export { ContentEndpoints };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
interface ReceiverRequest {
|
|
2
|
+
account_id?: string;
|
|
3
|
+
birth_information?: BirthInformation;
|
|
4
|
+
email?: string;
|
|
5
|
+
tel?: string;
|
|
6
|
+
vad_id?: string;
|
|
7
|
+
ssn?: string;
|
|
8
|
+
first_name?: string;
|
|
9
|
+
last_name?: string;
|
|
10
|
+
full_name?: string;
|
|
11
|
+
date_of_birth?: string;
|
|
12
|
+
}
|
|
13
|
+
interface BirthInformation {
|
|
14
|
+
birth_name?: string;
|
|
15
|
+
date_of_birth: string;
|
|
16
|
+
place_of_birth: string;
|
|
17
|
+
nationality?: string;
|
|
18
|
+
given_names?: string;
|
|
19
|
+
last_name?: string;
|
|
20
|
+
postaL_address?: string;
|
|
21
|
+
}
|
|
22
|
+
interface PaymentDetails {
|
|
23
|
+
amount: number;
|
|
24
|
+
currency: 'EUR';
|
|
25
|
+
description: string;
|
|
26
|
+
due_date: string;
|
|
27
|
+
iban: string;
|
|
28
|
+
reference: string;
|
|
29
|
+
}
|
|
30
|
+
interface SendContentRequest {
|
|
31
|
+
to: ReceiverRequest;
|
|
32
|
+
type: 'letter' | 'invoice' | 'contract';
|
|
33
|
+
subject: string;
|
|
34
|
+
body: {
|
|
35
|
+
type: 'application/pdf';
|
|
36
|
+
content: string;
|
|
37
|
+
}[];
|
|
38
|
+
payment_info?: {
|
|
39
|
+
details?: PaymentDetails;
|
|
40
|
+
payable: boolean;
|
|
41
|
+
};
|
|
42
|
+
signature_info?: {
|
|
43
|
+
signature_reference: string;
|
|
44
|
+
requesting_signer: {
|
|
45
|
+
field: string;
|
|
46
|
+
signer: 'sender' | 'receiver';
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export type { SendContentRequest, ReceiverRequest, BirthInformation, PaymentDetails };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
interface SendContentResponse {
|
|
2
|
+
id: string;
|
|
3
|
+
}
|
|
4
|
+
interface CheckReceiverResponse {
|
|
5
|
+
receiver: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
interface ContentMeta {
|
|
10
|
+
delivered: boolean;
|
|
11
|
+
delivered_date: string;
|
|
12
|
+
read: boolean;
|
|
13
|
+
read_date: string;
|
|
14
|
+
receiver?: string;
|
|
15
|
+
sender?: string;
|
|
16
|
+
receiver_state?: 'unread' | 'read' | 'archived' | 'trashed' | 'deleted' | 'pending';
|
|
17
|
+
sender_state?: 'activate' | 'activated' | 'trashed' | 'deleted' | 'pending';
|
|
18
|
+
sent_date: string;
|
|
19
|
+
size: number;
|
|
20
|
+
subject: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}
|
|
23
|
+
interface ContentResponse {
|
|
24
|
+
content: {
|
|
25
|
+
content: string;
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
meta: ContentMeta;
|
|
29
|
+
}
|
|
30
|
+
interface ContentActionsPaymentResponse {
|
|
31
|
+
details: {
|
|
32
|
+
amount: number;
|
|
33
|
+
currency: string;
|
|
34
|
+
due_date: string;
|
|
35
|
+
market: string;
|
|
36
|
+
reference: string;
|
|
37
|
+
iban: string;
|
|
38
|
+
tink_payment_id: string;
|
|
39
|
+
};
|
|
40
|
+
link: string;
|
|
41
|
+
}
|
|
42
|
+
interface ContentActionsSignatureResponse {
|
|
43
|
+
document_signatures: {
|
|
44
|
+
signature_ids: string[];
|
|
45
|
+
signature_reference: string;
|
|
46
|
+
};
|
|
47
|
+
embedded_signatures: {
|
|
48
|
+
created_by: string;
|
|
49
|
+
created_date: string;
|
|
50
|
+
document_signature_id: string;
|
|
51
|
+
due_date: string;
|
|
52
|
+
field_name: string;
|
|
53
|
+
history?: string;
|
|
54
|
+
purpose: string;
|
|
55
|
+
request_date: string;
|
|
56
|
+
requested_to: string;
|
|
57
|
+
signature_date: string;
|
|
58
|
+
signed_by: string;
|
|
59
|
+
signed_for: string;
|
|
60
|
+
value: string;
|
|
61
|
+
}[];
|
|
62
|
+
signature_reference: string;
|
|
63
|
+
}
|
|
64
|
+
interface ContentActionsResponse {
|
|
65
|
+
payments: ContentActionsPaymentResponse[];
|
|
66
|
+
signatures: ContentActionsSignatureResponse[];
|
|
67
|
+
}
|
|
68
|
+
export type { SendContentResponse, CheckReceiverResponse, ContentMeta, ContentResponse, ContentActionsResponse };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ApiV1 } from "../../api/api";
|
|
2
|
+
import { CreateSignatureReferenceRequest } from "./requests/signatures";
|
|
3
|
+
import { ApiResponse } from "./apiResponse";
|
|
4
|
+
import { CreateSignatureReferenceResponse } from "./responses/signatures";
|
|
5
|
+
declare class SignaturesEndpoint {
|
|
6
|
+
private endpoint;
|
|
7
|
+
private readonly VERSION;
|
|
8
|
+
private state;
|
|
9
|
+
constructor(api: ApiV1);
|
|
10
|
+
/**
|
|
11
|
+
* builds the full path
|
|
12
|
+
* @param path - The path to the endpoint, e.g. "authentication/login"
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
private getPath;
|
|
16
|
+
/**
|
|
17
|
+
* creates a signature reference
|
|
18
|
+
* @param tenantId - The id of the tenant
|
|
19
|
+
* @param request - The request object
|
|
20
|
+
* @returns the response object
|
|
21
|
+
*/
|
|
22
|
+
createSignatureReference(tenantId: string, request: CreateSignatureReferenceRequest): Promise<ApiResponse<CreateSignatureReferenceResponse>>;
|
|
23
|
+
/**
|
|
24
|
+
* gets a signature reference
|
|
25
|
+
* @param signatureId - The id of the signature
|
|
26
|
+
* @returns the response object
|
|
27
|
+
*/
|
|
28
|
+
exportSignature(signatureId: string, format: 'xml'): Promise<ApiResponse<any>>;
|
|
29
|
+
}
|
|
30
|
+
export { SignaturesEndpoint };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./api/api";
|
|
2
|
+
export * from "./endpoints/v1/requests/authentication";
|
|
3
|
+
export * from "./endpoints/v1/responses/authentication";
|
|
4
|
+
export * from "./endpoints/v1/requests/content";
|
|
5
|
+
export * from "./endpoints/v1/responses/content";
|
|
6
|
+
export * from "./endpoints/v1/requests/signatures";
|
|
7
|
+
export * from "./endpoints/v1/responses/signatures";
|
|
8
|
+
export * from "./endpoints/v1/apiResponse";
|
|
9
|
+
export * from "./endpoints/v1/authentication";
|
|
10
|
+
export * from "./endpoints/v1/content";
|
|
11
|
+
export * from "./endpoints/v1/signatures";
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
class ApiResponse {
|
|
4
|
+
constructor(data, error) {
|
|
5
|
+
this._data = data;
|
|
6
|
+
this._error = error;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* create a success response from data
|
|
10
|
+
* @param data - The data to return
|
|
11
|
+
*/
|
|
12
|
+
static success(data) {
|
|
13
|
+
return new ApiResponse(data);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* create an error response from an AxiosError
|
|
17
|
+
* @param error - The AxiosError object
|
|
18
|
+
*/
|
|
19
|
+
static error(error) {
|
|
20
|
+
return new ApiResponse(undefined, error);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* create an error response from an AxiosError
|
|
24
|
+
* @param error - The AxiosError object
|
|
25
|
+
*/
|
|
26
|
+
static errorAxios(error) {
|
|
27
|
+
const response = error.response;
|
|
28
|
+
if (response === undefined) {
|
|
29
|
+
return ApiResponse.error({
|
|
30
|
+
code: 50000,
|
|
31
|
+
message: "Unknown error",
|
|
32
|
+
status: 500
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const data = response.data;
|
|
36
|
+
return ApiResponse.error({
|
|
37
|
+
code: data.code,
|
|
38
|
+
message: data.message,
|
|
39
|
+
status: response.status
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* check if the response is a success
|
|
44
|
+
*/
|
|
45
|
+
get isSuccess() {
|
|
46
|
+
return this._data !== undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* check if the response is an error
|
|
50
|
+
*/
|
|
51
|
+
get isError() {
|
|
52
|
+
return this._error !== undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* get the data from the response
|
|
56
|
+
*/
|
|
57
|
+
get data() {
|
|
58
|
+
return this._data;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* get the error from the response
|
|
62
|
+
*/
|
|
63
|
+
get error() {
|
|
64
|
+
return this._error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class AuthenticationEndpoints {
|
|
69
|
+
constructor(api) {
|
|
70
|
+
this.VERSION = "v1";
|
|
71
|
+
this.endpoint = api.endpoint;
|
|
72
|
+
this.state = api.apiState;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* builds the full path
|
|
76
|
+
* @param path - The path to the endpoint, e.g. "authentication/login"
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
getPath(path) {
|
|
80
|
+
return `${this.endpoint}/${this.VERSION}/auth/${path}`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* login to the API
|
|
84
|
+
* @param loginRequest - The login request object
|
|
85
|
+
* @returns the login response object
|
|
86
|
+
*/
|
|
87
|
+
login(loginRequest) {
|
|
88
|
+
const path = this.getPath("login");
|
|
89
|
+
// axios.post(path, loginRequest)
|
|
90
|
+
return axios.post(path, loginRequest)
|
|
91
|
+
.then((response) => {
|
|
92
|
+
return ApiResponse.success(response.data);
|
|
93
|
+
}).then((response) => {
|
|
94
|
+
var _a, _b, _c, _d, _e;
|
|
95
|
+
const at = (_a = response.data) === null || _a === void 0 ? void 0 : _a.access_token;
|
|
96
|
+
this.state.auth_token = at;
|
|
97
|
+
const expire_in = ((_c = (_b = response.data) === null || _b === void 0 ? void 0 : _b.expires_in) !== null && _c !== void 0 ? _c : 0) * 1000;
|
|
98
|
+
const issue_time = new Date((_e = (_d = response.data) === null || _d === void 0 ? void 0 : _d.created_at) !== null && _e !== void 0 ? _e : new Date()).getMilliseconds();
|
|
99
|
+
const expires_milli = issue_time + expire_in;
|
|
100
|
+
this.state.auth_token_expire_date = new Date(expires_milli);
|
|
101
|
+
return response;
|
|
102
|
+
})
|
|
103
|
+
.catch((error) => {
|
|
104
|
+
return ApiResponse.errorAxios(error);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
class ContentEndpoints {
|
|
110
|
+
constructor(api) {
|
|
111
|
+
this.VERSION = "v1";
|
|
112
|
+
this.endpoint = api.endpoint;
|
|
113
|
+
this.state = api.apiState;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* builds the full path
|
|
117
|
+
* @param path - The path to the endpoint, e.g. "authentication/login"
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
getPath(path) {
|
|
121
|
+
return `${this.endpoint}/${this.VERSION}/content/${path}`;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* get the content of a document
|
|
125
|
+
* @param documentId - The id of the document
|
|
126
|
+
* @returns the content of the document
|
|
127
|
+
*/
|
|
128
|
+
getContent(documentId) {
|
|
129
|
+
const path = this.getPath(`document/${documentId}`);
|
|
130
|
+
return axios.get(path, {
|
|
131
|
+
headers: {
|
|
132
|
+
"Authorization": `Bearer ${this.state.auth_token}`
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
.then((response) => {
|
|
136
|
+
return ApiResponse.success(response.data);
|
|
137
|
+
})
|
|
138
|
+
.catch((error) => {
|
|
139
|
+
return ApiResponse.errorAxios(error);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* get the actions of a document
|
|
144
|
+
* @param documentId - The id of the document
|
|
145
|
+
* @returns the actions of the document
|
|
146
|
+
*/
|
|
147
|
+
getContentActions(documentId) {
|
|
148
|
+
const path = this.getPath(`document/${documentId}/actions`);
|
|
149
|
+
return axios.get(path, {
|
|
150
|
+
headers: {
|
|
151
|
+
"Authorization": `Bearer ${this.state.auth_token}`
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
.then((response) => {
|
|
155
|
+
return ApiResponse.success(response.data);
|
|
156
|
+
})
|
|
157
|
+
.catch((error) => {
|
|
158
|
+
return ApiResponse.errorAxios(error);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* checks if a receiver is existing in Brifle
|
|
163
|
+
* @param receiver - The receiver object to check
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
checkReceiver(receiver) {
|
|
167
|
+
const path = this.getPath(`receiver/check`);
|
|
168
|
+
return axios.post(path, receiver, {
|
|
169
|
+
headers: {
|
|
170
|
+
"Authorization": `Bearer ${this.state.auth_token}`
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
.then((response) => {
|
|
174
|
+
return ApiResponse.success(response.data);
|
|
175
|
+
})
|
|
176
|
+
.catch((error) => {
|
|
177
|
+
return ApiResponse.errorAxios(error);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* send a content to a receiver
|
|
182
|
+
* @param tenantId - The tenant id of the receiver
|
|
183
|
+
* @param request - The request object to send
|
|
184
|
+
* @returns
|
|
185
|
+
*/
|
|
186
|
+
sendContent(tenantId, request) {
|
|
187
|
+
const path = this.getPath(`send/${tenantId}`);
|
|
188
|
+
return axios.post(path, request, {
|
|
189
|
+
headers: {
|
|
190
|
+
"Authorization": `Bearer ${this.state.auth_token}`
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
.then((response) => {
|
|
194
|
+
return ApiResponse.success(response.data);
|
|
195
|
+
})
|
|
196
|
+
.catch((error) => {
|
|
197
|
+
return ApiResponse.errorAxios(error);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
class SignaturesEndpoint {
|
|
203
|
+
constructor(api) {
|
|
204
|
+
this.VERSION = "v1";
|
|
205
|
+
this.endpoint = api.endpoint;
|
|
206
|
+
this.state = api.apiState;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* builds the full path
|
|
210
|
+
* @param path - The path to the endpoint, e.g. "authentication/login"
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
getPath(path) {
|
|
214
|
+
return `${this.endpoint}/${this.VERSION}/signature/${path}`;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* creates a signature reference
|
|
218
|
+
* @param tenantId - The id of the tenant
|
|
219
|
+
* @param request - The request object
|
|
220
|
+
* @returns the response object
|
|
221
|
+
*/
|
|
222
|
+
createSignatureReference(tenantId, request) {
|
|
223
|
+
const path = this.getPath(`${tenantId}/reference`);
|
|
224
|
+
const headers = {
|
|
225
|
+
"Authorization": `Bearer ${this.state.auth_token}`,
|
|
226
|
+
};
|
|
227
|
+
return axios.post(path, request, { headers })
|
|
228
|
+
.then((response) => {
|
|
229
|
+
return ApiResponse.success(response.data);
|
|
230
|
+
})
|
|
231
|
+
.catch((error) => {
|
|
232
|
+
return ApiResponse.errorAxios(error);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* gets a signature reference
|
|
237
|
+
* @param signatureId - The id of the signature
|
|
238
|
+
* @returns the response object
|
|
239
|
+
*/
|
|
240
|
+
exportSignature(signatureId, format) {
|
|
241
|
+
const path = this.getPath(`${signatureId}/export/${format}`);
|
|
242
|
+
const headers = {
|
|
243
|
+
"Authorization": `Bearer ${this.state.auth_token}`,
|
|
244
|
+
};
|
|
245
|
+
return axios.get(path, { headers })
|
|
246
|
+
.then((response) => {
|
|
247
|
+
return ApiResponse.success(response.data);
|
|
248
|
+
})
|
|
249
|
+
.catch((error) => {
|
|
250
|
+
return ApiResponse.errorAxios(error);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
var ENDPOINTS;
|
|
256
|
+
(function (ENDPOINTS) {
|
|
257
|
+
ENDPOINTS["SANDBOX"] = "https://sandbox-api.brifle.de";
|
|
258
|
+
ENDPOINTS["PRODUCTION"] = "https://api.brifle.de";
|
|
259
|
+
})(ENDPOINTS || (ENDPOINTS = {}));
|
|
260
|
+
class ApiV1 {
|
|
261
|
+
constructor(endpoint) {
|
|
262
|
+
if (endpoint.endsWith("/")) {
|
|
263
|
+
this.endpoint = endpoint.slice(0, -1);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
this.endpoint = endpoint;
|
|
267
|
+
}
|
|
268
|
+
this.apiState = {};
|
|
269
|
+
}
|
|
270
|
+
static get sandbox() {
|
|
271
|
+
return new ApiV1(ENDPOINTS.SANDBOX);
|
|
272
|
+
}
|
|
273
|
+
static get production() {
|
|
274
|
+
return new ApiV1(ENDPOINTS.PRODUCTION);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* gets an instance of the AuthenticationEndpoints
|
|
278
|
+
* @returns AuthenticationEndpoints
|
|
279
|
+
*/
|
|
280
|
+
authentication() {
|
|
281
|
+
return new AuthenticationEndpoints(this);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* gets an instance of the ContentEndpoints
|
|
285
|
+
* @returns ContentEndpoints
|
|
286
|
+
*/
|
|
287
|
+
content() {
|
|
288
|
+
return new ContentEndpoints(this);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* gets an instance of the SignatureEndpoints
|
|
292
|
+
* @returns ContentEndpoints
|
|
293
|
+
*/
|
|
294
|
+
signature() {
|
|
295
|
+
return new SignaturesEndpoint(this);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export { ApiResponse, ApiV1, AuthenticationEndpoints, ContentEndpoints, SignaturesEndpoint };
|
|
300
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|