bkper 2.6.2 → 2.7.0
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/README.md +18 -9
- package/lib/index.d.ts +159 -39
- package/lib/model/App.js +1 -1
- package/lib/model/Bkper.js +13 -0
- package/lib/model/Book.js +19 -0
- package/lib/model/Connection.js +60 -23
- package/lib/model/Integration.js +27 -10
- package/lib/model/Transaction.js +11 -0
- package/lib/model/User.js +19 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ It also provide a **command line** utility to create and update [Bkper Apps and
|
|
|
8
8
|
|
|
9
9
|
## Instalation
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Add the package:
|
|
12
12
|
|
|
13
13
|
```
|
|
14
14
|
npm i -S bkper
|
|
@@ -22,21 +22,33 @@ yarn add bkper
|
|
|
22
22
|
|
|
23
23
|
- ```login``` - Logs the user in. Saves the client credentials to a ```~/.bkper-credentials.json``` file.
|
|
24
24
|
- ```logout``` - Logs out the user by deleting client credentials.
|
|
25
|
-
- ```app -c``` - Create a new App based on ```./bkperapp.json``` file
|
|
26
|
-
- ```app -u``` - Update an existing App based on ```./bkperapp.json``` file
|
|
25
|
+
- ```app -c``` - Create a new App based on ```./bkperapp.json``` file.
|
|
26
|
+
- ```app -u``` - Update an existing App based on ```./bkperapp.json``` file.
|
|
27
27
|
|
|
28
|
-
###
|
|
28
|
+
### Examples
|
|
29
|
+
```
|
|
30
|
+
npm bkper login
|
|
31
|
+
```
|
|
32
|
+
```
|
|
33
|
+
yarn bkper login
|
|
34
|
+
```
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
### Environment Variables
|
|
37
|
+
The following environment variable is necessary in order to communicate with the Bkper REST API:
|
|
31
38
|
|
|
32
39
|
```
|
|
33
40
|
BKPER_API_KEY=XXXX
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The ```app``` command also uses the following variables in order to perform App create/update operations:
|
|
44
|
+
|
|
45
|
+
```
|
|
34
46
|
BKPER_CLIENT_SECRET=YYYY
|
|
35
47
|
BKPER_USER_EMAILS="someone@gmail.com anotherone@altrostat.com"
|
|
36
48
|
BKPER_DEVELOPER_EMAIL=somedeveloer@mycompany.com
|
|
37
49
|
```
|
|
38
50
|
|
|
39
|
-
You can add a ```.env``` file at the root of your project with those variables and bkper will automatically load from it.
|
|
51
|
+
You can add a ```.env``` file at the root of your project with those variables and bkper will automatically load from it. Follow [these](https://bkper.com/docs/#rest-api-enabling) steps in order to configure a valid Bkper API key.
|
|
40
52
|
|
|
41
53
|
> WARNING: Never upload variables to the source code repository.
|
|
42
54
|
|
|
@@ -45,6 +57,3 @@ You can add a ```.env``` file at the root of your project with those variables a
|
|
|
45
57
|
- [Developer Docs](https://bkper.com/docs)
|
|
46
58
|
- [API Reference](https://bkper.com/docs/bkper-node/)
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
package/lib/index.d.ts
CHANGED
|
@@ -310,7 +310,7 @@ export declare class Amount {
|
|
|
310
310
|
/**
|
|
311
311
|
* Defines an App on Bkper.
|
|
312
312
|
*
|
|
313
|
-
* Apps can be installed on Books by users.
|
|
313
|
+
* Apps can be installed on Books by users.
|
|
314
314
|
*
|
|
315
315
|
* @public
|
|
316
316
|
*/
|
|
@@ -349,21 +349,34 @@ export declare class Bkper {
|
|
|
349
349
|
*
|
|
350
350
|
* @param id - The universal book id - The same bookId param of URL you access at app.bkper.com
|
|
351
351
|
*
|
|
352
|
+
* @returns The retrieved Book, for chaining
|
|
352
353
|
*/
|
|
353
354
|
static getBook(id: string): Promise<Book>;
|
|
354
355
|
/**
|
|
355
356
|
* Gets the current logged [[User]].
|
|
357
|
+
*
|
|
358
|
+
* @returns The retrieved User, for chaining
|
|
356
359
|
*/
|
|
357
360
|
static getUser(): Promise<User>;
|
|
358
361
|
/**
|
|
359
362
|
* Sets the API [[Config]] object.
|
|
363
|
+
*
|
|
364
|
+
* @param config - The Config object
|
|
360
365
|
*/
|
|
361
366
|
static setConfig(config: Config): void;
|
|
362
367
|
/**
|
|
368
|
+
* Sets the API key to identify the agent.
|
|
369
|
+
*
|
|
370
|
+
* @param key - The API key
|
|
371
|
+
*
|
|
372
|
+
* @returns The defined [[App]] object
|
|
373
|
+
*
|
|
363
374
|
* @deprecated Use `setConfig()` instead
|
|
364
375
|
*/
|
|
365
376
|
static setApiKey(key: string): App;
|
|
366
377
|
/**
|
|
378
|
+
* Sets the provider of the valid OAuth2 access token
|
|
379
|
+
*
|
|
367
380
|
* @deprecated Use `setConfig()` instead
|
|
368
381
|
*/
|
|
369
382
|
static setOAuthTokenProvider(oauthTokenProvider: () => Promise<string>): Promise<void>;
|
|
@@ -600,8 +613,27 @@ export declare class Book {
|
|
|
600
613
|
* Trigger [Balances Audit](https://help.bkper.com/en/articles/4412038-balances-audit) async process.
|
|
601
614
|
*/
|
|
602
615
|
audit(): void;
|
|
616
|
+
/**
|
|
617
|
+
* Gets the existing [[Integrations]] in the Book.
|
|
618
|
+
*
|
|
619
|
+
* @returns The existing Integration objects
|
|
620
|
+
*/
|
|
603
621
|
getIntegrations(): Promise<Integration[]>;
|
|
622
|
+
/**
|
|
623
|
+
* Creates a new [[Integration]] in the Book.
|
|
624
|
+
*
|
|
625
|
+
* @param integration - The Integration object or wrapped plain json
|
|
626
|
+
*
|
|
627
|
+
* @returns The created Integration object
|
|
628
|
+
*/
|
|
604
629
|
createIntegration(integration: bkper.Integration | Integration): Promise<Integration>;
|
|
630
|
+
/**
|
|
631
|
+
* Updates an existing [[Integration]] in the Book.
|
|
632
|
+
*
|
|
633
|
+
* @param integration - The Integration wrapped plain json
|
|
634
|
+
*
|
|
635
|
+
* @returns The updated Integration object
|
|
636
|
+
*/
|
|
605
637
|
updateIntegration(integration: bkper.Integration): Promise<Integration>;
|
|
606
638
|
/**
|
|
607
639
|
* Resumes a transaction iteration using a continuation token from a previous iterator.
|
|
@@ -761,7 +793,12 @@ export declare class Collection {
|
|
|
761
793
|
getBooks(): Book[];
|
|
762
794
|
}
|
|
763
795
|
|
|
764
|
-
|
|
796
|
+
/**
|
|
797
|
+
* This class defines the [[Bkper]] API Config.
|
|
798
|
+
*
|
|
799
|
+
* @public
|
|
800
|
+
*/
|
|
801
|
+
export declare interface Config {
|
|
765
802
|
/**
|
|
766
803
|
* The API key to identify the agent.
|
|
767
804
|
*
|
|
@@ -770,6 +807,9 @@ declare interface Config {
|
|
|
770
807
|
* See how to create your api key [here](https://cloud.google.com/docs/authentication/api-keys).
|
|
771
808
|
*/
|
|
772
809
|
apiKeyProvider?: () => Promise<string>;
|
|
810
|
+
/**
|
|
811
|
+
* Issue a valid OAuth2 access token with **https://www.googleapis.com/auth/userinfo.email** scope authorized.
|
|
812
|
+
*/
|
|
773
813
|
oauthTokenProvider?: () => Promise<string>;
|
|
774
814
|
/**
|
|
775
815
|
* Provides additional headers to append to the API request
|
|
@@ -777,6 +817,9 @@ declare interface Config {
|
|
|
777
817
|
requestHeadersProvider?: () => Promise<{
|
|
778
818
|
[key: string]: string;
|
|
779
819
|
}>;
|
|
820
|
+
/**
|
|
821
|
+
* Custom request error handler
|
|
822
|
+
*/
|
|
780
823
|
requestErrorHandler?: (error: any) => any;
|
|
781
824
|
/**
|
|
782
825
|
* Sets the base api url. Default to https://app.bkper.com/_ah/api/bkper
|
|
@@ -785,7 +828,7 @@ declare interface Config {
|
|
|
785
828
|
}
|
|
786
829
|
|
|
787
830
|
/**
|
|
788
|
-
* This class defines a Connection from an User to an external service.
|
|
831
|
+
* This class defines a Connection from an [[User]] to an external service.
|
|
789
832
|
*
|
|
790
833
|
* @public
|
|
791
834
|
*/
|
|
@@ -793,77 +836,103 @@ export declare class Connection {
|
|
|
793
836
|
|
|
794
837
|
constructor(json?: bkper.Connection);
|
|
795
838
|
/**
|
|
796
|
-
*
|
|
839
|
+
* Gets the wrapped plain json object of the Connection.
|
|
840
|
+
*
|
|
841
|
+
* @returns The Connection wrapped plain json object
|
|
797
842
|
*/
|
|
798
843
|
json(): bkper.Connection;
|
|
799
844
|
/**
|
|
800
|
-
*
|
|
845
|
+
* Gets the id of the Connection.
|
|
846
|
+
*
|
|
847
|
+
* @returns The Connection's id
|
|
801
848
|
*/
|
|
802
849
|
getId(): string;
|
|
803
850
|
/**
|
|
804
|
-
*
|
|
851
|
+
* Gets the agentId of the Connection.
|
|
852
|
+
*
|
|
853
|
+
* @returns The Connection's agentId
|
|
805
854
|
*/
|
|
806
855
|
getAgentId(): string;
|
|
807
856
|
/**
|
|
808
|
-
* Sets the Connection agentId
|
|
857
|
+
* Sets the Connection agentId.
|
|
809
858
|
*
|
|
810
|
-
* @
|
|
859
|
+
* @param agentId - The Connection agentId
|
|
860
|
+
*
|
|
861
|
+
* @returns The Connection, for chainning
|
|
811
862
|
*/
|
|
812
863
|
setAgentId(agentId: string): Connection;
|
|
813
864
|
/**
|
|
814
|
-
*
|
|
865
|
+
* Gets the name of the Connection.
|
|
866
|
+
*
|
|
867
|
+
* @returns The Connection name
|
|
815
868
|
*/
|
|
816
869
|
getName(): string;
|
|
817
870
|
/**
|
|
818
|
-
*
|
|
871
|
+
* Gets the email of the owner of the Connection.
|
|
872
|
+
*
|
|
873
|
+
* @returns The Connection owner's email
|
|
819
874
|
*/
|
|
820
875
|
getEmail(): string;
|
|
821
876
|
/**
|
|
822
877
|
* Sets the name of the Connection.
|
|
823
878
|
*
|
|
824
|
-
* @
|
|
879
|
+
* @param name - The name of the Connection
|
|
880
|
+
*
|
|
881
|
+
* @returns The Connection, for chainning
|
|
825
882
|
*/
|
|
826
883
|
setName(name: string): Connection;
|
|
827
884
|
/**
|
|
828
|
-
* Sets the universal unique identifier of
|
|
885
|
+
* Sets the universal unique identifier of the Connection.
|
|
829
886
|
*
|
|
830
|
-
* @
|
|
887
|
+
* @param uuid - The universal unique identifier of the Connection
|
|
888
|
+
*
|
|
889
|
+
* @returns The Connection, for chainning
|
|
831
890
|
*/
|
|
832
891
|
setUUID(uuid: string): Connection;
|
|
833
892
|
/**
|
|
834
|
-
*
|
|
893
|
+
* Gets the universal unique identifier of this Connection.
|
|
894
|
+
*
|
|
895
|
+
* @returns The Connection's universal unique identifier name
|
|
835
896
|
*/
|
|
836
897
|
getUUID(): string;
|
|
837
898
|
/**
|
|
838
|
-
*
|
|
899
|
+
* Gets the type of the Connection.
|
|
900
|
+
*
|
|
901
|
+
* @returns The Connection type
|
|
839
902
|
*/
|
|
840
903
|
getType(): "APP" | "BANK";
|
|
841
904
|
/**
|
|
842
|
-
* Sets the
|
|
905
|
+
* Sets the Connection type.
|
|
906
|
+
*
|
|
907
|
+
* @param type - The Connection type
|
|
843
908
|
*
|
|
844
|
-
* @returns
|
|
909
|
+
* @returns The Connection, for chainning
|
|
845
910
|
*/
|
|
846
911
|
setType(type: "APP" | "BANK"): Connection;
|
|
847
912
|
/**
|
|
848
|
-
* Gets the custom properties stored in
|
|
913
|
+
* Gets the custom properties stored in the Connection
|
|
914
|
+
*
|
|
915
|
+
* @returns Object with key/value pair properties
|
|
849
916
|
*/
|
|
850
917
|
getProperties(): {
|
|
851
918
|
[key: string]: string;
|
|
852
919
|
};
|
|
853
920
|
/**
|
|
854
|
-
* Sets the custom properties of the Connection
|
|
921
|
+
* Sets the custom properties of the Connection.
|
|
855
922
|
*
|
|
856
923
|
* @param properties - Object with key/value pair properties
|
|
857
924
|
*
|
|
858
|
-
* @returns
|
|
925
|
+
* @returns The Connection, for chainning
|
|
859
926
|
*/
|
|
860
927
|
setProperties(properties: {
|
|
861
928
|
[key: string]: string;
|
|
862
929
|
}): Connection;
|
|
863
930
|
/**
|
|
864
|
-
* Gets the property value for given keys. First property found will be retrieved
|
|
931
|
+
* Gets the property value for given keys. First property found will be retrieved.
|
|
865
932
|
*
|
|
866
933
|
* @param keys - The property key
|
|
934
|
+
*
|
|
935
|
+
* @returns The retrieved property value
|
|
867
936
|
*/
|
|
868
937
|
getProperty(...keys: string[]): string;
|
|
869
938
|
/**
|
|
@@ -871,27 +940,38 @@ export declare class Connection {
|
|
|
871
940
|
*
|
|
872
941
|
* @param key - The property key
|
|
873
942
|
* @param value - The property value
|
|
943
|
+
*
|
|
944
|
+
* @returns The Connection, for chaining
|
|
874
945
|
*/
|
|
875
946
|
setProperty(key: string, value: string): Connection;
|
|
876
947
|
/**
|
|
877
|
-
*
|
|
948
|
+
* Deletes a custom property stored in the Connection.
|
|
878
949
|
*
|
|
879
950
|
* @param key - The property key
|
|
880
951
|
*
|
|
881
|
-
* @returns
|
|
952
|
+
* @returns The Connection, for chainning
|
|
882
953
|
*/
|
|
883
954
|
deleteProperty(key: string): Connection;
|
|
884
955
|
/**
|
|
885
|
-
*
|
|
956
|
+
* Cleans any token property stored in the Connection.
|
|
886
957
|
*/
|
|
887
958
|
clearTokenProperties(): void;
|
|
888
959
|
/**
|
|
889
960
|
* Gets the custom properties keys stored in the Connection.
|
|
961
|
+
*
|
|
962
|
+
* @returns The retrieved property keys
|
|
890
963
|
*/
|
|
891
964
|
getPropertyKeys(): string[];
|
|
965
|
+
/**
|
|
966
|
+
* Gets the existing [[Integrations]] on the Connection.
|
|
967
|
+
*
|
|
968
|
+
* @returns The existing Integration objects
|
|
969
|
+
*/
|
|
892
970
|
getIntegrations(): Promise<Integration[]>;
|
|
893
971
|
/**
|
|
894
|
-
*
|
|
972
|
+
* Performs create new Connection.
|
|
973
|
+
*
|
|
974
|
+
* @returns The Connection, for chaining
|
|
895
975
|
*/
|
|
896
976
|
create(): Promise<Connection>;
|
|
897
977
|
}
|
|
@@ -1092,7 +1172,7 @@ export declare class Group {
|
|
|
1092
1172
|
}
|
|
1093
1173
|
|
|
1094
1174
|
/**
|
|
1095
|
-
* This class defines a Integration from an User to an external service.
|
|
1175
|
+
* This class defines a Integration from an [[User]] to an external service.
|
|
1096
1176
|
*
|
|
1097
1177
|
* @public
|
|
1098
1178
|
*/
|
|
@@ -1100,38 +1180,53 @@ export declare class Integration {
|
|
|
1100
1180
|
|
|
1101
1181
|
constructor(json: bkper.Integration);
|
|
1102
1182
|
/**
|
|
1103
|
-
*
|
|
1183
|
+
* Gets the wrapped plain json object of the Integration.
|
|
1184
|
+
*
|
|
1185
|
+
* @returns The Integration wrapped plain json object
|
|
1104
1186
|
*/
|
|
1105
1187
|
json(): bkper.Integration;
|
|
1188
|
+
/**
|
|
1189
|
+
* Gets the [[Book]] id of the Integration.
|
|
1190
|
+
*
|
|
1191
|
+
* @returns The Integration's Book id
|
|
1192
|
+
*/
|
|
1106
1193
|
getBookId(): string;
|
|
1107
1194
|
/**
|
|
1108
|
-
*
|
|
1195
|
+
* Gets the id of the Integration.
|
|
1196
|
+
*
|
|
1197
|
+
* @returns This Integration's id
|
|
1109
1198
|
*/
|
|
1110
1199
|
getId(): string;
|
|
1111
1200
|
/**
|
|
1112
|
-
*
|
|
1201
|
+
* Gets the name of the Integration.
|
|
1202
|
+
*
|
|
1203
|
+
* @returns The Integration's name
|
|
1113
1204
|
*/
|
|
1114
1205
|
getName(): string;
|
|
1115
1206
|
/**
|
|
1116
|
-
* Gets the custom properties stored in
|
|
1207
|
+
* Gets the custom properties stored in the Integration.
|
|
1208
|
+
*
|
|
1209
|
+
* @returns Object with key/value pair properties
|
|
1117
1210
|
*/
|
|
1118
1211
|
getProperties(): {
|
|
1119
1212
|
[key: string]: string;
|
|
1120
1213
|
};
|
|
1121
1214
|
/**
|
|
1122
|
-
* Sets the custom properties of the Integration
|
|
1215
|
+
* Sets the custom properties of the Integration.
|
|
1123
1216
|
*
|
|
1124
1217
|
* @param properties - Object with key/value pair properties
|
|
1125
1218
|
*
|
|
1126
|
-
* @returns
|
|
1219
|
+
* @returns The Integration, for chainning
|
|
1127
1220
|
*/
|
|
1128
1221
|
setProperties(properties: {
|
|
1129
1222
|
[key: string]: string;
|
|
1130
1223
|
}): Integration;
|
|
1131
1224
|
/**
|
|
1132
|
-
* Gets the property value for given keys. First property found will be retrieved
|
|
1225
|
+
* Gets the property value for given keys. First property found will be retrieved.
|
|
1133
1226
|
*
|
|
1134
1227
|
* @param keys - The property key
|
|
1228
|
+
*
|
|
1229
|
+
* @returns The retrieved property value
|
|
1135
1230
|
*/
|
|
1136
1231
|
getProperty(...keys: string[]): string;
|
|
1137
1232
|
/**
|
|
@@ -1139,14 +1234,16 @@ export declare class Integration {
|
|
|
1139
1234
|
*
|
|
1140
1235
|
* @param key - The property key
|
|
1141
1236
|
* @param value - The property value
|
|
1237
|
+
*
|
|
1238
|
+
* @returns The Integration, for chaining
|
|
1142
1239
|
*/
|
|
1143
1240
|
setProperty(key: string, value: string): Integration;
|
|
1144
1241
|
/**
|
|
1145
|
-
*
|
|
1242
|
+
* Deletes a custom property stored in the Integration.
|
|
1146
1243
|
*
|
|
1147
1244
|
* @param key - The property key
|
|
1148
1245
|
*
|
|
1149
|
-
* @returns
|
|
1246
|
+
* @returns The Integration, for chainning
|
|
1150
1247
|
*/
|
|
1151
1248
|
deleteProperty(key: string): Integration;
|
|
1152
1249
|
}
|
|
@@ -1291,6 +1388,14 @@ export declare class Transaction {
|
|
|
1291
1388
|
* @returns True if transaction is checked.
|
|
1292
1389
|
*/
|
|
1293
1390
|
isChecked(): boolean;
|
|
1391
|
+
/**
|
|
1392
|
+
* Set the check state of the Transaction.
|
|
1393
|
+
*
|
|
1394
|
+
* @param checked - The check state.
|
|
1395
|
+
*
|
|
1396
|
+
* @returns This Transaction, for chainning.
|
|
1397
|
+
*/
|
|
1398
|
+
setChecked(checked: boolean): Transaction;
|
|
1294
1399
|
/**
|
|
1295
1400
|
* @returns True if transaction is in trash.
|
|
1296
1401
|
*/
|
|
@@ -1634,21 +1739,36 @@ export declare class User {
|
|
|
1634
1739
|
|
|
1635
1740
|
constructor(wrapped: bkper.User);
|
|
1636
1741
|
/**
|
|
1637
|
-
*
|
|
1742
|
+
* Gets the id of the User.
|
|
1743
|
+
*
|
|
1744
|
+
* @returns The User's id
|
|
1638
1745
|
*/
|
|
1639
1746
|
getId(): string;
|
|
1640
1747
|
/**
|
|
1641
|
-
*
|
|
1748
|
+
* Gets the name of the User.
|
|
1749
|
+
*
|
|
1750
|
+
* @returns The User's name
|
|
1642
1751
|
*/
|
|
1643
1752
|
getName(): string;
|
|
1644
1753
|
/**
|
|
1645
|
-
*
|
|
1754
|
+
* Gets the full name of the User.
|
|
1755
|
+
*
|
|
1756
|
+
* @returns The User's full name
|
|
1646
1757
|
*/
|
|
1647
1758
|
getFullName(): string;
|
|
1648
1759
|
/**
|
|
1649
|
-
*
|
|
1760
|
+
* Gets the [[Connections]] of the User.
|
|
1761
|
+
*
|
|
1762
|
+
* @returns The retrieved Connection objects
|
|
1650
1763
|
*/
|
|
1651
1764
|
getConnections(): Promise<Connection[]>;
|
|
1765
|
+
/**
|
|
1766
|
+
* Gets a [[Connection]] of the User.
|
|
1767
|
+
*
|
|
1768
|
+
* @param id - The Connection's id
|
|
1769
|
+
*
|
|
1770
|
+
* @returns The retrieved Connection object
|
|
1771
|
+
*/
|
|
1652
1772
|
getConnection(id: string): Promise<Connection>;
|
|
1653
1773
|
}
|
|
1654
1774
|
|
package/lib/model/App.js
CHANGED
package/lib/model/Bkper.js
CHANGED
|
@@ -46,6 +46,7 @@ class Bkper {
|
|
|
46
46
|
*
|
|
47
47
|
* @param id - The universal book id - The same bookId param of URL you access at app.bkper.com
|
|
48
48
|
*
|
|
49
|
+
* @returns The retrieved Book, for chaining
|
|
49
50
|
*/
|
|
50
51
|
static getBook(id) {
|
|
51
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -55,6 +56,8 @@ class Bkper {
|
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Gets the current logged [[User]].
|
|
59
|
+
*
|
|
60
|
+
* @returns The retrieved User, for chaining
|
|
58
61
|
*/
|
|
59
62
|
static getUser() {
|
|
60
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -64,11 +67,19 @@ class Bkper {
|
|
|
64
67
|
}
|
|
65
68
|
/**
|
|
66
69
|
* Sets the API [[Config]] object.
|
|
70
|
+
*
|
|
71
|
+
* @param config - The Config object
|
|
67
72
|
*/
|
|
68
73
|
static setConfig(config) {
|
|
69
74
|
HttpApiRequest_1.HttpApiRequest.config = config;
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
77
|
+
* Sets the API key to identify the agent.
|
|
78
|
+
*
|
|
79
|
+
* @param key - The API key
|
|
80
|
+
*
|
|
81
|
+
* @returns The defined [[App]] object
|
|
82
|
+
*
|
|
72
83
|
* @deprecated Use `setConfig()` instead
|
|
73
84
|
*/
|
|
74
85
|
static setApiKey(key) {
|
|
@@ -76,6 +87,8 @@ class Bkper {
|
|
|
76
87
|
return new App_1.App();
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
90
|
+
* Sets the provider of the valid OAuth2 access token
|
|
91
|
+
*
|
|
79
92
|
* @deprecated Use `setConfig()` instead
|
|
80
93
|
*/
|
|
81
94
|
static setOAuthTokenProvider(oauthTokenProvider) {
|
package/lib/model/Book.js
CHANGED
|
@@ -400,6 +400,11 @@ class Book {
|
|
|
400
400
|
audit() {
|
|
401
401
|
BookService.audit(this.getId());
|
|
402
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Gets the existing [[Integrations]] in the Book.
|
|
405
|
+
*
|
|
406
|
+
* @returns The existing Integration objects
|
|
407
|
+
*/
|
|
403
408
|
getIntegrations() {
|
|
404
409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
405
410
|
const integrationsPlain = yield IntegrationService.listIntegrations(this.getId());
|
|
@@ -407,6 +412,13 @@ class Book {
|
|
|
407
412
|
return integrations;
|
|
408
413
|
});
|
|
409
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Creates a new [[Integration]] in the Book.
|
|
417
|
+
*
|
|
418
|
+
* @param integration - The Integration object or wrapped plain json
|
|
419
|
+
*
|
|
420
|
+
* @returns The created Integration object
|
|
421
|
+
*/
|
|
410
422
|
createIntegration(integration) {
|
|
411
423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
412
424
|
if (integration instanceof Integration_1.Integration) {
|
|
@@ -418,6 +430,13 @@ class Book {
|
|
|
418
430
|
return new Integration_1.Integration(integration);
|
|
419
431
|
});
|
|
420
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Updates an existing [[Integration]] in the Book.
|
|
435
|
+
*
|
|
436
|
+
* @param integration - The Integration wrapped plain json
|
|
437
|
+
*
|
|
438
|
+
* @returns The updated Integration object
|
|
439
|
+
*/
|
|
421
440
|
updateIntegration(integration) {
|
|
422
441
|
return __awaiter(this, void 0, void 0, function* () {
|
|
423
442
|
if (integration instanceof Integration_1.Integration) {
|
package/lib/model/Connection.js
CHANGED
|
@@ -32,7 +32,7 @@ exports.Connection = void 0;
|
|
|
32
32
|
const ConnectionService = __importStar(require("../service/connection-service"));
|
|
33
33
|
const Integration_1 = require("./Integration");
|
|
34
34
|
/**
|
|
35
|
-
* This class defines a Connection from an User to an external service.
|
|
35
|
+
* This class defines a Connection from an [[User]] to an external service.
|
|
36
36
|
*
|
|
37
37
|
* @public
|
|
38
38
|
*/
|
|
@@ -41,40 +41,52 @@ class Connection {
|
|
|
41
41
|
this.wrapped = json || {};
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Gets the wrapped plain json object of the Connection.
|
|
45
|
+
*
|
|
46
|
+
* @returns The Connection wrapped plain json object
|
|
45
47
|
*/
|
|
46
48
|
json() {
|
|
47
49
|
return this.wrapped;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
|
-
*
|
|
52
|
+
* Gets the id of the Connection.
|
|
53
|
+
*
|
|
54
|
+
* @returns The Connection's id
|
|
51
55
|
*/
|
|
52
56
|
getId() {
|
|
53
57
|
return this.wrapped.id;
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
56
|
-
*
|
|
60
|
+
* Gets the agentId of the Connection.
|
|
61
|
+
*
|
|
62
|
+
* @returns The Connection's agentId
|
|
57
63
|
*/
|
|
58
64
|
getAgentId() {
|
|
59
65
|
return this.wrapped.agentId;
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
62
|
-
* Sets the Connection agentId
|
|
68
|
+
* Sets the Connection agentId.
|
|
63
69
|
*
|
|
64
|
-
* @
|
|
70
|
+
* @param agentId - The Connection agentId
|
|
71
|
+
*
|
|
72
|
+
* @returns The Connection, for chainning
|
|
65
73
|
*/
|
|
66
74
|
setAgentId(agentId) {
|
|
67
75
|
this.wrapped.agentId = agentId;
|
|
68
76
|
return this;
|
|
69
77
|
}
|
|
70
78
|
/**
|
|
71
|
-
*
|
|
79
|
+
* Gets the name of the Connection.
|
|
80
|
+
*
|
|
81
|
+
* @returns The Connection name
|
|
72
82
|
*/
|
|
73
83
|
getName() {
|
|
74
84
|
return this.wrapped.name;
|
|
75
85
|
}
|
|
76
86
|
/**
|
|
77
|
-
*
|
|
87
|
+
* Gets the email of the owner of the Connection.
|
|
88
|
+
*
|
|
89
|
+
* @returns The Connection owner's email
|
|
78
90
|
*/
|
|
79
91
|
getEmail() {
|
|
80
92
|
return this.wrapped.email;
|
|
@@ -82,63 +94,77 @@ class Connection {
|
|
|
82
94
|
/**
|
|
83
95
|
* Sets the name of the Connection.
|
|
84
96
|
*
|
|
85
|
-
* @
|
|
97
|
+
* @param name - The name of the Connection
|
|
98
|
+
*
|
|
99
|
+
* @returns The Connection, for chainning
|
|
86
100
|
*/
|
|
87
101
|
setName(name) {
|
|
88
102
|
this.wrapped.name = name;
|
|
89
103
|
return this;
|
|
90
104
|
}
|
|
91
105
|
/**
|
|
92
|
-
* Sets the universal unique identifier of
|
|
106
|
+
* Sets the universal unique identifier of the Connection.
|
|
107
|
+
*
|
|
108
|
+
* @param uuid - The universal unique identifier of the Connection
|
|
93
109
|
*
|
|
94
|
-
* @returns
|
|
110
|
+
* @returns The Connection, for chainning
|
|
95
111
|
*/
|
|
96
112
|
setUUID(uuid) {
|
|
97
113
|
this.wrapped.uuid = uuid;
|
|
98
114
|
return this;
|
|
99
115
|
}
|
|
100
116
|
/**
|
|
101
|
-
*
|
|
117
|
+
* Gets the universal unique identifier of this Connection.
|
|
118
|
+
*
|
|
119
|
+
* @returns The Connection's universal unique identifier name
|
|
102
120
|
*/
|
|
103
121
|
getUUID() {
|
|
104
122
|
return this.wrapped.uuid;
|
|
105
123
|
}
|
|
106
124
|
/**
|
|
107
|
-
*
|
|
125
|
+
* Gets the type of the Connection.
|
|
126
|
+
*
|
|
127
|
+
* @returns The Connection type
|
|
108
128
|
*/
|
|
109
129
|
getType() {
|
|
110
130
|
return this.wrapped.type;
|
|
111
131
|
}
|
|
112
132
|
/**
|
|
113
|
-
* Sets the
|
|
133
|
+
* Sets the Connection type.
|
|
114
134
|
*
|
|
115
|
-
* @
|
|
135
|
+
* @param type - The Connection type
|
|
136
|
+
*
|
|
137
|
+
* @returns The Connection, for chainning
|
|
116
138
|
*/
|
|
117
139
|
setType(type) {
|
|
118
140
|
this.wrapped.type = type;
|
|
119
141
|
return this;
|
|
120
142
|
}
|
|
121
143
|
/**
|
|
122
|
-
* Gets the custom properties stored in
|
|
144
|
+
* Gets the custom properties stored in the Connection
|
|
145
|
+
*
|
|
146
|
+
* @returns Object with key/value pair properties
|
|
123
147
|
*/
|
|
124
148
|
getProperties() {
|
|
125
149
|
return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
|
|
126
150
|
}
|
|
127
151
|
/**
|
|
128
|
-
* Sets the custom properties of the Connection
|
|
152
|
+
* Sets the custom properties of the Connection.
|
|
129
153
|
*
|
|
130
154
|
* @param properties - Object with key/value pair properties
|
|
131
155
|
*
|
|
132
|
-
* @returns
|
|
156
|
+
* @returns The Connection, for chainning
|
|
133
157
|
*/
|
|
134
158
|
setProperties(properties) {
|
|
135
159
|
this.wrapped.properties = Object.assign({}, properties);
|
|
136
160
|
return this;
|
|
137
161
|
}
|
|
138
162
|
/**
|
|
139
|
-
* Gets the property value for given keys. First property found will be retrieved
|
|
163
|
+
* Gets the property value for given keys. First property found will be retrieved.
|
|
140
164
|
*
|
|
141
165
|
* @param keys - The property key
|
|
166
|
+
*
|
|
167
|
+
* @returns The retrieved property value
|
|
142
168
|
*/
|
|
143
169
|
getProperty(...keys) {
|
|
144
170
|
for (let index = 0; index < keys.length; index++) {
|
|
@@ -155,6 +181,8 @@ class Connection {
|
|
|
155
181
|
*
|
|
156
182
|
* @param key - The property key
|
|
157
183
|
* @param value - The property value
|
|
184
|
+
*
|
|
185
|
+
* @returns The Connection, for chaining
|
|
158
186
|
*/
|
|
159
187
|
setProperty(key, value) {
|
|
160
188
|
if (key == null || key.trim() == '') {
|
|
@@ -167,24 +195,26 @@ class Connection {
|
|
|
167
195
|
return this;
|
|
168
196
|
}
|
|
169
197
|
/**
|
|
170
|
-
*
|
|
198
|
+
* Deletes a custom property stored in the Connection.
|
|
171
199
|
*
|
|
172
200
|
* @param key - The property key
|
|
173
201
|
*
|
|
174
|
-
* @returns
|
|
202
|
+
* @returns The Connection, for chainning
|
|
175
203
|
*/
|
|
176
204
|
deleteProperty(key) {
|
|
177
205
|
this.setProperty(key, null);
|
|
178
206
|
return this;
|
|
179
207
|
}
|
|
180
208
|
/**
|
|
181
|
-
*
|
|
209
|
+
* Cleans any token property stored in the Connection.
|
|
182
210
|
*/
|
|
183
211
|
clearTokenProperties() {
|
|
184
212
|
this.getPropertyKeys().filter(key => key.includes("token")).forEach(key => this.deleteProperty(key));
|
|
185
213
|
}
|
|
186
214
|
/**
|
|
187
215
|
* Gets the custom properties keys stored in the Connection.
|
|
216
|
+
*
|
|
217
|
+
* @returns The retrieved property keys
|
|
188
218
|
*/
|
|
189
219
|
getPropertyKeys() {
|
|
190
220
|
let properties = this.getProperties();
|
|
@@ -199,6 +229,11 @@ class Connection {
|
|
|
199
229
|
propertyKeys = propertyKeys.sort();
|
|
200
230
|
return propertyKeys;
|
|
201
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Gets the existing [[Integrations]] on the Connection.
|
|
234
|
+
*
|
|
235
|
+
* @returns The existing Integration objects
|
|
236
|
+
*/
|
|
202
237
|
getIntegrations() {
|
|
203
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
239
|
const integrationsPlain = yield ConnectionService.listIntegrations(this.getId());
|
|
@@ -207,7 +242,9 @@ class Connection {
|
|
|
207
242
|
});
|
|
208
243
|
}
|
|
209
244
|
/**
|
|
210
|
-
*
|
|
245
|
+
* Performs create new Connection.
|
|
246
|
+
*
|
|
247
|
+
* @returns The Connection, for chaining
|
|
211
248
|
*/
|
|
212
249
|
create() {
|
|
213
250
|
return __awaiter(this, void 0, void 0, function* () {
|
package/lib/model/Integration.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Integration = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* This class defines a Integration from an User to an external service.
|
|
5
|
+
* This class defines a Integration from an [[User]] to an external service.
|
|
6
6
|
*
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
@@ -11,47 +11,62 @@ class Integration {
|
|
|
11
11
|
this.wrapped = json;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Gets the wrapped plain json object of the Integration.
|
|
15
|
+
*
|
|
16
|
+
* @returns The Integration wrapped plain json object
|
|
15
17
|
*/
|
|
16
18
|
json() {
|
|
17
19
|
return this.wrapped;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Gets the [[Book]] id of the Integration.
|
|
23
|
+
*
|
|
24
|
+
* @returns The Integration's Book id
|
|
25
|
+
*/
|
|
19
26
|
getBookId() {
|
|
20
27
|
return this.wrapped.bookId;
|
|
21
28
|
}
|
|
22
29
|
/**
|
|
23
|
-
*
|
|
30
|
+
* Gets the id of the Integration.
|
|
31
|
+
*
|
|
32
|
+
* @returns This Integration's id
|
|
24
33
|
*/
|
|
25
34
|
getId() {
|
|
26
35
|
return this.wrapped.id;
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
29
|
-
*
|
|
38
|
+
* Gets the name of the Integration.
|
|
39
|
+
*
|
|
40
|
+
* @returns The Integration's name
|
|
30
41
|
*/
|
|
31
42
|
getName() {
|
|
32
43
|
return this.wrapped.name;
|
|
33
44
|
}
|
|
34
45
|
/**
|
|
35
|
-
* Gets the custom properties stored in
|
|
46
|
+
* Gets the custom properties stored in the Integration.
|
|
47
|
+
*
|
|
48
|
+
* @returns Object with key/value pair properties
|
|
36
49
|
*/
|
|
37
50
|
getProperties() {
|
|
38
51
|
return this.wrapped.properties != null ? Object.assign({}, this.wrapped.properties) : {};
|
|
39
52
|
}
|
|
40
53
|
/**
|
|
41
|
-
* Sets the custom properties of the Integration
|
|
54
|
+
* Sets the custom properties of the Integration.
|
|
42
55
|
*
|
|
43
56
|
* @param properties - Object with key/value pair properties
|
|
44
57
|
*
|
|
45
|
-
* @returns
|
|
58
|
+
* @returns The Integration, for chainning
|
|
46
59
|
*/
|
|
47
60
|
setProperties(properties) {
|
|
48
61
|
this.wrapped.properties = Object.assign({}, properties);
|
|
49
62
|
return this;
|
|
50
63
|
}
|
|
51
64
|
/**
|
|
52
|
-
* Gets the property value for given keys. First property found will be retrieved
|
|
65
|
+
* Gets the property value for given keys. First property found will be retrieved.
|
|
53
66
|
*
|
|
54
67
|
* @param keys - The property key
|
|
68
|
+
*
|
|
69
|
+
* @returns The retrieved property value
|
|
55
70
|
*/
|
|
56
71
|
getProperty(...keys) {
|
|
57
72
|
for (let index = 0; index < keys.length; index++) {
|
|
@@ -68,6 +83,8 @@ class Integration {
|
|
|
68
83
|
*
|
|
69
84
|
* @param key - The property key
|
|
70
85
|
* @param value - The property value
|
|
86
|
+
*
|
|
87
|
+
* @returns The Integration, for chaining
|
|
71
88
|
*/
|
|
72
89
|
setProperty(key, value) {
|
|
73
90
|
if (key == null || key.trim() == '') {
|
|
@@ -80,11 +97,11 @@ class Integration {
|
|
|
80
97
|
return this;
|
|
81
98
|
}
|
|
82
99
|
/**
|
|
83
|
-
*
|
|
100
|
+
* Deletes a custom property stored in the Integration.
|
|
84
101
|
*
|
|
85
102
|
* @param key - The property key
|
|
86
103
|
*
|
|
87
|
-
* @returns
|
|
104
|
+
* @returns The Integration, for chainning
|
|
88
105
|
*/
|
|
89
106
|
deleteProperty(key) {
|
|
90
107
|
this.setProperty(key, null);
|
package/lib/model/Transaction.js
CHANGED
|
@@ -98,6 +98,17 @@ class Transaction {
|
|
|
98
98
|
isChecked() {
|
|
99
99
|
return this.wrapped.checked;
|
|
100
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Set the check state of the Transaction.
|
|
103
|
+
*
|
|
104
|
+
* @param checked - The check state.
|
|
105
|
+
*
|
|
106
|
+
* @returns This Transaction, for chainning.
|
|
107
|
+
*/
|
|
108
|
+
setChecked(checked) {
|
|
109
|
+
this.wrapped.checked = checked;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
101
112
|
/**
|
|
102
113
|
* @returns True if transaction is in trash.
|
|
103
114
|
*/
|
package/lib/model/User.js
CHANGED
|
@@ -41,25 +41,33 @@ class User {
|
|
|
41
41
|
this.wrapped = wrapped;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Gets the id of the User.
|
|
45
|
+
*
|
|
46
|
+
* @returns The User's id
|
|
45
47
|
*/
|
|
46
48
|
getId() {
|
|
47
49
|
return this.wrapped.id;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
|
-
*
|
|
52
|
+
* Gets the name of the User.
|
|
53
|
+
*
|
|
54
|
+
* @returns The User's name
|
|
51
55
|
*/
|
|
52
56
|
getName() {
|
|
53
57
|
return this.wrapped.name;
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
56
|
-
*
|
|
60
|
+
* Gets the full name of the User.
|
|
61
|
+
*
|
|
62
|
+
* @returns The User's full name
|
|
57
63
|
*/
|
|
58
64
|
getFullName() {
|
|
59
65
|
return this.wrapped.fullName;
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
62
|
-
*
|
|
68
|
+
* Gets the [[Connections]] of the User.
|
|
69
|
+
*
|
|
70
|
+
* @returns The retrieved Connection objects
|
|
63
71
|
*/
|
|
64
72
|
getConnections() {
|
|
65
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -67,6 +75,13 @@ class User {
|
|
|
67
75
|
return json.map(c => new Connection_1.Connection(c));
|
|
68
76
|
});
|
|
69
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets a [[Connection]] of the User.
|
|
80
|
+
*
|
|
81
|
+
* @param id - The Connection's id
|
|
82
|
+
*
|
|
83
|
+
* @returns The retrieved Connection object
|
|
84
|
+
*/
|
|
70
85
|
getConnection(id) {
|
|
71
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
87
|
const json = yield ConnectionService.getConnection(id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Node.js client for Bkper REST API",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"open": "^7.3.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@bkper/bkper-api-types": "^5.
|
|
49
|
+
"@bkper/bkper-api-types": "^5.9.0",
|
|
50
50
|
"@microsoft/api-extractor": "^7.12.1",
|
|
51
51
|
"@types/big.js": "^6.0.2",
|
|
52
52
|
"@types/chai": "^4.2.14",
|