timber-node 0.0.5 → 0.0.7

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.
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.BillPaymentService = void 0;
7
- const form_data_1 = __importDefault(require("form-data"));
4
+ const getFormData_1 = require("./utils/getFormData");
8
5
  /**
9
6
  * Service for Bill Payment
10
7
  *
@@ -62,7 +59,7 @@ class BillPaymentService {
62
59
  * ```
63
60
  */
64
61
  async create(data) {
65
- const formData = new form_data_1.default();
62
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
66
63
  formData.append('invoice', data.invoice);
67
64
  formData.append('date', data.date);
68
65
  formData.append('payment_method', data.payment_method);
@@ -83,7 +80,7 @@ class BillPaymentService {
83
80
  formData.append('file', data.file[0]);
84
81
  }
85
82
  return await this.http.post('/customer/purchase/payment-record', formData, {
86
- headers: formData.getHeaders(),
83
+ headers,
87
84
  });
88
85
  }
89
86
  /**
@@ -101,7 +98,7 @@ class BillPaymentService {
101
98
  * ```
102
99
  */
103
100
  async update(id, data) {
104
- const formData = new form_data_1.default();
101
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
105
102
  formData.append('invoice', data.invoice);
106
103
  formData.append('date', data.date);
107
104
  formData.append('payment_method', data.payment_method);
@@ -122,7 +119,7 @@ class BillPaymentService {
122
119
  formData.append('file', data.file[0]);
123
120
  }
124
121
  return await this.http.put(`/customer/purchase/payment-record/${id}`, formData, {
125
- headers: formData.getHeaders(),
122
+ headers,
126
123
  });
127
124
  }
128
125
  /**
@@ -0,0 +1,146 @@
1
+ import { AxiosInstance, AxiosResponse } from 'axios';
2
+ export interface CompanyData {
3
+ name: string;
4
+ currency: string;
5
+ language: string;
6
+ address: string;
7
+ city: string;
8
+ state: string;
9
+ zip_code: string;
10
+ country: string;
11
+ email: string;
12
+ country_code: string;
13
+ mobile: string;
14
+ tax_number: string;
15
+ financial_start_date: string;
16
+ license_expiry: string;
17
+ license_issue_date: string;
18
+ sector: string[];
19
+ user_role: string;
20
+ business_years: string;
21
+ size: string;
22
+ current_method: string;
23
+ purpose: string;
24
+ license: File[];
25
+ license_number: string;
26
+ license_authority: string;
27
+ trn: string;
28
+ }
29
+ export interface Company extends CompanyData {
30
+ _id: string;
31
+ created_at?: string;
32
+ updated_at?: string;
33
+ }
34
+ export interface CompanyQueryParams {
35
+ page?: number;
36
+ limit?: number;
37
+ search?: string;
38
+ }
39
+ /**
40
+ * Service for Company
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const { createClient } = require('timber-sdk-dev');
45
+ * const client = createClient('your-api-key');
46
+ * const company = await client.company.list({ page: 1, limit: 10 });
47
+ * console.log(company.data);
48
+ * ```
49
+ */
50
+ export declare class CompanyService {
51
+ private http;
52
+ constructor(http: AxiosInstance);
53
+ /**
54
+ * Fetch a paginated list of companies.
55
+ *
56
+ * @param params - Query options like page, limit, filters, sort.
57
+ * @returns List of companies matching the query.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const companies = await client.company.list({ page: 1, limit: 5 });
62
+ * console.log(companies.data);
63
+ * ```
64
+ */
65
+ list(params?: CompanyQueryParams): Promise<AxiosResponse<Company[]>>;
66
+ /**
67
+ * Fetch an company by ID.
68
+ *
69
+ * @param id - The ID of the company to fetch.
70
+ * @returns The company matching the ID.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const company = await client.company.get('company_id_here');
75
+ * console.log(company.data);
76
+ * ```
77
+ */
78
+ get(id: string): Promise<AxiosResponse<Company>>;
79
+ /**
80
+ * Create a new company.
81
+ *
82
+ * @param data - Company creation payload
83
+ * @returns The created company
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const newCompany = {
88
+ * name: "company_name",
89
+ * currency: "USD",
90
+ * language: "en",
91
+ * address: "123 Main St",
92
+ * city: "New York",
93
+ * state: "NY",
94
+ * zip_code: "10001",
95
+ * country: "USA",
96
+ * tax_number: "123456789",
97
+ * financial_start_date: "2023-01-01",
98
+ * business_years: "1-2",
99
+ * license_expiry: "2023-01-01",
100
+ * license_issue_date: "2023-01-01",
101
+ * user_role: "CEO",
102
+ * size: "small",
103
+ * current_method: "accountant",
104
+ * purpose: "testing",
105
+ * email: "test@test.com",
106
+ * country_code: "US",
107
+ * mobile: "1234567890",
108
+ * license: [File],
109
+ * license_number: "123456789",
110
+ * license_authority: "NY",
111
+ * trn: "123456789",
112
+ * sector: ["product", "service"], // Optional
113
+ * };
114
+ * const response = await client.company.create(newCompany);
115
+ * console.log(response.data);
116
+ * ```
117
+ */
118
+ create(data: CompanyData): Promise<AxiosResponse<Company>>;
119
+ /**
120
+ * Update an existing company.
121
+ *
122
+ * @param id - Company ID
123
+ * @param data - Partial update data
124
+ * @returns Updated company
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * const updates = { name: "new_company_name" };
129
+ * const updated = await client.company.update('company_id_here', updates);
130
+ * console.log(updated.data);
131
+ * ```
132
+ */
133
+ update(id: string, data: Partial<CompanyData>): Promise<AxiosResponse<Company>>;
134
+ /**Default company
135
+ *
136
+ * @param id - Company ID
137
+ * @returns default company
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const defaultCompany = await client.company.default('company_id_here');
142
+ * console.log(defaultCompany.data);
143
+ * ```
144
+ * */
145
+ default(id: string): Promise<AxiosResponse<Company>>;
146
+ }
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CompanyService = void 0;
7
+ const form_data_1 = __importDefault(require("form-data"));
8
+ /**
9
+ * Service for Company
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const { createClient } = require('timber-sdk-dev');
14
+ * const client = createClient('your-api-key');
15
+ * const company = await client.company.list({ page: 1, limit: 10 });
16
+ * console.log(company.data);
17
+ * ```
18
+ */
19
+ class CompanyService {
20
+ constructor(http) {
21
+ this.http = http;
22
+ }
23
+ /**
24
+ * Fetch a paginated list of companies.
25
+ *
26
+ * @param params - Query options like page, limit, filters, sort.
27
+ * @returns List of companies matching the query.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const companies = await client.company.list({ page: 1, limit: 5 });
32
+ * console.log(companies.data);
33
+ * ```
34
+ */
35
+ async list(params = {}) {
36
+ return await this.http.get('/customer/company', { params });
37
+ }
38
+ /**
39
+ * Fetch an company by ID.
40
+ *
41
+ * @param id - The ID of the company to fetch.
42
+ * @returns The company matching the ID.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const company = await client.company.get('company_id_here');
47
+ * console.log(company.data);
48
+ * ```
49
+ */
50
+ async get(id) {
51
+ return await this.http.get(`/customer/company/${id}`);
52
+ }
53
+ /**
54
+ * Create a new company.
55
+ *
56
+ * @param data - Company creation payload
57
+ * @returns The created company
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const newCompany = {
62
+ * name: "company_name",
63
+ * currency: "USD",
64
+ * language: "en",
65
+ * address: "123 Main St",
66
+ * city: "New York",
67
+ * state: "NY",
68
+ * zip_code: "10001",
69
+ * country: "USA",
70
+ * tax_number: "123456789",
71
+ * financial_start_date: "2023-01-01",
72
+ * business_years: "1-2",
73
+ * license_expiry: "2023-01-01",
74
+ * license_issue_date: "2023-01-01",
75
+ * user_role: "CEO",
76
+ * size: "small",
77
+ * current_method: "accountant",
78
+ * purpose: "testing",
79
+ * email: "test@test.com",
80
+ * country_code: "US",
81
+ * mobile: "1234567890",
82
+ * license: [File],
83
+ * license_number: "123456789",
84
+ * license_authority: "NY",
85
+ * trn: "123456789",
86
+ * sector: ["product", "service"], // Optional
87
+ * };
88
+ * const response = await client.company.create(newCompany);
89
+ * console.log(response.data);
90
+ * ```
91
+ */
92
+ async create(data) {
93
+ const formData = new form_data_1.default();
94
+ formData.append('name', data.name);
95
+ formData.append('currency', data.currency);
96
+ formData.append('language', data.language);
97
+ formData.append('address', data.address);
98
+ formData.append('city', data.city);
99
+ formData.append('state', data.state);
100
+ formData.append('zip_code', data.zip_code);
101
+ formData.append('country', data.country);
102
+ formData.append('tax_number', data.tax_number);
103
+ formData.append('financial_start_date', data.financial_start_date);
104
+ formData.append('business_years', data.business_years);
105
+ formData.append('license_expiry', data.license_expiry);
106
+ formData.append('license_issue_date', data.license_issue_date);
107
+ formData.append('user_role', data.user_role);
108
+ formData.append('size', data.size);
109
+ formData.append('current_method', data.current_method);
110
+ formData.append('purpose', data.purpose);
111
+ formData.append('email', data.email);
112
+ formData.append('country_code', data.country_code);
113
+ formData.append('mobile', data.mobile);
114
+ formData.append('license', data.license[0]);
115
+ formData.append('license_number', data.license_number);
116
+ formData.append('license_authority', data.license_authority);
117
+ formData.append('trn', data.trn);
118
+ data.sector.forEach((item, index) => {
119
+ formData.append(`sector[${index}]`, item);
120
+ });
121
+ return await this.http.post('/customer/company', formData, {
122
+ headers: formData.getHeaders(),
123
+ });
124
+ }
125
+ /**
126
+ * Update an existing company.
127
+ *
128
+ * @param id - Company ID
129
+ * @param data - Partial update data
130
+ * @returns Updated company
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * const updates = { name: "new_company_name" };
135
+ * const updated = await client.company.update('company_id_here', updates);
136
+ * console.log(updated.data);
137
+ * ```
138
+ */
139
+ async update(id, data) {
140
+ const formData = new form_data_1.default();
141
+ formData.append('name', data.name);
142
+ formData.append('currency', data.currency);
143
+ formData.append('language', data.language);
144
+ formData.append('address', data.address);
145
+ formData.append('city', data.city);
146
+ formData.append('state', data.state);
147
+ formData.append('zip_code', data.zip_code);
148
+ formData.append('country', data.country);
149
+ formData.append('tax_number', data.tax_number);
150
+ formData.append('financial_start_date', data.financial_start_date);
151
+ formData.append('business_years', data.business_years);
152
+ formData.append('license_expiry', data.license_expiry);
153
+ formData.append('license_issue_date', data.license_issue_date);
154
+ formData.append('user_role', data.user_role);
155
+ formData.append('size', data.size);
156
+ formData.append('current_method', data.current_method);
157
+ formData.append('purpose', data.purpose);
158
+ formData.append('email', data.email);
159
+ formData.append('country_code', data.country_code);
160
+ formData.append('mobile', data.mobile);
161
+ if (data === null || data === void 0 ? void 0 : data.license) {
162
+ formData.append('license', data.license[0]);
163
+ }
164
+ formData.append('license_number', data.license_number);
165
+ formData.append('license_authority', data.license_authority);
166
+ formData.append('trn', data.trn);
167
+ if (data === null || data === void 0 ? void 0 : data.sector) {
168
+ data.sector.forEach((item, index) => {
169
+ formData.append(`sector[${index}]`, item);
170
+ });
171
+ }
172
+ return await this.http.put(`/customer/company/${id}`, data, {
173
+ headers: formData.getHeaders(),
174
+ });
175
+ }
176
+ /**Default company
177
+ *
178
+ * @param id - Company ID
179
+ * @returns default company
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * const defaultCompany = await client.company.default('company_id_here');
184
+ * console.log(defaultCompany.data);
185
+ * ```
186
+ * */
187
+ async default(id) {
188
+ return await this.http.patch(`/customer/company/${id}/default`);
189
+ }
190
+ }
191
+ exports.CompanyService = CompanyService;
package/dist/customer.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomerService = void 0;
4
+ const getFormData_1 = require("./utils/getFormData");
4
5
  /**
5
6
  * Service for Customer
6
7
  *
@@ -44,7 +45,18 @@ class CustomerService {
44
45
  * ```
45
46
  */
46
47
  async create(data) {
47
- return await this.http.post('/customer/customer', data);
48
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
49
+ Object.entries(data).forEach(([key, value]) => {
50
+ if (value instanceof File) {
51
+ formData.append(key, value);
52
+ }
53
+ else {
54
+ formData.append(key, value);
55
+ }
56
+ });
57
+ return await this.http.post('/customer/customer', formData, {
58
+ headers,
59
+ });
48
60
  }
49
61
  /**
50
62
  * Update an existing customer.
@@ -61,7 +73,18 @@ class CustomerService {
61
73
  * ```
62
74
  */
63
75
  async update(id, data) {
64
- return await this.http.put(`/customer/customer/${id}`, data);
76
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
77
+ Object.entries(data).forEach(([key, value]) => {
78
+ if (value instanceof File) {
79
+ formData.append(key, value);
80
+ }
81
+ else {
82
+ formData.append(key, value);
83
+ }
84
+ });
85
+ return await this.http.put(`/customer/customer/${id}`, formData, {
86
+ headers,
87
+ });
65
88
  }
66
89
  /**
67
90
  * Delete an customer by ID.
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ import { SalaryService } from './salary';
11
11
  import { EmployeeService } from './employee';
12
12
  import { ChequeService } from './cheque';
13
13
  import { BankStatementService } from './bankStatement';
14
+ import { CompanyService } from './company';
14
15
  declare class TimberClient {
15
16
  expense: ExpenseService;
16
17
  expenseCategory: ExpenseCategoryService;
@@ -25,6 +26,7 @@ declare class TimberClient {
25
26
  employee: EmployeeService;
26
27
  cheque: ChequeService;
27
28
  bankStatement: BankStatementService;
29
+ company: CompanyService;
28
30
  constructor(apiKey: string, options?: {
29
31
  baseURL?: string;
30
32
  });
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ const salary_1 = require("./salary");
18
18
  const employee_1 = require("./employee");
19
19
  const cheque_1 = require("./cheque");
20
20
  const bankStatement_1 = require("./bankStatement");
21
+ const company_1 = require("./company");
21
22
  class TimberClient {
22
23
  constructor(apiKey, options = {}) {
23
24
  const baseURL = `${options.baseURL || 'http://localhost:4010'}/api/v1/user/sdk`;
@@ -41,6 +42,7 @@ class TimberClient {
41
42
  this.employee = new employee_1.EmployeeService(http);
42
43
  this.cheque = new cheque_1.ChequeService(http);
43
44
  this.bankStatement = new bankStatement_1.BankStatementService(http);
45
+ this.company = new company_1.CompanyService(http);
44
46
  }
45
47
  }
46
48
  const createClient = (apiKey, options = {}) => {
package/dist/invoice.js CHANGED
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.InvoiceService = void 0;
7
- const form_data_1 = __importDefault(require("form-data"));
4
+ const getFormData_1 = require("./utils/getFormData");
8
5
  /**
9
6
  * Service for Invoice
10
7
  *
@@ -51,7 +48,7 @@ class InvoiceService {
51
48
  return await this.http.get(`/customer/invoice/${id}`);
52
49
  }
53
50
  async create(data) {
54
- const formData = new form_data_1.default();
51
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
55
52
  for (const key in data) {
56
53
  const value = data[key];
57
54
  if (key === 'items' || key === 'customer' || key === 'biller') {
@@ -69,11 +66,11 @@ class InvoiceService {
69
66
  }
70
67
  }
71
68
  return await this.http.post('/customer/invoice', formData, {
72
- headers: formData.getHeaders(),
69
+ headers,
73
70
  });
74
71
  }
75
72
  async update(id, data) {
76
- const formData = new form_data_1.default();
73
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
77
74
  for (const key in data) {
78
75
  const value = data[key];
79
76
  if (key === 'items' || key === 'customer' || key === 'biller') {
@@ -91,7 +88,7 @@ class InvoiceService {
91
88
  }
92
89
  }
93
90
  return await this.http.put(`/customer/invoice/${id}`, data, {
94
- headers: formData.getHeaders(),
91
+ headers,
95
92
  });
96
93
  }
97
94
  /**
@@ -5,6 +5,7 @@ export interface InvoicePaymentData {
5
5
  payment_method: string;
6
6
  cheque_no?: string;
7
7
  cheque_date?: string;
8
+ cheque_due_date?: string;
8
9
  bank_name?: string;
9
10
  file?: string;
10
11
  amount: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvoicePaymentService = void 0;
4
+ const getFormData_1 = require("./utils/getFormData");
4
5
  /**
5
6
  * Service for Invoice Payment
6
7
  *
@@ -58,7 +59,29 @@ class InvoicePaymentService {
58
59
  * ```
59
60
  */
60
61
  async create(data) {
61
- return await this.http.post('/customer/invoice/payment-records', data);
62
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
63
+ formData.append('invoice', data.invoice);
64
+ formData.append('date', data.date);
65
+ formData.append('payment_method', data.payment_method);
66
+ if (data.cheque_no) {
67
+ formData.append('cheque_no', data.cheque_no);
68
+ }
69
+ if (data.cheque_date) {
70
+ formData.append('cheque_date', data.cheque_date);
71
+ }
72
+ if (data.cheque_due_date) {
73
+ formData.append('cheque_due_date', data.cheque_due_date);
74
+ }
75
+ if (data.bank_name) {
76
+ formData.append('bank_name', data.bank_name);
77
+ }
78
+ formData.append('amount', data.amount.toString());
79
+ if (data.file) {
80
+ formData.append('file', data.file[0]);
81
+ }
82
+ return await this.http.post('/customer/invoice/payment-records', formData, {
83
+ headers,
84
+ });
62
85
  }
63
86
  /**
64
87
  * Update an existing invoice payment.
@@ -75,7 +98,37 @@ class InvoicePaymentService {
75
98
  * ```
76
99
  */
77
100
  async update(id, data) {
78
- return await this.http.put(`/customer/invoice/payment-records/${id}`, data);
101
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
102
+ if (data.invoice) {
103
+ formData.append('invoice', data.invoice);
104
+ }
105
+ if (data.date) {
106
+ formData.append('date', data.date);
107
+ }
108
+ if (data.payment_method) {
109
+ formData.append('payment_method', data.payment_method);
110
+ }
111
+ if (data.cheque_no) {
112
+ formData.append('cheque_no', data.cheque_no);
113
+ }
114
+ if (data.cheque_date) {
115
+ formData.append('cheque_date', data.cheque_date);
116
+ }
117
+ if (data.cheque_due_date) {
118
+ formData.append('cheque_due_date', data.cheque_due_date);
119
+ }
120
+ if (data.bank_name) {
121
+ formData.append('bank_name', data.bank_name);
122
+ }
123
+ if (data === null || data === void 0 ? void 0 : data.amount) {
124
+ formData.append('amount', data === null || data === void 0 ? void 0 : data.amount.toString());
125
+ }
126
+ if (data.file) {
127
+ formData.append('file', data.file[0]);
128
+ }
129
+ return await this.http.put(`/customer/invoice/payment-records/${id}`, formData, {
130
+ headers,
131
+ });
79
132
  }
80
133
  /**
81
134
  * Delete an invoice payment by ID.
@@ -0,0 +1,6 @@
1
+ type UniversalFormData = FormData | import('form-data');
2
+ export declare function getFormData(): Promise<{
3
+ formData: UniversalFormData;
4
+ headers: Record<string, string>;
5
+ }>;
6
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getFormData = getFormData;
37
+ async function getFormData() {
38
+ if (typeof window === 'undefined') {
39
+ const FormDataNode = (await Promise.resolve().then(() => __importStar(require('form-data')))).default;
40
+ const formData = new FormDataNode();
41
+ return { formData, headers: formData.getHeaders() };
42
+ }
43
+ else {
44
+ const formData = new FormData();
45
+ return { formData, headers: {} };
46
+ }
47
+ }
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.VendorPaymentService = void 0;
7
- const form_data_1 = __importDefault(require("form-data"));
4
+ const getFormData_1 = require("./utils/getFormData");
8
5
  /**
9
6
  * Service for Vendor Payment
10
7
  *
@@ -112,7 +109,7 @@ class VendorPaymentService {
112
109
  * ```
113
110
  */
114
111
  async create(data) {
115
- const formData = new form_data_1.default();
112
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
116
113
  try {
117
114
  Object.entries(data).forEach(([key, value]) => {
118
115
  if (key === 'customer' || key === 'biller') {
@@ -154,7 +151,7 @@ class VendorPaymentService {
154
151
  formData.append('file', data.logo);
155
152
  }
156
153
  return await this.http.post('/customer/purchase', formData, {
157
- headers: formData.getHeaders(),
154
+ headers,
158
155
  });
159
156
  }
160
157
  /**
@@ -172,7 +169,7 @@ class VendorPaymentService {
172
169
  * ```
173
170
  */
174
171
  async update(id, data) {
175
- const formData = new form_data_1.default();
172
+ const { formData, headers } = await (0, getFormData_1.getFormData)();
176
173
  try {
177
174
  Object.entries(data).forEach(([key, value]) => {
178
175
  if (key === 'customer' || key === 'biller') {
@@ -214,7 +211,7 @@ class VendorPaymentService {
214
211
  formData.append('file', data.logo);
215
212
  }
216
213
  return await this.http.put(`/customer/purchase/${id}`, formData, {
217
- headers: formData.getHeaders(),
214
+ headers,
218
215
  });
219
216
  }
220
217
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "timber-node",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Simplifying accounting and tax filing for businesses",
5
5
  "keywords": [
6
6
  "timber"
@@ -40,6 +40,7 @@
40
40
  "dependencies": {
41
41
  "axios": "^1.10.0",
42
42
  "form-data": "^4.0.3",
43
+ "timber-node": "^0.0.5",
43
44
  "typescript-eslint": "^8.35.0"
44
45
  },
45
46
  "devDependencies": {