@brifle/brifle-sdk 0.0.3 → 0.0.5

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.
Files changed (33) hide show
  1. package/dist/cjs/api/api.d.ts +18 -0
  2. package/dist/cjs/endpoints/v1/accounts.d.ts +15 -0
  3. package/dist/cjs/endpoints/v1/mailbox.d.ts +18 -0
  4. package/dist/cjs/endpoints/v1/requests/mailbox.d.ts +10 -0
  5. package/dist/cjs/endpoints/v1/responses/accounts.d.ts +8 -0
  6. package/dist/cjs/endpoints/v1/responses/mailbox.d.ts +21 -0
  7. package/dist/cjs/endpoints/v1/responses/tenant.d.ts +12 -0
  8. package/dist/cjs/endpoints/v1/tenant.d.ts +19 -0
  9. package/dist/cjs/index.d.ts +7 -0
  10. package/dist/cjs/index.js +154 -0
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/esm/api/api.d.ts +18 -0
  13. package/dist/esm/endpoints/v1/accounts.d.ts +15 -0
  14. package/dist/esm/endpoints/v1/mailbox.d.ts +18 -0
  15. package/dist/esm/endpoints/v1/requests/mailbox.d.ts +10 -0
  16. package/dist/esm/endpoints/v1/responses/accounts.d.ts +8 -0
  17. package/dist/esm/endpoints/v1/responses/mailbox.d.ts +21 -0
  18. package/dist/esm/endpoints/v1/responses/tenant.d.ts +12 -0
  19. package/dist/esm/endpoints/v1/tenant.d.ts +19 -0
  20. package/dist/esm/index.d.ts +7 -0
  21. package/dist/esm/index.mjs +152 -1
  22. package/dist/esm/index.mjs.map +1 -1
  23. package/dist/index.d.ts +110 -2
  24. package/dist/types/api/api.d.ts +18 -0
  25. package/dist/types/endpoints/v1/accounts.d.ts +15 -0
  26. package/dist/types/endpoints/v1/mailbox.d.ts +18 -0
  27. package/dist/types/endpoints/v1/requests/mailbox.d.ts +10 -0
  28. package/dist/types/endpoints/v1/responses/accounts.d.ts +8 -0
  29. package/dist/types/endpoints/v1/responses/mailbox.d.ts +21 -0
  30. package/dist/types/endpoints/v1/responses/tenant.d.ts +12 -0
  31. package/dist/types/endpoints/v1/tenant.d.ts +19 -0
  32. package/dist/types/index.d.ts +7 -0
  33. package/package.json +1 -1
@@ -1,6 +1,9 @@
1
1
  import { AuthenticationEndpoints } from "../endpoints/v1/authentication";
2
2
  import { ContentEndpoints } from "../endpoints/v1/content";
3
3
  import { SignaturesEndpoint } from "../endpoints/v1/signatures";
4
+ import { MailboxEndpoints } from "../endpoints/v1/mailbox";
5
+ import { TenantsEndpoints } from "../endpoints/v1/tenant";
6
+ import { AccountsEndpoints } from "../endpoints/v1/accounts";
4
7
  declare class ApiV1 {
5
8
  readonly endpoint: string;
6
9
  readonly apiState: ApiV1State;
@@ -22,6 +25,21 @@ declare class ApiV1 {
22
25
  * @returns ContentEndpoints
23
26
  */
24
27
  signature(): SignaturesEndpoint;
28
+ /**
29
+ * gets an instance of the TenantsEndpoints
30
+ * @returns TenantsEndpoints
31
+ */
32
+ tenants(): TenantsEndpoints;
33
+ /**
34
+ * gets an instance of the AccountsEndpoints
35
+ * @returns AccountsEndpoints
36
+ */
37
+ accounts(): AccountsEndpoints;
38
+ /**
39
+ * gets an instance of the MailboxEndpoints
40
+ * @returns MailboxEndpoints
41
+ */
42
+ mailbox(): MailboxEndpoints;
25
43
  }
26
44
  export interface ApiV1State {
27
45
  auth_token?: string;
@@ -0,0 +1,15 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { AccountInfo } from "./responses/accounts";
3
+ import { ApiResponse } from "./apiResponse";
4
+ declare class AccountsEndpoints {
5
+ private endpoint;
6
+ private readonly VERSION;
7
+ private state;
8
+ constructor(api: ApiV1);
9
+ private getPath;
10
+ /**
11
+ * Gets a tenant by its ID
12
+ */
13
+ getById(accountId: string): Promise<ApiResponse<AccountInfo>>;
14
+ }
15
+ export { AccountsEndpoints };
@@ -0,0 +1,18 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { InboxFilter, OutboxFilter } from "./requests/mailbox";
3
+ import { MailboxResponse } from "./responses/mailbox";
4
+ import { ApiResponse } from "./apiResponse";
5
+ declare class MailboxEndpoints {
6
+ private endpoint;
7
+ private readonly VERSION;
8
+ private state;
9
+ constructor(api: ApiV1);
10
+ private getPath;
11
+ /**
12
+ * Get the inbox of an account
13
+ * @returns the mailbox response object
14
+ */
15
+ getInbox(filter: InboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
16
+ getOutbox(tenant: string, filter: OutboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
17
+ }
18
+ export { MailboxEndpoints };
@@ -0,0 +1,10 @@
1
+ interface InboxFilter {
2
+ state?: Array<'read' | 'unread' | 'trashed'>;
3
+ subject?: string;
4
+ sub_mailbox?: string;
5
+ type?: 'letter' | 'invoice' | 'contract';
6
+ }
7
+ interface OutboxFilter {
8
+ state?: Array<'active' | 'trashed'>;
9
+ }
10
+ export type { InboxFilter, OutboxFilter };
@@ -0,0 +1,8 @@
1
+ interface AccountInfo {
2
+ company_name: string;
3
+ first_name: string;
4
+ last_name: string;
5
+ middle_name: string;
6
+ type: 'private' | 'business';
7
+ }
8
+ export type { AccountInfo };
@@ -0,0 +1,21 @@
1
+ interface MailboxResponse {
2
+ total: number;
3
+ results: Meta[];
4
+ }
5
+ interface Meta {
6
+ id: string;
7
+ sender: string;
8
+ receiver: string;
9
+ read: boolean;
10
+ read_date: string;
11
+ size: number;
12
+ type: string;
13
+ delivered: boolean;
14
+ delivered_date: string;
15
+ sent_date: string;
16
+ subject: string;
17
+ sender_state?: string;
18
+ receiver_state?: string;
19
+ size_responsive?: number;
20
+ }
21
+ export type { MailboxResponse, Meta };
@@ -0,0 +1,12 @@
1
+ interface Tenant {
2
+ account_id: string;
3
+ name: string;
4
+ image?: string;
5
+ private: boolean;
6
+ id: string;
7
+ }
8
+ interface TenantsResponse {
9
+ total: number;
10
+ tenants: Tenant[];
11
+ }
12
+ export type { Tenant, TenantsResponse };
@@ -0,0 +1,19 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { Tenant, TenantsResponse } from "./responses/tenant";
3
+ import { ApiResponse } from "./apiResponse";
4
+ declare class TenantsEndpoints {
5
+ private endpoint;
6
+ private readonly VERSION;
7
+ private state;
8
+ constructor(api: ApiV1);
9
+ private getPath;
10
+ /**
11
+ * Gets a tenant by its ID
12
+ */
13
+ getById(tenantId: string): Promise<ApiResponse<Tenant>>;
14
+ /**
15
+ * Gets all tenants owned by the account id
16
+ */
17
+ getMy(): Promise<ApiResponse<TenantsResponse>>;
18
+ }
19
+ export { TenantsEndpoints };
@@ -9,3 +9,10 @@ export * from "./endpoints/v1/apiResponse";
9
9
  export * from "./endpoints/v1/authentication";
10
10
  export * from "./endpoints/v1/content";
11
11
  export * from "./endpoints/v1/signatures";
12
+ export * from "./endpoints/v1/mailbox";
13
+ export * from "./endpoints/v1/requests/mailbox";
14
+ export * from "./endpoints/v1/responses/mailbox";
15
+ export * from "./endpoints/v1/tenant";
16
+ export * from "./endpoints/v1/responses/tenant";
17
+ export * from "./endpoints/v1/accounts";
18
+ export * from "./endpoints/v1/responses/accounts";
package/dist/cjs/index.js CHANGED
@@ -254,6 +254,136 @@ class SignaturesEndpoint {
254
254
  }
255
255
  }
256
256
 
257
+ class MailboxEndpoints {
258
+ constructor(api) {
259
+ this.VERSION = "v1";
260
+ this.endpoint = api.endpoint;
261
+ this.state = api.apiState;
262
+ }
263
+ getPath(path) {
264
+ return `${this.endpoint}/${this.VERSION}/mailbox/${path}`;
265
+ }
266
+ /**
267
+ * Get the inbox of an account
268
+ * @returns the mailbox response object
269
+ */
270
+ getInbox(filter, page = 1) {
271
+ const path = this.getPath(`inbox`);
272
+ const body = {
273
+ filter: filter,
274
+ page: page
275
+ };
276
+ return axios.post(path, body, {
277
+ headers: {
278
+ "Authorization": `Bearer ${this.state.auth_token}`,
279
+ "Content-Type": "application/json"
280
+ }
281
+ })
282
+ .then((response) => {
283
+ return ApiResponse.success(response.data);
284
+ })
285
+ .catch((error) => {
286
+ return ApiResponse.errorAxios(error);
287
+ });
288
+ }
289
+ getOutbox(tenant, filter, page = 1) {
290
+ const path = this.getPath(`outbox/${tenant}`);
291
+ const body = {
292
+ filter: filter,
293
+ page: page
294
+ };
295
+ return axios.post(path, body, {
296
+ headers: {
297
+ "Authorization": `Bearer ${this.state.auth_token}`,
298
+ "Content-Type": "application/json"
299
+ }
300
+ })
301
+ .then((response) => {
302
+ return ApiResponse.success(response.data);
303
+ })
304
+ .catch((error) => {
305
+ return ApiResponse.errorAxios(error);
306
+ });
307
+ }
308
+ }
309
+
310
+ class TenantsEndpoints {
311
+ constructor(api) {
312
+ this.VERSION = "v1";
313
+ this.endpoint = api.endpoint;
314
+ this.state = api.apiState;
315
+ }
316
+ getPath(path) {
317
+ return `${this.endpoint}/${this.VERSION}/tenants/${path}`;
318
+ }
319
+ /**
320
+ * Gets a tenant by its ID
321
+ */
322
+ getById(tenantId) {
323
+ const path = this.getPath(`id/${tenantId}`);
324
+ return axios.get(path, {
325
+ headers: {
326
+ "Authorization": `Bearer ${this.state.auth_token}`,
327
+ "Content-Type": "application/json"
328
+ }
329
+ })
330
+ .then((response) => {
331
+ return ApiResponse.success(response.data);
332
+ })
333
+ .catch((error) => {
334
+ return ApiResponse.errorAxios(error);
335
+ });
336
+ }
337
+ /**
338
+ * Gets all tenants owned by the account id
339
+ */
340
+ getMy() {
341
+ const path = this.getPath(`my`);
342
+ return axios.get(path, {
343
+ headers: {
344
+ "Authorization": `Bearer ${this.state.auth_token}`,
345
+ "Content-Type": "application/json"
346
+ }
347
+ })
348
+ .then((response) => {
349
+ return ApiResponse.success(response.data);
350
+ })
351
+ .catch((error) => {
352
+ return ApiResponse.errorAxios(error);
353
+ });
354
+ }
355
+ }
356
+
357
+ class AccountsEndpoints {
358
+ constructor(api) {
359
+ this.VERSION = "v1";
360
+ this.endpoint = api.endpoint;
361
+ this.state = api.apiState;
362
+ }
363
+ getPath(path) {
364
+ return `${this.endpoint}/${this.VERSION}/accounts/${path}`;
365
+ }
366
+ /**
367
+ * Gets a tenant by its ID
368
+ */
369
+ getById(accountId) {
370
+ const path = this.getPath(`${accountId}`);
371
+ console.log(path, path);
372
+ return axios.get(path, {
373
+ headers: {
374
+ "Authorization": `Bearer ${this.state.auth_token}`,
375
+ "Content-Type": "application/json"
376
+ }
377
+ })
378
+ .then((response) => {
379
+ return ApiResponse.success(response.data);
380
+ })
381
+ .catch((error) => {
382
+ return ApiResponse.errorAxios(error);
383
+ });
384
+ }
385
+ }
386
+
257
387
  var ENDPOINTS;
258
388
  (function (ENDPOINTS) {
259
389
  ENDPOINTS["SANDBOX"] = "https://sandbox-api.brifle.de";
@@ -296,11 +426,35 @@ class ApiV1 {
296
426
  signature() {
297
427
  return new SignaturesEndpoint(this);
298
428
  }
429
+ /**
430
+ * gets an instance of the TenantsEndpoints
431
+ * @returns TenantsEndpoints
432
+ */
433
+ tenants() {
434
+ return new TenantsEndpoints(this);
435
+ }
436
+ /**
437
+ * gets an instance of the AccountsEndpoints
438
+ * @returns AccountsEndpoints
439
+ */
440
+ accounts() {
441
+ return new AccountsEndpoints(this);
442
+ }
443
+ /**
444
+ * gets an instance of the MailboxEndpoints
445
+ * @returns MailboxEndpoints
446
+ */
447
+ mailbox() {
448
+ return new MailboxEndpoints(this);
449
+ }
299
450
  }
300
451
 
452
+ exports.AccountsEndpoints = AccountsEndpoints;
301
453
  exports.ApiResponse = ApiResponse;
302
454
  exports.ApiV1 = ApiV1;
303
455
  exports.AuthenticationEndpoints = AuthenticationEndpoints;
304
456
  exports.ContentEndpoints = ContentEndpoints;
457
+ exports.MailboxEndpoints = MailboxEndpoints;
305
458
  exports.SignaturesEndpoint = SignaturesEndpoint;
459
+ exports.TenantsEndpoints = TenantsEndpoints;
306
460
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,9 @@
1
1
  import { AuthenticationEndpoints } from "../endpoints/v1/authentication";
2
2
  import { ContentEndpoints } from "../endpoints/v1/content";
3
3
  import { SignaturesEndpoint } from "../endpoints/v1/signatures";
4
+ import { MailboxEndpoints } from "../endpoints/v1/mailbox";
5
+ import { TenantsEndpoints } from "../endpoints/v1/tenant";
6
+ import { AccountsEndpoints } from "../endpoints/v1/accounts";
4
7
  declare class ApiV1 {
5
8
  readonly endpoint: string;
6
9
  readonly apiState: ApiV1State;
@@ -22,6 +25,21 @@ declare class ApiV1 {
22
25
  * @returns ContentEndpoints
23
26
  */
24
27
  signature(): SignaturesEndpoint;
28
+ /**
29
+ * gets an instance of the TenantsEndpoints
30
+ * @returns TenantsEndpoints
31
+ */
32
+ tenants(): TenantsEndpoints;
33
+ /**
34
+ * gets an instance of the AccountsEndpoints
35
+ * @returns AccountsEndpoints
36
+ */
37
+ accounts(): AccountsEndpoints;
38
+ /**
39
+ * gets an instance of the MailboxEndpoints
40
+ * @returns MailboxEndpoints
41
+ */
42
+ mailbox(): MailboxEndpoints;
25
43
  }
26
44
  export interface ApiV1State {
27
45
  auth_token?: string;
@@ -0,0 +1,15 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { AccountInfo } from "./responses/accounts";
3
+ import { ApiResponse } from "./apiResponse";
4
+ declare class AccountsEndpoints {
5
+ private endpoint;
6
+ private readonly VERSION;
7
+ private state;
8
+ constructor(api: ApiV1);
9
+ private getPath;
10
+ /**
11
+ * Gets a tenant by its ID
12
+ */
13
+ getById(accountId: string): Promise<ApiResponse<AccountInfo>>;
14
+ }
15
+ export { AccountsEndpoints };
@@ -0,0 +1,18 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { InboxFilter, OutboxFilter } from "./requests/mailbox";
3
+ import { MailboxResponse } from "./responses/mailbox";
4
+ import { ApiResponse } from "./apiResponse";
5
+ declare class MailboxEndpoints {
6
+ private endpoint;
7
+ private readonly VERSION;
8
+ private state;
9
+ constructor(api: ApiV1);
10
+ private getPath;
11
+ /**
12
+ * Get the inbox of an account
13
+ * @returns the mailbox response object
14
+ */
15
+ getInbox(filter: InboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
16
+ getOutbox(tenant: string, filter: OutboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
17
+ }
18
+ export { MailboxEndpoints };
@@ -0,0 +1,10 @@
1
+ interface InboxFilter {
2
+ state?: Array<'read' | 'unread' | 'trashed'>;
3
+ subject?: string;
4
+ sub_mailbox?: string;
5
+ type?: 'letter' | 'invoice' | 'contract';
6
+ }
7
+ interface OutboxFilter {
8
+ state?: Array<'active' | 'trashed'>;
9
+ }
10
+ export type { InboxFilter, OutboxFilter };
@@ -0,0 +1,8 @@
1
+ interface AccountInfo {
2
+ company_name: string;
3
+ first_name: string;
4
+ last_name: string;
5
+ middle_name: string;
6
+ type: 'private' | 'business';
7
+ }
8
+ export type { AccountInfo };
@@ -0,0 +1,21 @@
1
+ interface MailboxResponse {
2
+ total: number;
3
+ results: Meta[];
4
+ }
5
+ interface Meta {
6
+ id: string;
7
+ sender: string;
8
+ receiver: string;
9
+ read: boolean;
10
+ read_date: string;
11
+ size: number;
12
+ type: string;
13
+ delivered: boolean;
14
+ delivered_date: string;
15
+ sent_date: string;
16
+ subject: string;
17
+ sender_state?: string;
18
+ receiver_state?: string;
19
+ size_responsive?: number;
20
+ }
21
+ export type { MailboxResponse, Meta };
@@ -0,0 +1,12 @@
1
+ interface Tenant {
2
+ account_id: string;
3
+ name: string;
4
+ image?: string;
5
+ private: boolean;
6
+ id: string;
7
+ }
8
+ interface TenantsResponse {
9
+ total: number;
10
+ tenants: Tenant[];
11
+ }
12
+ export type { Tenant, TenantsResponse };
@@ -0,0 +1,19 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { Tenant, TenantsResponse } from "./responses/tenant";
3
+ import { ApiResponse } from "./apiResponse";
4
+ declare class TenantsEndpoints {
5
+ private endpoint;
6
+ private readonly VERSION;
7
+ private state;
8
+ constructor(api: ApiV1);
9
+ private getPath;
10
+ /**
11
+ * Gets a tenant by its ID
12
+ */
13
+ getById(tenantId: string): Promise<ApiResponse<Tenant>>;
14
+ /**
15
+ * Gets all tenants owned by the account id
16
+ */
17
+ getMy(): Promise<ApiResponse<TenantsResponse>>;
18
+ }
19
+ export { TenantsEndpoints };
@@ -9,3 +9,10 @@ export * from "./endpoints/v1/apiResponse";
9
9
  export * from "./endpoints/v1/authentication";
10
10
  export * from "./endpoints/v1/content";
11
11
  export * from "./endpoints/v1/signatures";
12
+ export * from "./endpoints/v1/mailbox";
13
+ export * from "./endpoints/v1/requests/mailbox";
14
+ export * from "./endpoints/v1/responses/mailbox";
15
+ export * from "./endpoints/v1/tenant";
16
+ export * from "./endpoints/v1/responses/tenant";
17
+ export * from "./endpoints/v1/accounts";
18
+ export * from "./endpoints/v1/responses/accounts";
@@ -252,6 +252,136 @@ class SignaturesEndpoint {
252
252
  }
253
253
  }
254
254
 
255
+ class MailboxEndpoints {
256
+ constructor(api) {
257
+ this.VERSION = "v1";
258
+ this.endpoint = api.endpoint;
259
+ this.state = api.apiState;
260
+ }
261
+ getPath(path) {
262
+ return `${this.endpoint}/${this.VERSION}/mailbox/${path}`;
263
+ }
264
+ /**
265
+ * Get the inbox of an account
266
+ * @returns the mailbox response object
267
+ */
268
+ getInbox(filter, page = 1) {
269
+ const path = this.getPath(`inbox`);
270
+ const body = {
271
+ filter: filter,
272
+ page: page
273
+ };
274
+ return axios.post(path, body, {
275
+ headers: {
276
+ "Authorization": `Bearer ${this.state.auth_token}`,
277
+ "Content-Type": "application/json"
278
+ }
279
+ })
280
+ .then((response) => {
281
+ return ApiResponse.success(response.data);
282
+ })
283
+ .catch((error) => {
284
+ return ApiResponse.errorAxios(error);
285
+ });
286
+ }
287
+ getOutbox(tenant, filter, page = 1) {
288
+ const path = this.getPath(`outbox/${tenant}`);
289
+ const body = {
290
+ filter: filter,
291
+ page: page
292
+ };
293
+ return axios.post(path, body, {
294
+ headers: {
295
+ "Authorization": `Bearer ${this.state.auth_token}`,
296
+ "Content-Type": "application/json"
297
+ }
298
+ })
299
+ .then((response) => {
300
+ return ApiResponse.success(response.data);
301
+ })
302
+ .catch((error) => {
303
+ return ApiResponse.errorAxios(error);
304
+ });
305
+ }
306
+ }
307
+
308
+ class TenantsEndpoints {
309
+ constructor(api) {
310
+ this.VERSION = "v1";
311
+ this.endpoint = api.endpoint;
312
+ this.state = api.apiState;
313
+ }
314
+ getPath(path) {
315
+ return `${this.endpoint}/${this.VERSION}/tenants/${path}`;
316
+ }
317
+ /**
318
+ * Gets a tenant by its ID
319
+ */
320
+ getById(tenantId) {
321
+ const path = this.getPath(`id/${tenantId}`);
322
+ return axios.get(path, {
323
+ headers: {
324
+ "Authorization": `Bearer ${this.state.auth_token}`,
325
+ "Content-Type": "application/json"
326
+ }
327
+ })
328
+ .then((response) => {
329
+ return ApiResponse.success(response.data);
330
+ })
331
+ .catch((error) => {
332
+ return ApiResponse.errorAxios(error);
333
+ });
334
+ }
335
+ /**
336
+ * Gets all tenants owned by the account id
337
+ */
338
+ getMy() {
339
+ const path = this.getPath(`my`);
340
+ return axios.get(path, {
341
+ headers: {
342
+ "Authorization": `Bearer ${this.state.auth_token}`,
343
+ "Content-Type": "application/json"
344
+ }
345
+ })
346
+ .then((response) => {
347
+ return ApiResponse.success(response.data);
348
+ })
349
+ .catch((error) => {
350
+ return ApiResponse.errorAxios(error);
351
+ });
352
+ }
353
+ }
354
+
355
+ class AccountsEndpoints {
356
+ constructor(api) {
357
+ this.VERSION = "v1";
358
+ this.endpoint = api.endpoint;
359
+ this.state = api.apiState;
360
+ }
361
+ getPath(path) {
362
+ return `${this.endpoint}/${this.VERSION}/accounts/${path}`;
363
+ }
364
+ /**
365
+ * Gets a tenant by its ID
366
+ */
367
+ getById(accountId) {
368
+ const path = this.getPath(`${accountId}`);
369
+ console.log(path, path);
370
+ return axios.get(path, {
371
+ headers: {
372
+ "Authorization": `Bearer ${this.state.auth_token}`,
373
+ "Content-Type": "application/json"
374
+ }
375
+ })
376
+ .then((response) => {
377
+ return ApiResponse.success(response.data);
378
+ })
379
+ .catch((error) => {
380
+ return ApiResponse.errorAxios(error);
381
+ });
382
+ }
383
+ }
384
+
255
385
  var ENDPOINTS;
256
386
  (function (ENDPOINTS) {
257
387
  ENDPOINTS["SANDBOX"] = "https://sandbox-api.brifle.de";
@@ -294,7 +424,28 @@ class ApiV1 {
294
424
  signature() {
295
425
  return new SignaturesEndpoint(this);
296
426
  }
427
+ /**
428
+ * gets an instance of the TenantsEndpoints
429
+ * @returns TenantsEndpoints
430
+ */
431
+ tenants() {
432
+ return new TenantsEndpoints(this);
433
+ }
434
+ /**
435
+ * gets an instance of the AccountsEndpoints
436
+ * @returns AccountsEndpoints
437
+ */
438
+ accounts() {
439
+ return new AccountsEndpoints(this);
440
+ }
441
+ /**
442
+ * gets an instance of the MailboxEndpoints
443
+ * @returns MailboxEndpoints
444
+ */
445
+ mailbox() {
446
+ return new MailboxEndpoints(this);
447
+ }
297
448
  }
298
449
 
299
- export { ApiResponse, ApiV1, AuthenticationEndpoints, ContentEndpoints, SignaturesEndpoint };
450
+ export { AccountsEndpoints, ApiResponse, ApiV1, AuthenticationEndpoints, ContentEndpoints, MailboxEndpoints, SignaturesEndpoint, TenantsEndpoints };
300
451
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -278,6 +278,99 @@ declare class SignaturesEndpoint {
278
278
  exportSignature(signatureId: string, format: 'xml'): Promise<ApiResponse<any>>;
279
279
  }
280
280
 
281
+ interface InboxFilter {
282
+ state?: Array<'read' | 'unread' | 'trashed'>;
283
+ subject?: string;
284
+ sub_mailbox?: string;
285
+ type?: 'letter' | 'invoice' | 'contract';
286
+ }
287
+ interface OutboxFilter {
288
+ state?: Array<'active' | 'trashed'>;
289
+ }
290
+
291
+ interface MailboxResponse {
292
+ total: number;
293
+ results: Meta[];
294
+ }
295
+ interface Meta {
296
+ id: string;
297
+ sender: string;
298
+ receiver: string;
299
+ read: boolean;
300
+ read_date: string;
301
+ size: number;
302
+ type: string;
303
+ delivered: boolean;
304
+ delivered_date: string;
305
+ sent_date: string;
306
+ subject: string;
307
+ sender_state?: string;
308
+ receiver_state?: string;
309
+ size_responsive?: number;
310
+ }
311
+
312
+ declare class MailboxEndpoints {
313
+ private endpoint;
314
+ private readonly VERSION;
315
+ private state;
316
+ constructor(api: ApiV1);
317
+ private getPath;
318
+ /**
319
+ * Get the inbox of an account
320
+ * @returns the mailbox response object
321
+ */
322
+ getInbox(filter: InboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
323
+ getOutbox(tenant: string, filter: OutboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
324
+ }
325
+
326
+ interface Tenant {
327
+ account_id: string;
328
+ name: string;
329
+ image?: string;
330
+ private: boolean;
331
+ id: string;
332
+ }
333
+ interface TenantsResponse {
334
+ total: number;
335
+ tenants: Tenant[];
336
+ }
337
+
338
+ declare class TenantsEndpoints {
339
+ private endpoint;
340
+ private readonly VERSION;
341
+ private state;
342
+ constructor(api: ApiV1);
343
+ private getPath;
344
+ /**
345
+ * Gets a tenant by its ID
346
+ */
347
+ getById(tenantId: string): Promise<ApiResponse<Tenant>>;
348
+ /**
349
+ * Gets all tenants owned by the account id
350
+ */
351
+ getMy(): Promise<ApiResponse<TenantsResponse>>;
352
+ }
353
+
354
+ interface AccountInfo {
355
+ company_name: string;
356
+ first_name: string;
357
+ last_name: string;
358
+ middle_name: string;
359
+ type: 'private' | 'business';
360
+ }
361
+
362
+ declare class AccountsEndpoints {
363
+ private endpoint;
364
+ private readonly VERSION;
365
+ private state;
366
+ constructor(api: ApiV1);
367
+ private getPath;
368
+ /**
369
+ * Gets a tenant by its ID
370
+ */
371
+ getById(accountId: string): Promise<ApiResponse<AccountInfo>>;
372
+ }
373
+
281
374
  declare class ApiV1 {
282
375
  readonly endpoint: string;
283
376
  readonly apiState: ApiV1State;
@@ -299,11 +392,26 @@ declare class ApiV1 {
299
392
  * @returns ContentEndpoints
300
393
  */
301
394
  signature(): SignaturesEndpoint;
395
+ /**
396
+ * gets an instance of the TenantsEndpoints
397
+ * @returns TenantsEndpoints
398
+ */
399
+ tenants(): TenantsEndpoints;
400
+ /**
401
+ * gets an instance of the AccountsEndpoints
402
+ * @returns AccountsEndpoints
403
+ */
404
+ accounts(): AccountsEndpoints;
405
+ /**
406
+ * gets an instance of the MailboxEndpoints
407
+ * @returns MailboxEndpoints
408
+ */
409
+ mailbox(): MailboxEndpoints;
302
410
  }
303
411
  interface ApiV1State {
304
412
  auth_token?: string;
305
413
  auth_token_expire_date?: Date;
306
414
  }
307
415
 
308
- export { ApiResponse, ApiV1, AuthenticationEndpoints, ContentEndpoints, SignaturesEndpoint };
309
- export type { ApiV1State, BirthInformation, CheckReceiverResponse, ContentActionsResponse, ContentMeta, ContentResponse, CreateSignatureReferenceRequest, CreateSignatureReferenceResponse, ErrorResponse, LoginRequest, LoginResponse, LogoutRequest, PaymentDetails, ReceiverRequest, SendContentRequest, SendContentResponse };
416
+ export { AccountsEndpoints, ApiResponse, ApiV1, AuthenticationEndpoints, ContentEndpoints, MailboxEndpoints, SignaturesEndpoint, TenantsEndpoints };
417
+ export type { AccountInfo, ApiV1State, BirthInformation, CheckReceiverResponse, ContentActionsResponse, ContentMeta, ContentResponse, CreateSignatureReferenceRequest, CreateSignatureReferenceResponse, ErrorResponse, InboxFilter, LoginRequest, LoginResponse, LogoutRequest, MailboxResponse, Meta, OutboxFilter, PaymentDetails, ReceiverRequest, SendContentRequest, SendContentResponse, Tenant, TenantsResponse };
@@ -1,6 +1,9 @@
1
1
  import { AuthenticationEndpoints } from "../endpoints/v1/authentication";
2
2
  import { ContentEndpoints } from "../endpoints/v1/content";
3
3
  import { SignaturesEndpoint } from "../endpoints/v1/signatures";
4
+ import { MailboxEndpoints } from "../endpoints/v1/mailbox";
5
+ import { TenantsEndpoints } from "../endpoints/v1/tenant";
6
+ import { AccountsEndpoints } from "../endpoints/v1/accounts";
4
7
  declare class ApiV1 {
5
8
  readonly endpoint: string;
6
9
  readonly apiState: ApiV1State;
@@ -22,6 +25,21 @@ declare class ApiV1 {
22
25
  * @returns ContentEndpoints
23
26
  */
24
27
  signature(): SignaturesEndpoint;
28
+ /**
29
+ * gets an instance of the TenantsEndpoints
30
+ * @returns TenantsEndpoints
31
+ */
32
+ tenants(): TenantsEndpoints;
33
+ /**
34
+ * gets an instance of the AccountsEndpoints
35
+ * @returns AccountsEndpoints
36
+ */
37
+ accounts(): AccountsEndpoints;
38
+ /**
39
+ * gets an instance of the MailboxEndpoints
40
+ * @returns MailboxEndpoints
41
+ */
42
+ mailbox(): MailboxEndpoints;
25
43
  }
26
44
  export interface ApiV1State {
27
45
  auth_token?: string;
@@ -0,0 +1,15 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { AccountInfo } from "./responses/accounts";
3
+ import { ApiResponse } from "./apiResponse";
4
+ declare class AccountsEndpoints {
5
+ private endpoint;
6
+ private readonly VERSION;
7
+ private state;
8
+ constructor(api: ApiV1);
9
+ private getPath;
10
+ /**
11
+ * Gets a tenant by its ID
12
+ */
13
+ getById(accountId: string): Promise<ApiResponse<AccountInfo>>;
14
+ }
15
+ export { AccountsEndpoints };
@@ -0,0 +1,18 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { InboxFilter, OutboxFilter } from "./requests/mailbox";
3
+ import { MailboxResponse } from "./responses/mailbox";
4
+ import { ApiResponse } from "./apiResponse";
5
+ declare class MailboxEndpoints {
6
+ private endpoint;
7
+ private readonly VERSION;
8
+ private state;
9
+ constructor(api: ApiV1);
10
+ private getPath;
11
+ /**
12
+ * Get the inbox of an account
13
+ * @returns the mailbox response object
14
+ */
15
+ getInbox(filter: InboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
16
+ getOutbox(tenant: string, filter: OutboxFilter, page?: number): Promise<ApiResponse<MailboxResponse>>;
17
+ }
18
+ export { MailboxEndpoints };
@@ -0,0 +1,10 @@
1
+ interface InboxFilter {
2
+ state?: Array<'read' | 'unread' | 'trashed'>;
3
+ subject?: string;
4
+ sub_mailbox?: string;
5
+ type?: 'letter' | 'invoice' | 'contract';
6
+ }
7
+ interface OutboxFilter {
8
+ state?: Array<'active' | 'trashed'>;
9
+ }
10
+ export type { InboxFilter, OutboxFilter };
@@ -0,0 +1,8 @@
1
+ interface AccountInfo {
2
+ company_name: string;
3
+ first_name: string;
4
+ last_name: string;
5
+ middle_name: string;
6
+ type: 'private' | 'business';
7
+ }
8
+ export type { AccountInfo };
@@ -0,0 +1,21 @@
1
+ interface MailboxResponse {
2
+ total: number;
3
+ results: Meta[];
4
+ }
5
+ interface Meta {
6
+ id: string;
7
+ sender: string;
8
+ receiver: string;
9
+ read: boolean;
10
+ read_date: string;
11
+ size: number;
12
+ type: string;
13
+ delivered: boolean;
14
+ delivered_date: string;
15
+ sent_date: string;
16
+ subject: string;
17
+ sender_state?: string;
18
+ receiver_state?: string;
19
+ size_responsive?: number;
20
+ }
21
+ export type { MailboxResponse, Meta };
@@ -0,0 +1,12 @@
1
+ interface Tenant {
2
+ account_id: string;
3
+ name: string;
4
+ image?: string;
5
+ private: boolean;
6
+ id: string;
7
+ }
8
+ interface TenantsResponse {
9
+ total: number;
10
+ tenants: Tenant[];
11
+ }
12
+ export type { Tenant, TenantsResponse };
@@ -0,0 +1,19 @@
1
+ import { ApiV1 } from "../../api/api";
2
+ import { Tenant, TenantsResponse } from "./responses/tenant";
3
+ import { ApiResponse } from "./apiResponse";
4
+ declare class TenantsEndpoints {
5
+ private endpoint;
6
+ private readonly VERSION;
7
+ private state;
8
+ constructor(api: ApiV1);
9
+ private getPath;
10
+ /**
11
+ * Gets a tenant by its ID
12
+ */
13
+ getById(tenantId: string): Promise<ApiResponse<Tenant>>;
14
+ /**
15
+ * Gets all tenants owned by the account id
16
+ */
17
+ getMy(): Promise<ApiResponse<TenantsResponse>>;
18
+ }
19
+ export { TenantsEndpoints };
@@ -9,3 +9,10 @@ export * from "./endpoints/v1/apiResponse";
9
9
  export * from "./endpoints/v1/authentication";
10
10
  export * from "./endpoints/v1/content";
11
11
  export * from "./endpoints/v1/signatures";
12
+ export * from "./endpoints/v1/mailbox";
13
+ export * from "./endpoints/v1/requests/mailbox";
14
+ export * from "./endpoints/v1/responses/mailbox";
15
+ export * from "./endpoints/v1/tenant";
16
+ export * from "./endpoints/v1/responses/tenant";
17
+ export * from "./endpoints/v1/accounts";
18
+ export * from "./endpoints/v1/responses/accounts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brifle/brifle-sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "The JavaScript SDK to interact with the API of Brifle",
5
5
  "files": [
6
6
  "dist",