bkper-js 1.4.0 → 1.5.1
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 +1 -1
- package/lib/index.d.ts +20 -1
- package/lib/model/Bkper.js +15 -0
- package/lib/model/Book.js +11 -0
- package/lib/service/book-service.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[Bkper REST API]: https://bkper.com/docs/#rest-apis
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/bkper)
|
|
3
|
+
[](https://www.npmjs.com/package/bkper-js)
|
|
4
4
|
|
|
5
5
|
bkper-js library is a simple and secure way to access the [Bkper REST API] on Node.js and modern browsers.
|
|
6
6
|
|
package/lib/index.d.ts
CHANGED
|
@@ -387,6 +387,19 @@ export declare class App {
|
|
|
387
387
|
* @public
|
|
388
388
|
*/
|
|
389
389
|
export declare class Bkper {
|
|
390
|
+
/**
|
|
391
|
+
* Instantiate a new [[Book]]
|
|
392
|
+
*
|
|
393
|
+
* Example:
|
|
394
|
+
* ```js
|
|
395
|
+
* var book = Bkper.newBook()
|
|
396
|
+
* .setName('My New Book')
|
|
397
|
+
* .setFractionDigits(2)
|
|
398
|
+
* .setDecimalSeparator('DOT')
|
|
399
|
+
* .create();
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
static newBook(): Book;
|
|
390
403
|
/**
|
|
391
404
|
* Gets the [[Book]] with the specified bookId from url param.
|
|
392
405
|
*
|
|
@@ -828,6 +841,12 @@ export declare class Book {
|
|
|
828
841
|
* Retrieve a file by id
|
|
829
842
|
*/
|
|
830
843
|
getFile(id: string): Promise<File>;
|
|
844
|
+
/**
|
|
845
|
+
* Performs create new Book.
|
|
846
|
+
*
|
|
847
|
+
* @returns The created Book object
|
|
848
|
+
*/
|
|
849
|
+
create(): Promise<Book>;
|
|
831
850
|
/**
|
|
832
851
|
* Perform update Book, applying pending changes.
|
|
833
852
|
*/
|
|
@@ -877,7 +896,7 @@ export declare interface Config {
|
|
|
877
896
|
/**
|
|
878
897
|
* Issue a valid OAuth2 access token with **https://www.googleapis.com/auth/userinfo.email** scope authorized.
|
|
879
898
|
*/
|
|
880
|
-
oauthTokenProvider?: () => Promise<string>;
|
|
899
|
+
oauthTokenProvider?: () => Promise<string | undefined>;
|
|
881
900
|
/**
|
|
882
901
|
* Provides additional headers to append to the API request
|
|
883
902
|
*/
|
package/lib/model/Bkper.js
CHANGED
|
@@ -32,6 +32,21 @@ import { User } from "./User.js";
|
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
34
|
export class Bkper {
|
|
35
|
+
/**
|
|
36
|
+
* Instantiate a new [[Book]]
|
|
37
|
+
*
|
|
38
|
+
* Example:
|
|
39
|
+
* ```js
|
|
40
|
+
* var book = Bkper.newBook()
|
|
41
|
+
* .setName('My New Book')
|
|
42
|
+
* .setFractionDigits(2)
|
|
43
|
+
* .setDecimalSeparator('DOT')
|
|
44
|
+
* .create();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
static newBook() {
|
|
48
|
+
return new Book();
|
|
49
|
+
}
|
|
35
50
|
/**
|
|
36
51
|
* Gets the [[Book]] with the specified bookId from url param.
|
|
37
52
|
*
|
package/lib/model/Book.js
CHANGED
|
@@ -689,6 +689,17 @@ export class Book {
|
|
|
689
689
|
return file;
|
|
690
690
|
});
|
|
691
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* Performs create new Book.
|
|
694
|
+
*
|
|
695
|
+
* @returns The created Book object
|
|
696
|
+
*/
|
|
697
|
+
create() {
|
|
698
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
699
|
+
this.wrapped = yield BookService.createBook(this.wrapped);
|
|
700
|
+
return this;
|
|
701
|
+
});
|
|
702
|
+
}
|
|
692
703
|
/**
|
|
693
704
|
* Perform update Book, applying pending changes.
|
|
694
705
|
*/
|
|
@@ -31,6 +31,12 @@ export function loadBook(bookId) {
|
|
|
31
31
|
return response.data;
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
export function createBook(book) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
let response = yield new HttpBooksApiV5Request('').setMethod('POST').setPayload(book).fetch();
|
|
37
|
+
return response.data;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
34
40
|
export function updateBook(bookId, book) {
|
|
35
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
42
|
var response = yield new HttpBooksApiV5Request(`${bookId}`).setMethod('PUT').setPayload(book).fetch();
|