timber-node 0.2.1 → 0.2.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/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/invoiceItem.d.ts +86 -0
- package/dist/invoiceItem.js +72 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { BankStatementService } from './bankStatement';
|
|
|
14
14
|
import { CompanyService } from './company';
|
|
15
15
|
import { InvoiceNumberService } from './invoiceNumber';
|
|
16
16
|
import { InvoiceTemplateService } from './invoiceTemplates';
|
|
17
|
+
import { InvoiceItemService } from './invoiceItem';
|
|
17
18
|
declare class TimberClient {
|
|
18
19
|
expense: ExpenseService;
|
|
19
20
|
expenseCategory: ExpenseCategoryService;
|
|
@@ -31,6 +32,7 @@ declare class TimberClient {
|
|
|
31
32
|
company: CompanyService;
|
|
32
33
|
invoiceNumber: InvoiceNumberService;
|
|
33
34
|
invoiceTemplate: InvoiceTemplateService;
|
|
35
|
+
invoiceItem: InvoiceItemService;
|
|
34
36
|
constructor(apiKey: string, options?: {
|
|
35
37
|
baseURL?: string;
|
|
36
38
|
});
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const bankStatement_1 = require("./bankStatement");
|
|
|
21
21
|
const company_1 = require("./company");
|
|
22
22
|
const invoiceNumber_1 = require("./invoiceNumber");
|
|
23
23
|
const invoiceTemplates_1 = require("./invoiceTemplates");
|
|
24
|
+
const invoiceItem_1 = require("./invoiceItem");
|
|
24
25
|
class TimberClient {
|
|
25
26
|
constructor(apiKey, options = {}) {
|
|
26
27
|
const baseURL = `${options.baseURL || 'http://localhost:4010'}/api/v1/user/sdk`;
|
|
@@ -31,6 +32,9 @@ class TimberClient {
|
|
|
31
32
|
},
|
|
32
33
|
});
|
|
33
34
|
delete http.defaults.headers.post['Content-Type'];
|
|
35
|
+
// http.interceptors.response.use((response) => {
|
|
36
|
+
// return response.data?.data ?? response.data;
|
|
37
|
+
// });
|
|
34
38
|
this.expense = new expense_1.ExpenseService(http);
|
|
35
39
|
this.expenseCategory = new expenseCategory_1.ExpenseCategoryService(http);
|
|
36
40
|
this.rawExpense = new rawExpense_1.RawExpenseService(http);
|
|
@@ -47,6 +51,7 @@ class TimberClient {
|
|
|
47
51
|
this.company = new company_1.CompanyService(http);
|
|
48
52
|
this.invoiceNumber = new invoiceNumber_1.InvoiceNumberService(http);
|
|
49
53
|
this.invoiceTemplate = new invoiceTemplates_1.InvoiceTemplateService(http);
|
|
54
|
+
this.invoiceItem = new invoiceItem_1.InvoiceItemService(http);
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
const createClient = (apiKey, options = {}) => {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
export interface CreateInvoiceItemRequest {
|
|
3
|
+
title: string;
|
|
4
|
+
rate: number;
|
|
5
|
+
discount: number;
|
|
6
|
+
vat: number;
|
|
7
|
+
}
|
|
8
|
+
export type UpdateInvoiceItemRequest = Partial<CreateInvoiceItemRequest>;
|
|
9
|
+
export interface InvoiceItem {
|
|
10
|
+
_id: string;
|
|
11
|
+
company: string;
|
|
12
|
+
title: string;
|
|
13
|
+
rate: number;
|
|
14
|
+
discount: number;
|
|
15
|
+
vat: number;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
}
|
|
19
|
+
export interface InvoiceItemQueryParams {
|
|
20
|
+
page?: number;
|
|
21
|
+
limit?: number;
|
|
22
|
+
sort?: string;
|
|
23
|
+
search?: string;
|
|
24
|
+
filters?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Service for Invoice Item
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
32
|
+
* const client = createClient('your-api-key');
|
|
33
|
+
* const InvoiceItem = await client.InvoiceItem.list({});
|
|
34
|
+
* console.log(InvoiceItem.data);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class InvoiceItemService {
|
|
38
|
+
private http;
|
|
39
|
+
constructor(http: AxiosInstance);
|
|
40
|
+
/**
|
|
41
|
+
* Fetch a paginated list of invoice templates.
|
|
42
|
+
* @param params
|
|
43
|
+
* @returns
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const invoiceItems = await client.InvoiceItem.list();
|
|
48
|
+
* console.log(invoiceItems.data);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
list(): Promise<AxiosResponse<InvoiceItem>>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a new invoice template.
|
|
54
|
+
*
|
|
55
|
+
* @param data
|
|
56
|
+
* @returns
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const newInvoiceItem = {
|
|
61
|
+
* title: "Invoice Item",
|
|
62
|
+
* rate: 100,
|
|
63
|
+
* discount: 0,
|
|
64
|
+
* vat: 0,
|
|
65
|
+
* };
|
|
66
|
+
* const response = await client.InvoiceItem.create(newInvoiceItem);
|
|
67
|
+
* console.log(response.data);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
create(data: CreateInvoiceItemRequest): Promise<AxiosResponse<InvoiceItem>>;
|
|
71
|
+
/**
|
|
72
|
+
* Update an existing invoice template.
|
|
73
|
+
*
|
|
74
|
+
* @param id
|
|
75
|
+
* @param data
|
|
76
|
+
* @returns
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const updates = { title: "Invoice Item" };
|
|
81
|
+
* const updated = await client.InvoiceItem.update('invoice_template_id_here', updates);
|
|
82
|
+
* console.log(updated.data);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
update(id: string, data: CreateInvoiceItemRequest): Promise<AxiosResponse<InvoiceItem>>;
|
|
86
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvoiceItemService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Service for Invoice Item
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
10
|
+
* const client = createClient('your-api-key');
|
|
11
|
+
* const InvoiceItem = await client.InvoiceItem.list({});
|
|
12
|
+
* console.log(InvoiceItem.data);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
class InvoiceItemService {
|
|
16
|
+
constructor(http) {
|
|
17
|
+
this.http = http;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fetch a paginated list of invoice templates.
|
|
21
|
+
* @param params
|
|
22
|
+
* @returns
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const invoiceItems = await client.InvoiceItem.list();
|
|
27
|
+
* console.log(invoiceItems.data);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
async list() {
|
|
31
|
+
return await this.http.get('/customer/invoice-item');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a new invoice template.
|
|
35
|
+
*
|
|
36
|
+
* @param data
|
|
37
|
+
* @returns
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const newInvoiceItem = {
|
|
42
|
+
* title: "Invoice Item",
|
|
43
|
+
* rate: 100,
|
|
44
|
+
* discount: 0,
|
|
45
|
+
* vat: 0,
|
|
46
|
+
* };
|
|
47
|
+
* const response = await client.InvoiceItem.create(newInvoiceItem);
|
|
48
|
+
* console.log(response.data);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
async create(data) {
|
|
52
|
+
return await this.http.post('/customer/invoice-item', data);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Update an existing invoice template.
|
|
56
|
+
*
|
|
57
|
+
* @param id
|
|
58
|
+
* @param data
|
|
59
|
+
* @returns
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const updates = { title: "Invoice Item" };
|
|
64
|
+
* const updated = await client.InvoiceItem.update('invoice_template_id_here', updates);
|
|
65
|
+
* console.log(updated.data);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
async update(id, data) {
|
|
69
|
+
return await this.http.patch(`/customer/invoice-item/${id}`, data);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.InvoiceItemService = InvoiceItemService;
|