@opsrev/acculynx-cli 1.5.0 → 1.6.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.
Files changed (2) hide show
  1. package/dist/index.js +12 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -77,12 +77,13 @@ function createApiClient(config) {
77
77
  body
78
78
  });
79
79
  if (!response.ok) {
80
- const text = await response.text();
80
+ const text2 = await response.text();
81
81
  throw new Error(
82
- `API error (${response.status} ${response.statusText}): ${text}`
82
+ `API error (${response.status} ${response.statusText}): ${text2}`
83
83
  );
84
84
  }
85
- return response.json();
85
+ const text = await response.text();
86
+ return text ? JSON.parse(text) : { status: response.status };
86
87
  }
87
88
  return {
88
89
  get: doGet,
@@ -217,6 +218,14 @@ function registerJobsCommands(parentCmd, getClient2) {
217
218
  );
218
219
  console.log(JSON.stringify(result));
219
220
  });
221
+ jobs.command("add-expense").argument("<jobId>", "Job ID").description("Record an additional expense on a job (pipe JSON body to stdin)").action(async (jobId) => {
222
+ const body = await readStdin();
223
+ const result = await getClient2().post(
224
+ `/jobs/${jobId}/payments/expense`,
225
+ body
226
+ );
227
+ console.log(JSON.stringify(result));
228
+ });
220
229
  jobs.command("upload-document").argument("<jobId>", "Job ID").argument("<filePath>", "Path to the file to upload").requiredOption("--folder-id <id>", "Document folder ID (required)").option("--description <text>", "Brief description of the file").option("--external-id <id>", "External reference identifier").option("--external-source <source>", "External reference source").description("Upload a document to a job").action(async (jobId, filePath, opts) => {
221
230
  const ext = extname(filePath).toLowerCase();
222
231
  if (DISALLOWED_EXTENSIONS.has(ext)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opsrev/acculynx-cli",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "CLI for the AccuLynx roofing CRM API",
5
5
  "type": "module",
6
6
  "bin": {