timber-node 0.1.8 → 0.2.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/dist/billPayment.d.ts +1 -1
- package/dist/billPayment.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/invoice.d.ts +1 -0
- package/dist/invoiceNumber.d.ts +78 -0
- package/dist/invoiceNumber.js +64 -0
- package/dist/invoicePayment.js +2 -2
- package/dist/invoiceTemplates.d.ts +143 -0
- package/dist/invoiceTemplates.js +116 -0
- package/dist/vendorPayment.d.ts +1 -0
- package/package.json +1 -1
package/dist/billPayment.d.ts
CHANGED
package/dist/billPayment.js
CHANGED
|
@@ -77,7 +77,7 @@ class BillPaymentService {
|
|
|
77
77
|
}
|
|
78
78
|
formData.append('amount', data.amount.toString());
|
|
79
79
|
if (data.file) {
|
|
80
|
-
formData.append('file', data.file
|
|
80
|
+
formData.append('file', data.file);
|
|
81
81
|
}
|
|
82
82
|
return await this.http.post('/customer/purchase/payment-record', formData, {
|
|
83
83
|
headers,
|
|
@@ -116,7 +116,7 @@ class BillPaymentService {
|
|
|
116
116
|
}
|
|
117
117
|
formData.append('amount', data.amount.toString());
|
|
118
118
|
if (data.file) {
|
|
119
|
-
formData.append('file', data.file
|
|
119
|
+
formData.append('file', data.file);
|
|
120
120
|
}
|
|
121
121
|
return await this.http.put(`/customer/purchase/payment-record/${id}`, formData, {
|
|
122
122
|
headers,
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ import { EmployeeService } from './employee';
|
|
|
12
12
|
import { ChequeService } from './cheque';
|
|
13
13
|
import { BankStatementService } from './bankStatement';
|
|
14
14
|
import { CompanyService } from './company';
|
|
15
|
+
import { InvoiceNumberService } from './invoiceNumber';
|
|
16
|
+
import { InvoiceTemplateService } from './invoiceTemplates';
|
|
15
17
|
declare class TimberClient {
|
|
16
18
|
expense: ExpenseService;
|
|
17
19
|
expenseCategory: ExpenseCategoryService;
|
|
@@ -27,6 +29,8 @@ declare class TimberClient {
|
|
|
27
29
|
cheque: ChequeService;
|
|
28
30
|
bankStatement: BankStatementService;
|
|
29
31
|
company: CompanyService;
|
|
32
|
+
invoiceNumber: InvoiceNumberService;
|
|
33
|
+
invoiceTemplate: InvoiceTemplateService;
|
|
30
34
|
constructor(apiKey: string, options?: {
|
|
31
35
|
baseURL?: string;
|
|
32
36
|
});
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,8 @@ const employee_1 = require("./employee");
|
|
|
19
19
|
const cheque_1 = require("./cheque");
|
|
20
20
|
const bankStatement_1 = require("./bankStatement");
|
|
21
21
|
const company_1 = require("./company");
|
|
22
|
+
const invoiceNumber_1 = require("./invoiceNumber");
|
|
23
|
+
const invoiceTemplates_1 = require("./invoiceTemplates");
|
|
22
24
|
class TimberClient {
|
|
23
25
|
constructor(apiKey, options = {}) {
|
|
24
26
|
const baseURL = `${options.baseURL || 'http://localhost:4010'}/api/v1/user/sdk`;
|
|
@@ -43,6 +45,8 @@ class TimberClient {
|
|
|
43
45
|
this.cheque = new cheque_1.ChequeService(http);
|
|
44
46
|
this.bankStatement = new bankStatement_1.BankStatementService(http);
|
|
45
47
|
this.company = new company_1.CompanyService(http);
|
|
48
|
+
this.invoiceNumber = new invoiceNumber_1.InvoiceNumberService(http);
|
|
49
|
+
this.invoiceTemplate = new invoiceTemplates_1.InvoiceTemplateService(http);
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
const createClient = (apiKey, options = {}) => {
|
package/dist/invoice.d.ts
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
export interface CreateInvoiceNumberRequest {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
next_number: number;
|
|
5
|
+
sequence_length: number;
|
|
6
|
+
prefix: string;
|
|
7
|
+
}
|
|
8
|
+
export type UpdateInvoiceNumberRequest = Partial<CreateInvoiceNumberRequest>;
|
|
9
|
+
export interface InvoiceNumber {
|
|
10
|
+
_id: string;
|
|
11
|
+
company: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
next_number: number;
|
|
14
|
+
sequence_length: number;
|
|
15
|
+
prefix: string;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
}
|
|
19
|
+
export interface InvoiceNumberQueryParams {
|
|
20
|
+
search?: string;
|
|
21
|
+
}
|
|
22
|
+
export type NextNumberResponse = {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
next_invoice_number: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Service for Invoice Number
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
32
|
+
* const client = createClient('your-api-key');
|
|
33
|
+
* const invoiceNumber = await client.invoiceNumber.get();
|
|
34
|
+
* console.log(invoiceNumber.data);
|
|
35
|
+
*/
|
|
36
|
+
export declare class InvoiceNumberService {
|
|
37
|
+
private http;
|
|
38
|
+
constructor(http: AxiosInstance);
|
|
39
|
+
/**
|
|
40
|
+
* Fetch a single invoice number.
|
|
41
|
+
*
|
|
42
|
+
* @returns Invoice number object
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const invoiceNumber = await client.invoiceNumber.get();
|
|
47
|
+
* console.log(invoiceNumber.data);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
get(): Promise<AxiosResponse<InvoiceNumber>>;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch next invoice number.
|
|
53
|
+
*
|
|
54
|
+
* @returns Invoice number object
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const invoiceNumber = await client.invoiceNumber.next();
|
|
59
|
+
* console.log(invoiceNumber.data);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
next(): Promise<AxiosResponse<NextNumberResponse>>;
|
|
63
|
+
/**
|
|
64
|
+
* Update an existing invoice number.
|
|
65
|
+
*
|
|
66
|
+
* @param id
|
|
67
|
+
* @param data
|
|
68
|
+
* @returns
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const updates = { enabled: true };
|
|
73
|
+
* const updated = await client.InvoiceNumber.update(updates);
|
|
74
|
+
* console.log(updated.data);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
update(data: CreateInvoiceNumberRequest): Promise<AxiosResponse<InvoiceNumber>>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvoiceNumberService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Service for Invoice Number
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
10
|
+
* const client = createClient('your-api-key');
|
|
11
|
+
* const invoiceNumber = await client.invoiceNumber.get();
|
|
12
|
+
* console.log(invoiceNumber.data);
|
|
13
|
+
*/
|
|
14
|
+
class InvoiceNumberService {
|
|
15
|
+
constructor(http) {
|
|
16
|
+
this.http = http;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Fetch a single invoice number.
|
|
20
|
+
*
|
|
21
|
+
* @returns Invoice number object
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const invoiceNumber = await client.invoiceNumber.get();
|
|
26
|
+
* console.log(invoiceNumber.data);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
async get() {
|
|
30
|
+
return await this.http.get(`/customer/invoice-number`);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fetch next invoice number.
|
|
34
|
+
*
|
|
35
|
+
* @returns Invoice number object
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const invoiceNumber = await client.invoiceNumber.next();
|
|
40
|
+
* console.log(invoiceNumber.data);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
async next() {
|
|
44
|
+
return await this.http.get(`/customer/invoice-number/next`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Update an existing invoice number.
|
|
48
|
+
*
|
|
49
|
+
* @param id
|
|
50
|
+
* @param data
|
|
51
|
+
* @returns
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const updates = { enabled: true };
|
|
56
|
+
* const updated = await client.InvoiceNumber.update(updates);
|
|
57
|
+
* console.log(updated.data);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
async update(data) {
|
|
61
|
+
return await this.http.patch(`/customer/invoice-number`, data);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.InvoiceNumberService = InvoiceNumberService;
|
package/dist/invoicePayment.js
CHANGED
|
@@ -77,7 +77,7 @@ class InvoicePaymentService {
|
|
|
77
77
|
}
|
|
78
78
|
formData.append('amount', data.amount.toString());
|
|
79
79
|
if (data.file) {
|
|
80
|
-
formData.append('file', data.file
|
|
80
|
+
formData.append('file', data.file);
|
|
81
81
|
}
|
|
82
82
|
return await this.http.post('/customer/invoice/payment-records', formData, {
|
|
83
83
|
headers,
|
|
@@ -124,7 +124,7 @@ class InvoicePaymentService {
|
|
|
124
124
|
formData.append('amount', data === null || data === void 0 ? void 0 : data.amount.toString());
|
|
125
125
|
}
|
|
126
126
|
if (data.file) {
|
|
127
|
-
formData.append('file', data.file
|
|
127
|
+
formData.append('file', data.file);
|
|
128
128
|
}
|
|
129
129
|
return await this.http.put(`/customer/invoice/payment-records/${id}`, formData, {
|
|
130
130
|
headers,
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
export interface CreateInvoiceTemplateRequest {
|
|
3
|
+
terms: [
|
|
4
|
+
{
|
|
5
|
+
name: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
];
|
|
9
|
+
notes: [
|
|
10
|
+
{
|
|
11
|
+
name: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
type?: 'terms' | 'notes';
|
|
16
|
+
}
|
|
17
|
+
export type UpdateInvoiceTemplateRequest = Partial<CreateInvoiceTemplateRequest>;
|
|
18
|
+
export interface InvoiceTemplate {
|
|
19
|
+
_id: string;
|
|
20
|
+
company: string;
|
|
21
|
+
terms: [
|
|
22
|
+
{
|
|
23
|
+
name: string;
|
|
24
|
+
content: string;
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
notes: [
|
|
28
|
+
{
|
|
29
|
+
name: string;
|
|
30
|
+
content: string;
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
created_at: string;
|
|
34
|
+
updated_at: string;
|
|
35
|
+
}
|
|
36
|
+
export interface InvoiceTemplateQueryParams {
|
|
37
|
+
page?: number;
|
|
38
|
+
limit?: number;
|
|
39
|
+
sort?: string;
|
|
40
|
+
search?: string;
|
|
41
|
+
filters?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Service for Invoice Template
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
49
|
+
* const client = createClient('your-api-key');
|
|
50
|
+
* const InvoiceTemplate = await client.InvoiceTemplate.list({ page: 1, limit: 10 });
|
|
51
|
+
* console.log(InvoiceTemplate.data);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare class InvoiceTemplateService {
|
|
55
|
+
private http;
|
|
56
|
+
constructor(http: AxiosInstance);
|
|
57
|
+
/**
|
|
58
|
+
* Fetch a paginated list of invoice templates.
|
|
59
|
+
* @param params
|
|
60
|
+
* @returns
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const invoiceTemplates = await client.InvoiceTemplate.list();
|
|
65
|
+
* console.log(invoiceTemplates.data);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
list(params: InvoiceTemplateQueryParams): Promise<AxiosResponse<InvoiceTemplate>>;
|
|
69
|
+
/**
|
|
70
|
+
* Fetch a single invoice template by ID.
|
|
71
|
+
*
|
|
72
|
+
* @param id
|
|
73
|
+
* @returns
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const invoiceTemplate = await client.InvoiceTemplate.get('invoice_template_id_here');
|
|
78
|
+
* console.log(invoiceTemplate.data);
|
|
79
|
+
* ``` */
|
|
80
|
+
get(id: string): Promise<AxiosResponse<InvoiceTemplate>>;
|
|
81
|
+
/**
|
|
82
|
+
* Create a new invoice template.
|
|
83
|
+
*
|
|
84
|
+
* @param data
|
|
85
|
+
* @returns
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const newInvoiceTemplate = {
|
|
90
|
+
* terms: [
|
|
91
|
+
* {
|
|
92
|
+
* name: "Terms",
|
|
93
|
+
* content: "Terms content"
|
|
94
|
+
* }
|
|
95
|
+
* ],
|
|
96
|
+
* notes: [
|
|
97
|
+
* {
|
|
98
|
+
* name: "Notes",
|
|
99
|
+
* content: "Notes content"
|
|
100
|
+
* }
|
|
101
|
+
* ]
|
|
102
|
+
* };
|
|
103
|
+
* const response = await client.InvoiceTemplate.create(newInvoiceTemplate);
|
|
104
|
+
* console.log(response.data);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
create(data: CreateInvoiceTemplateRequest): Promise<AxiosResponse<InvoiceTemplate>>;
|
|
108
|
+
/**
|
|
109
|
+
* Update an existing invoice template.
|
|
110
|
+
*
|
|
111
|
+
* @param id
|
|
112
|
+
* @param data
|
|
113
|
+
* @returns
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const updates = { type: "notes", notes: [
|
|
118
|
+
* {
|
|
119
|
+
* name: "Notes",
|
|
120
|
+
* content: "Notes content"
|
|
121
|
+
* }
|
|
122
|
+
* ]};
|
|
123
|
+
* const updated = await client.InvoiceTemplate.update('invoice_template_id_here', updates);
|
|
124
|
+
* console.log(updated.data);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
update(id: string, data: CreateInvoiceTemplateRequest): Promise<AxiosResponse<InvoiceTemplate>>;
|
|
128
|
+
/**
|
|
129
|
+
* Delete an invoice template by ID.
|
|
130
|
+
*
|
|
131
|
+
* @param id
|
|
132
|
+
* @returns
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const response = await client.InvoiceTemplate.delete('expense_category_id_here');
|
|
137
|
+
* console.log(response.data.message);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
delete(id: string): Promise<AxiosResponse<{
|
|
141
|
+
message: string;
|
|
142
|
+
}>>;
|
|
143
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvoiceTemplateService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Service for Invoice Template
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { createClient } = require('timber-sdk-dev');
|
|
10
|
+
* const client = createClient('your-api-key');
|
|
11
|
+
* const InvoiceTemplate = await client.InvoiceTemplate.list({ page: 1, limit: 10 });
|
|
12
|
+
* console.log(InvoiceTemplate.data);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
class InvoiceTemplateService {
|
|
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 invoiceTemplates = await client.InvoiceTemplate.list();
|
|
27
|
+
* console.log(invoiceTemplates.data);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
async list(params) {
|
|
31
|
+
return await this.http.get('/customer/invoice-template', {
|
|
32
|
+
params,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fetch a single invoice template by ID.
|
|
37
|
+
*
|
|
38
|
+
* @param id
|
|
39
|
+
* @returns
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const invoiceTemplate = await client.InvoiceTemplate.get('invoice_template_id_here');
|
|
44
|
+
* console.log(invoiceTemplate.data);
|
|
45
|
+
* ``` */
|
|
46
|
+
async get(id) {
|
|
47
|
+
return await this.http.get(`/customer/invoice-template/${id}`);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a new invoice template.
|
|
51
|
+
*
|
|
52
|
+
* @param data
|
|
53
|
+
* @returns
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const newInvoiceTemplate = {
|
|
58
|
+
* terms: [
|
|
59
|
+
* {
|
|
60
|
+
* name: "Terms",
|
|
61
|
+
* content: "Terms content"
|
|
62
|
+
* }
|
|
63
|
+
* ],
|
|
64
|
+
* notes: [
|
|
65
|
+
* {
|
|
66
|
+
* name: "Notes",
|
|
67
|
+
* content: "Notes content"
|
|
68
|
+
* }
|
|
69
|
+
* ]
|
|
70
|
+
* };
|
|
71
|
+
* const response = await client.InvoiceTemplate.create(newInvoiceTemplate);
|
|
72
|
+
* console.log(response.data);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
async create(data) {
|
|
76
|
+
return await this.http.post('/customer/invoice-template', data);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Update an existing invoice template.
|
|
80
|
+
*
|
|
81
|
+
* @param id
|
|
82
|
+
* @param data
|
|
83
|
+
* @returns
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const updates = { type: "notes", notes: [
|
|
88
|
+
* {
|
|
89
|
+
* name: "Notes",
|
|
90
|
+
* content: "Notes content"
|
|
91
|
+
* }
|
|
92
|
+
* ]};
|
|
93
|
+
* const updated = await client.InvoiceTemplate.update('invoice_template_id_here', updates);
|
|
94
|
+
* console.log(updated.data);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
async update(id, data) {
|
|
98
|
+
return await this.http.put(`/customer/invoice-template/${id}`, data);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Delete an invoice template by ID.
|
|
102
|
+
*
|
|
103
|
+
* @param id
|
|
104
|
+
* @returns
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const response = await client.InvoiceTemplate.delete('expense_category_id_here');
|
|
109
|
+
* console.log(response.data.message);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
async delete(id) {
|
|
113
|
+
return await this.http.delete(`/customer/invoice-template/${id}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.InvoiceTemplateService = InvoiceTemplateService;
|
package/dist/vendorPayment.d.ts
CHANGED