timber-node 0.0.4 → 0.0.6

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.
@@ -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/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.d.ts CHANGED
@@ -87,6 +87,19 @@ export declare class InvoiceService {
87
87
  * ```
88
88
  */
89
89
  list(params?: InvoiceQueryParams): Promise<AxiosResponse<Invoice[]>>;
90
+ /**
91
+ * Fetch an invoice by ID.
92
+ *
93
+ * @param id - The ID of the invoice to fetch.
94
+ * @returns The invoice matching the ID.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const invoice = await client.invoice.get('invoice_id_here');
99
+ * console.log(invoice.data);
100
+ * ```
101
+ */
102
+ get(id: string): Promise<AxiosResponse<Invoice>>;
90
103
  create(data: InvoiceData): Promise<AxiosResponse<Invoice>>;
91
104
  update(id: string, data: Partial<InvoiceData>): Promise<AxiosResponse<Invoice>>;
92
105
  /**
package/dist/invoice.js CHANGED
@@ -35,6 +35,21 @@ class InvoiceService {
35
35
  async list(params = {}) {
36
36
  return await this.http.get('/customer/invoice', { params });
37
37
  }
38
+ /**
39
+ * Fetch an invoice by ID.
40
+ *
41
+ * @param id - The ID of the invoice to fetch.
42
+ * @returns The invoice matching the ID.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const invoice = await client.invoice.get('invoice_id_here');
47
+ * console.log(invoice.data);
48
+ * ```
49
+ */
50
+ async get(id) {
51
+ return await this.http.get(`/customer/invoice/${id}`);
52
+ }
38
53
  async create(data) {
39
54
  const formData = new form_data_1.default();
40
55
  for (const key in data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "timber-node",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
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": {