@ktmcp-cli/billingo 1.0.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/.env.example +8 -0
- package/AGENT.md +447 -0
- package/CLI_SUMMARY.md +377 -0
- package/INDEX.md +364 -0
- package/INSTALL.sh +62 -0
- package/LICENSE +21 -0
- package/OPENCLAW.md +503 -0
- package/PROJECT_REPORT.md +462 -0
- package/QUICKSTART.md +212 -0
- package/README.md +378 -0
- package/STRUCTURE.txt +266 -0
- package/TESTING.md +513 -0
- package/banner.png +0 -0
- package/bin/billingo.js +75 -0
- package/examples/bank-account.json +8 -0
- package/examples/invoice.json +32 -0
- package/examples/partner.json +20 -0
- package/examples/product.json +10 -0
- package/logo.png +0 -0
- package/package.json +35 -0
- package/src/commands/bank-accounts.js +131 -0
- package/src/commands/config.js +73 -0
- package/src/commands/currencies.js +40 -0
- package/src/commands/document-blocks.js +40 -0
- package/src/commands/documents.js +248 -0
- package/src/commands/organization.js +35 -0
- package/src/commands/partners.js +130 -0
- package/src/commands/products.js +130 -0
- package/src/commands/utilities.js +34 -0
- package/src/lib/api.js +160 -0
- package/src/lib/auth.js +32 -0
- package/src/lib/config.js +87 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bank Account Commands
|
|
3
|
+
*
|
|
4
|
+
* Manage bank accounts for invoicing
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import ora from 'ora';
|
|
10
|
+
import { get, post, put, del, formatOutput } from '../lib/api.js';
|
|
11
|
+
import { readFileSync } from 'fs';
|
|
12
|
+
|
|
13
|
+
export function registerBankAccountCommands(program) {
|
|
14
|
+
const bankAccounts = new Command('bank-accounts')
|
|
15
|
+
.alias('banks')
|
|
16
|
+
.description('Manage bank accounts');
|
|
17
|
+
|
|
18
|
+
bankAccounts
|
|
19
|
+
.command('list')
|
|
20
|
+
.description('List all bank accounts')
|
|
21
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
22
|
+
.option('--per-page <number>', 'Results per page', '25')
|
|
23
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
24
|
+
.action(async (options) => {
|
|
25
|
+
const spinner = ora('Fetching bank accounts...').start();
|
|
26
|
+
try {
|
|
27
|
+
const data = await get('/bank-accounts', {
|
|
28
|
+
page: options.page,
|
|
29
|
+
per_page: options.perPage,
|
|
30
|
+
});
|
|
31
|
+
spinner.succeed('Bank accounts retrieved');
|
|
32
|
+
console.log(formatOutput(data, options.format));
|
|
33
|
+
} catch (error) {
|
|
34
|
+
spinner.fail('Failed to fetch bank accounts');
|
|
35
|
+
console.error(chalk.red('Error:'), error.message);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
bankAccounts
|
|
41
|
+
.command('get <id>')
|
|
42
|
+
.description('Get bank account by ID')
|
|
43
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
44
|
+
.action(async (id, options) => {
|
|
45
|
+
const spinner = ora(`Fetching bank account ${id}...`).start();
|
|
46
|
+
try {
|
|
47
|
+
const data = await get(`/bank-accounts/${id}`);
|
|
48
|
+
spinner.succeed('Bank account retrieved');
|
|
49
|
+
console.log(formatOutput(data, options.format));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
spinner.fail('Failed to fetch bank account');
|
|
52
|
+
console.error(chalk.red('Error:'), error.message);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
bankAccounts
|
|
58
|
+
.command('create')
|
|
59
|
+
.description('Create a new bank account')
|
|
60
|
+
.option('-f, --file <path>', 'JSON file with bank account data')
|
|
61
|
+
.option('-d, --data <json>', 'JSON string with bank account data')
|
|
62
|
+
.action(async (options) => {
|
|
63
|
+
const spinner = ora('Creating bank account...').start();
|
|
64
|
+
try {
|
|
65
|
+
let data;
|
|
66
|
+
if (options.file) {
|
|
67
|
+
data = JSON.parse(readFileSync(options.file, 'utf-8'));
|
|
68
|
+
} else if (options.data) {
|
|
69
|
+
data = JSON.parse(options.data);
|
|
70
|
+
} else {
|
|
71
|
+
spinner.fail('No data provided');
|
|
72
|
+
console.error(chalk.red('Error: Provide data with --file or --data'));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const result = await post('/bank-accounts', data);
|
|
77
|
+
spinner.succeed('Bank account created');
|
|
78
|
+
console.log(formatOutput(result, 'pretty'));
|
|
79
|
+
} catch (error) {
|
|
80
|
+
spinner.fail('Failed to create bank account');
|
|
81
|
+
console.error(chalk.red('Error:'), error.message);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
bankAccounts
|
|
87
|
+
.command('update <id>')
|
|
88
|
+
.description('Update a bank account')
|
|
89
|
+
.option('-f, --file <path>', 'JSON file with bank account data')
|
|
90
|
+
.option('-d, --data <json>', 'JSON string with bank account data')
|
|
91
|
+
.action(async (id, options) => {
|
|
92
|
+
const spinner = ora(`Updating bank account ${id}...`).start();
|
|
93
|
+
try {
|
|
94
|
+
let data;
|
|
95
|
+
if (options.file) {
|
|
96
|
+
data = JSON.parse(readFileSync(options.file, 'utf-8'));
|
|
97
|
+
} else if (options.data) {
|
|
98
|
+
data = JSON.parse(options.data);
|
|
99
|
+
} else {
|
|
100
|
+
spinner.fail('No data provided');
|
|
101
|
+
console.error(chalk.red('Error: Provide data with --file or --data'));
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const result = await put(`/bank-accounts/${id}`, data);
|
|
106
|
+
spinner.succeed('Bank account updated');
|
|
107
|
+
console.log(formatOutput(result, 'pretty'));
|
|
108
|
+
} catch (error) {
|
|
109
|
+
spinner.fail('Failed to update bank account');
|
|
110
|
+
console.error(chalk.red('Error:'), error.message);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
bankAccounts
|
|
116
|
+
.command('delete <id>')
|
|
117
|
+
.description('Delete a bank account')
|
|
118
|
+
.action(async (id) => {
|
|
119
|
+
const spinner = ora(`Deleting bank account ${id}...`).start();
|
|
120
|
+
try {
|
|
121
|
+
await del(`/bank-accounts/${id}`);
|
|
122
|
+
spinner.succeed('Bank account deleted');
|
|
123
|
+
} catch (error) {
|
|
124
|
+
spinner.fail('Failed to delete bank account');
|
|
125
|
+
console.error(chalk.red('Error:'), error.message);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
program.addCommand(bankAccounts);
|
|
131
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Commands
|
|
3
|
+
*
|
|
4
|
+
* Manage CLI configuration (API key, base URL, etc.)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { getConfig, setConfig, getAllConfig, clearConfig } from '../lib/config.js';
|
|
10
|
+
|
|
11
|
+
export function registerConfigCommands(program) {
|
|
12
|
+
const config = new Command('config')
|
|
13
|
+
.description('Manage CLI configuration');
|
|
14
|
+
|
|
15
|
+
config
|
|
16
|
+
.command('set <key> <value>')
|
|
17
|
+
.description('Set a configuration value')
|
|
18
|
+
.action((key, value) => {
|
|
19
|
+
try {
|
|
20
|
+
setConfig(key, value);
|
|
21
|
+
console.log(chalk.green(`✓ Configuration updated: ${key} = ${value}`));
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error(chalk.red('Error:'), error.message);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
config
|
|
29
|
+
.command('get <key>')
|
|
30
|
+
.description('Get a configuration value')
|
|
31
|
+
.action((key) => {
|
|
32
|
+
try {
|
|
33
|
+
const value = getConfig(key);
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
console.log(chalk.yellow(`Configuration key "${key}" not found`));
|
|
36
|
+
} else {
|
|
37
|
+
console.log(value);
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error(chalk.red('Error:'), error.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
config
|
|
46
|
+
.command('list')
|
|
47
|
+
.description('List all configuration')
|
|
48
|
+
.action(() => {
|
|
49
|
+
try {
|
|
50
|
+
const allConfig = getAllConfig();
|
|
51
|
+
console.log(chalk.cyan('Current configuration:'));
|
|
52
|
+
console.log(JSON.stringify(allConfig, null, 2));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(chalk.red('Error:'), error.message);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
config
|
|
60
|
+
.command('clear')
|
|
61
|
+
.description('Clear all configuration')
|
|
62
|
+
.action(() => {
|
|
63
|
+
try {
|
|
64
|
+
clearConfig();
|
|
65
|
+
console.log(chalk.green('✓ Configuration cleared'));
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error(chalk.red('Error:'), error.message);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
program.addCommand(config);
|
|
73
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency Commands
|
|
3
|
+
*
|
|
4
|
+
* Get currency conversion rates
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import ora from 'ora';
|
|
10
|
+
import { get, formatOutput } from '../lib/api.js';
|
|
11
|
+
|
|
12
|
+
export function registerCurrencyCommands(program) {
|
|
13
|
+
const currencies = new Command('currencies')
|
|
14
|
+
.alias('currency')
|
|
15
|
+
.description('Get currency conversion rates');
|
|
16
|
+
|
|
17
|
+
currencies
|
|
18
|
+
.command('convert')
|
|
19
|
+
.description('Get conversion rate between currencies')
|
|
20
|
+
.requiredOption('--from <currency>', 'Source currency code (e.g., HUF)')
|
|
21
|
+
.requiredOption('--to <currency>', 'Target currency code (e.g., EUR)')
|
|
22
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
23
|
+
.action(async (options) => {
|
|
24
|
+
const spinner = ora(`Getting conversion rate ${options.from} → ${options.to}...`).start();
|
|
25
|
+
try {
|
|
26
|
+
const data = await get('/currencies', {
|
|
27
|
+
from: options.from,
|
|
28
|
+
to: options.to,
|
|
29
|
+
});
|
|
30
|
+
spinner.succeed('Conversion rate retrieved');
|
|
31
|
+
console.log(formatOutput(data, options.format));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
spinner.fail('Failed to get conversion rate');
|
|
34
|
+
console.error(chalk.red('Error:'), error.message);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
program.addCommand(currencies);
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Block Commands
|
|
3
|
+
*
|
|
4
|
+
* Manage document blocks (invoice pads)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import ora from 'ora';
|
|
10
|
+
import { get, formatOutput } from '../lib/api.js';
|
|
11
|
+
|
|
12
|
+
export function registerDocumentBlockCommands(program) {
|
|
13
|
+
const documentBlocks = new Command('document-blocks')
|
|
14
|
+
.alias('blocks')
|
|
15
|
+
.description('Manage document blocks (invoice pads)');
|
|
16
|
+
|
|
17
|
+
documentBlocks
|
|
18
|
+
.command('list')
|
|
19
|
+
.description('List all document blocks')
|
|
20
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
21
|
+
.option('--per-page <number>', 'Results per page', '25')
|
|
22
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
23
|
+
.action(async (options) => {
|
|
24
|
+
const spinner = ora('Fetching document blocks...').start();
|
|
25
|
+
try {
|
|
26
|
+
const data = await get('/document-blocks', {
|
|
27
|
+
page: options.page,
|
|
28
|
+
per_page: options.perPage,
|
|
29
|
+
});
|
|
30
|
+
spinner.succeed('Document blocks retrieved');
|
|
31
|
+
console.log(formatOutput(data, options.format));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
spinner.fail('Failed to fetch document blocks');
|
|
34
|
+
console.error(chalk.red('Error:'), error.message);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
program.addCommand(documentBlocks);
|
|
40
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Commands
|
|
3
|
+
*
|
|
4
|
+
* Manage invoices and other financial documents
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import ora from 'ora';
|
|
10
|
+
import { get, post, put, del, downloadFile, formatOutput } from '../lib/api.js';
|
|
11
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
12
|
+
|
|
13
|
+
export function registerDocumentCommands(program) {
|
|
14
|
+
const documents = new Command('documents')
|
|
15
|
+
.alias('docs')
|
|
16
|
+
.description('Manage documents (invoices)');
|
|
17
|
+
|
|
18
|
+
documents
|
|
19
|
+
.command('list')
|
|
20
|
+
.description('List all documents')
|
|
21
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
22
|
+
.option('--per-page <number>', 'Results per page', '25')
|
|
23
|
+
.option('--block-id <id>', 'Filter by document block ID')
|
|
24
|
+
.option('--partner-id <id>', 'Filter by partner ID')
|
|
25
|
+
.option('--payment-method <method>', 'Filter by payment method')
|
|
26
|
+
.option('--payment-status <status>', 'Filter by payment status')
|
|
27
|
+
.option('--start-date <date>', 'Filter by start date (YYYY-MM-DD)')
|
|
28
|
+
.option('--end-date <date>', 'Filter by end date (YYYY-MM-DD)')
|
|
29
|
+
.option('--start-number <number>', 'Filter by start document number')
|
|
30
|
+
.option('--end-number <number>', 'Filter by end document number')
|
|
31
|
+
.option('--start-year <year>', 'Filter by start year')
|
|
32
|
+
.option('--end-year <year>', 'Filter by end year')
|
|
33
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
34
|
+
.action(async (options) => {
|
|
35
|
+
const spinner = ora('Fetching documents...').start();
|
|
36
|
+
try {
|
|
37
|
+
const params = {
|
|
38
|
+
page: options.page,
|
|
39
|
+
per_page: options.perPage,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Add optional filters
|
|
43
|
+
if (options.blockId) params.block_id = options.blockId;
|
|
44
|
+
if (options.partnerId) params.partner_id = options.partnerId;
|
|
45
|
+
if (options.paymentMethod) params.payment_method = options.paymentMethod;
|
|
46
|
+
if (options.paymentStatus) params.payment_status = options.paymentStatus;
|
|
47
|
+
if (options.startDate) params.start_date = options.startDate;
|
|
48
|
+
if (options.endDate) params.end_date = options.endDate;
|
|
49
|
+
if (options.startNumber) params.start_number = options.startNumber;
|
|
50
|
+
if (options.endNumber) params.end_number = options.endNumber;
|
|
51
|
+
if (options.startYear) params.start_year = options.startYear;
|
|
52
|
+
if (options.endYear) params.end_year = options.endYear;
|
|
53
|
+
|
|
54
|
+
const data = await get('/documents', params);
|
|
55
|
+
spinner.succeed('Documents retrieved');
|
|
56
|
+
console.log(formatOutput(data, options.format));
|
|
57
|
+
} catch (error) {
|
|
58
|
+
spinner.fail('Failed to fetch documents');
|
|
59
|
+
console.error(chalk.red('Error:'), error.message);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
documents
|
|
65
|
+
.command('get <id>')
|
|
66
|
+
.description('Get document by ID')
|
|
67
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
68
|
+
.action(async (id, options) => {
|
|
69
|
+
const spinner = ora(`Fetching document ${id}...`).start();
|
|
70
|
+
try {
|
|
71
|
+
const data = await get(`/documents/${id}`);
|
|
72
|
+
spinner.succeed('Document retrieved');
|
|
73
|
+
console.log(formatOutput(data, options.format));
|
|
74
|
+
} catch (error) {
|
|
75
|
+
spinner.fail('Failed to fetch document');
|
|
76
|
+
console.error(chalk.red('Error:'), error.message);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
documents
|
|
82
|
+
.command('create')
|
|
83
|
+
.description('Create a new document')
|
|
84
|
+
.option('-f, --file <path>', 'JSON file with document data')
|
|
85
|
+
.option('-d, --data <json>', 'JSON string with document data')
|
|
86
|
+
.action(async (options) => {
|
|
87
|
+
const spinner = ora('Creating document...').start();
|
|
88
|
+
try {
|
|
89
|
+
let data;
|
|
90
|
+
if (options.file) {
|
|
91
|
+
data = JSON.parse(readFileSync(options.file, 'utf-8'));
|
|
92
|
+
} else if (options.data) {
|
|
93
|
+
data = JSON.parse(options.data);
|
|
94
|
+
} else {
|
|
95
|
+
spinner.fail('No data provided');
|
|
96
|
+
console.error(chalk.red('Error: Provide data with --file or --data'));
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const result = await post('/documents', data);
|
|
101
|
+
spinner.succeed('Document created');
|
|
102
|
+
console.log(formatOutput(result, 'pretty'));
|
|
103
|
+
} catch (error) {
|
|
104
|
+
spinner.fail('Failed to create document');
|
|
105
|
+
console.error(chalk.red('Error:'), error.message);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
documents
|
|
111
|
+
.command('cancel <id>')
|
|
112
|
+
.description('Cancel a document')
|
|
113
|
+
.action(async (id) => {
|
|
114
|
+
const spinner = ora(`Canceling document ${id}...`).start();
|
|
115
|
+
try {
|
|
116
|
+
const result = await post(`/documents/${id}/cancel`);
|
|
117
|
+
spinner.succeed('Document canceled');
|
|
118
|
+
console.log(formatOutput(result, 'pretty'));
|
|
119
|
+
} catch (error) {
|
|
120
|
+
spinner.fail('Failed to cancel document');
|
|
121
|
+
console.error(chalk.red('Error:'), error.message);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
documents
|
|
127
|
+
.command('download <id>')
|
|
128
|
+
.description('Download document as PDF')
|
|
129
|
+
.option('-o, --output <path>', 'Output file path', 'document.pdf')
|
|
130
|
+
.action(async (id, options) => {
|
|
131
|
+
const spinner = ora(`Downloading document ${id}...`).start();
|
|
132
|
+
try {
|
|
133
|
+
const buffer = await downloadFile(`/documents/${id}/download`);
|
|
134
|
+
writeFileSync(options.output, buffer);
|
|
135
|
+
spinner.succeed(`Document saved to ${options.output}`);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
spinner.fail('Failed to download document');
|
|
138
|
+
console.error(chalk.red('Error:'), error.message);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
documents
|
|
144
|
+
.command('send <id>')
|
|
145
|
+
.description('Send document via email')
|
|
146
|
+
.option('-e, --emails <emails>', 'Comma-separated email addresses')
|
|
147
|
+
.option('-s, --subject <subject>', 'Email subject')
|
|
148
|
+
.option('-m, --message <message>', 'Email message')
|
|
149
|
+
.action(async (id, options) => {
|
|
150
|
+
const spinner = ora(`Sending document ${id}...`).start();
|
|
151
|
+
try {
|
|
152
|
+
const data = {};
|
|
153
|
+
if (options.emails) data.emails = options.emails.split(',');
|
|
154
|
+
if (options.subject) data.subject = options.subject;
|
|
155
|
+
if (options.message) data.message = options.message;
|
|
156
|
+
|
|
157
|
+
const result = await post(`/documents/${id}/send`, data);
|
|
158
|
+
spinner.succeed('Document sent');
|
|
159
|
+
console.log(formatOutput(result, 'pretty'));
|
|
160
|
+
} catch (error) {
|
|
161
|
+
spinner.fail('Failed to send document');
|
|
162
|
+
console.error(chalk.red('Error:'), error.message);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
documents
|
|
168
|
+
.command('public-url <id>')
|
|
169
|
+
.description('Get public download URL for document')
|
|
170
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
171
|
+
.action(async (id, options) => {
|
|
172
|
+
const spinner = ora(`Getting public URL for document ${id}...`).start();
|
|
173
|
+
try {
|
|
174
|
+
const data = await get(`/documents/${id}/public-url`);
|
|
175
|
+
spinner.succeed('Public URL retrieved');
|
|
176
|
+
console.log(formatOutput(data, options.format));
|
|
177
|
+
} catch (error) {
|
|
178
|
+
spinner.fail('Failed to get public URL');
|
|
179
|
+
console.error(chalk.red('Error:'), error.message);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
documents
|
|
185
|
+
.command('payments <id>')
|
|
186
|
+
.description('Get payment history for document')
|
|
187
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
188
|
+
.action(async (id, options) => {
|
|
189
|
+
const spinner = ora(`Fetching payments for document ${id}...`).start();
|
|
190
|
+
try {
|
|
191
|
+
const data = await get(`/documents/${id}/payments`);
|
|
192
|
+
spinner.succeed('Payments retrieved');
|
|
193
|
+
console.log(formatOutput(data, options.format));
|
|
194
|
+
} catch (error) {
|
|
195
|
+
spinner.fail('Failed to fetch payments');
|
|
196
|
+
console.error(chalk.red('Error:'), error.message);
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
documents
|
|
202
|
+
.command('update-payments <id>')
|
|
203
|
+
.description('Update payment history for document')
|
|
204
|
+
.option('-f, --file <path>', 'JSON file with payment data')
|
|
205
|
+
.option('-d, --data <json>', 'JSON string with payment data')
|
|
206
|
+
.action(async (id, options) => {
|
|
207
|
+
const spinner = ora(`Updating payments for document ${id}...`).start();
|
|
208
|
+
try {
|
|
209
|
+
let data;
|
|
210
|
+
if (options.file) {
|
|
211
|
+
data = JSON.parse(readFileSync(options.file, 'utf-8'));
|
|
212
|
+
} else if (options.data) {
|
|
213
|
+
data = JSON.parse(options.data);
|
|
214
|
+
} else {
|
|
215
|
+
spinner.fail('No data provided');
|
|
216
|
+
console.error(chalk.red('Error: Provide data with --file or --data'));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const result = await put(`/documents/${id}/payments`, data);
|
|
221
|
+
spinner.succeed('Payments updated');
|
|
222
|
+
console.log(formatOutput(result, 'pretty'));
|
|
223
|
+
} catch (error) {
|
|
224
|
+
spinner.fail('Failed to update payments');
|
|
225
|
+
console.error(chalk.red('Error:'), error.message);
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
documents
|
|
231
|
+
.command('online-szamla <id>')
|
|
232
|
+
.description('Check Online Számla status')
|
|
233
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
234
|
+
.action(async (id, options) => {
|
|
235
|
+
const spinner = ora(`Checking Online Számla status for document ${id}...`).start();
|
|
236
|
+
try {
|
|
237
|
+
const data = await get(`/documents/${id}/online-szamla`);
|
|
238
|
+
spinner.succeed('Status retrieved');
|
|
239
|
+
console.log(formatOutput(data, options.format));
|
|
240
|
+
} catch (error) {
|
|
241
|
+
spinner.fail('Failed to check status');
|
|
242
|
+
console.error(chalk.red('Error:'), error.message);
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
program.addCommand(documents);
|
|
248
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization Commands
|
|
3
|
+
*
|
|
4
|
+
* Retrieve organization information
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import ora from 'ora';
|
|
10
|
+
import { get, formatOutput } from '../lib/api.js';
|
|
11
|
+
|
|
12
|
+
export function registerOrganizationCommands(program) {
|
|
13
|
+
const organization = new Command('organization')
|
|
14
|
+
.alias('org')
|
|
15
|
+
.description('Retrieve organization information');
|
|
16
|
+
|
|
17
|
+
organization
|
|
18
|
+
.command('get')
|
|
19
|
+
.description('Get organization data')
|
|
20
|
+
.option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
|
|
21
|
+
.action(async (options) => {
|
|
22
|
+
const spinner = ora('Fetching organization data...').start();
|
|
23
|
+
try {
|
|
24
|
+
const data = await get('/organization');
|
|
25
|
+
spinner.succeed('Organization data retrieved');
|
|
26
|
+
console.log(formatOutput(data, options.format));
|
|
27
|
+
} catch (error) {
|
|
28
|
+
spinner.fail('Failed to fetch organization data');
|
|
29
|
+
console.error(chalk.red('Error:'), error.message);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
program.addCommand(organization);
|
|
35
|
+
}
|