@commercelayer/cli-plugin-triggers 4.5.0 → 4.7.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/README.md +148 -8
- package/lib/commands/authorization/forward.d.ts +9 -0
- package/lib/commands/authorization/forward.js +22 -0
- package/lib/commands/capture/forward.d.ts +9 -0
- package/lib/commands/capture/forward.js +22 -0
- package/lib/commands/event/index.d.ts +9 -0
- package/lib/commands/event/index.js +40 -0
- package/lib/commands/event/trigger.d.ts +9 -0
- package/lib/commands/event/trigger.js +22 -0
- package/lib/commands/return/refund.d.ts +9 -0
- package/lib/commands/return/refund.js +22 -0
- package/lib/commands/return/refund_amount_cents.d.ts +9 -0
- package/lib/commands/return/refund_amount_cents.js +22 -0
- package/lib/exec.js +4 -3
- package/lib/triggers/authorizations.d.ts +1 -1
- package/lib/triggers/authorizations.js +6 -1
- package/lib/triggers/captures.d.ts +1 -1
- package/lib/triggers/captures.js +6 -1
- package/lib/triggers/events.d.ts +3 -0
- package/lib/triggers/events.js +10 -0
- package/lib/triggers/orders.js +2 -2
- package/lib/triggers/returns.d.ts +1 -1
- package/lib/triggers/returns.js +10 -0
- package/oclif.manifest.json +1049 -521
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ $ commercelayer plugins:install triggers
|
|
|
35
35
|
* [`commercelayer authorization ID`](#commercelayer-authorization-id)
|
|
36
36
|
* [`commercelayer authorization:capture ID`](#commercelayer-authorizationcapture-id)
|
|
37
37
|
* [`commercelayer authorization:capture_amount_cents ID`](#commercelayer-authorizationcapture_amount_cents-id)
|
|
38
|
+
* [`commercelayer authorization:forward ID`](#commercelayer-authorizationforward-id)
|
|
38
39
|
* [`commercelayer authorization:void ID`](#commercelayer-authorizationvoid-id)
|
|
39
40
|
* [`commercelayer axerve_payment ID`](#commercelayer-axerve_payment-id)
|
|
40
41
|
* [`commercelayer axerve_payment:update ID`](#commercelayer-axerve_paymentupdate-id)
|
|
@@ -45,6 +46,7 @@ $ commercelayer plugins:install triggers
|
|
|
45
46
|
* [`commercelayer buy_x_pay_y_promotion:disable ID`](#commercelayer-buy_x_pay_y_promotiondisable-id)
|
|
46
47
|
* [`commercelayer buy_x_pay_y_promotion:enable ID`](#commercelayer-buy_x_pay_y_promotionenable-id)
|
|
47
48
|
* [`commercelayer capture ID`](#commercelayer-capture-id)
|
|
49
|
+
* [`commercelayer capture:forward ID`](#commercelayer-captureforward-id)
|
|
48
50
|
* [`commercelayer capture:refund ID`](#commercelayer-capturerefund-id)
|
|
49
51
|
* [`commercelayer capture:refund_amount_cents ID`](#commercelayer-capturerefund_amount_cents-id)
|
|
50
52
|
* [`commercelayer checkout_com_payment ID`](#commercelayer-checkout_com_payment-id)
|
|
@@ -52,6 +54,8 @@ $ commercelayer plugins:install triggers
|
|
|
52
54
|
* [`commercelayer checkout_com_payment:refresh ID`](#commercelayer-checkout_com_paymentrefresh-id)
|
|
53
55
|
* [`commercelayer customer_password_reset ID`](#commercelayer-customer_password_reset-id)
|
|
54
56
|
* [`commercelayer customer_password_reset:reset_password_token ID`](#commercelayer-customer_password_resetreset_password_token-id)
|
|
57
|
+
* [`commercelayer event ID`](#commercelayer-event-id)
|
|
58
|
+
* [`commercelayer event:trigger ID`](#commercelayer-eventtrigger-id)
|
|
55
59
|
* [`commercelayer external_gateway ID`](#commercelayer-external_gateway-id)
|
|
56
60
|
* [`commercelayer external_gateway:reset_circuit ID`](#commercelayer-external_gatewayreset_circuit-id)
|
|
57
61
|
* [`commercelayer external_promotion ID`](#commercelayer-external_promotion-id)
|
|
@@ -142,6 +146,8 @@ $ commercelayer plugins:install triggers
|
|
|
142
146
|
* [`commercelayer return:archive ID`](#commercelayer-returnarchive-id)
|
|
143
147
|
* [`commercelayer return:cancel ID`](#commercelayer-returncancel-id)
|
|
144
148
|
* [`commercelayer return:receive ID`](#commercelayer-returnreceive-id)
|
|
149
|
+
* [`commercelayer return:refund ID`](#commercelayer-returnrefund-id)
|
|
150
|
+
* [`commercelayer return:refund_amount_cents ID`](#commercelayer-returnrefund_amount_cents-id)
|
|
145
151
|
* [`commercelayer return:reject ID`](#commercelayer-returnreject-id)
|
|
146
152
|
* [`commercelayer return:request ID`](#commercelayer-returnrequest-id)
|
|
147
153
|
* [`commercelayer return:restock ID`](#commercelayer-returnrestock-id)
|
|
@@ -282,7 +288,7 @@ _See code: [src/commands/authorization/capture.ts](https://github.com/commercela
|
|
|
282
288
|
|
|
283
289
|
### `commercelayer authorization:capture_amount_cents ID`
|
|
284
290
|
|
|
285
|
-
|
|
291
|
+
Send this attribute as a value in cents if you want to overwrite the amount to be captured.
|
|
286
292
|
|
|
287
293
|
```sh-session
|
|
288
294
|
USAGE
|
|
@@ -297,11 +303,34 @@ FLAGS
|
|
|
297
303
|
-u, --unformatted print JSON output without indentation
|
|
298
304
|
|
|
299
305
|
DESCRIPTION
|
|
300
|
-
|
|
306
|
+
Send this attribute as a value in cents if you want to overwrite the amount to be captured.
|
|
301
307
|
```
|
|
302
308
|
|
|
303
309
|
_See code: [src/commands/authorization/capture_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/authorization/capture_amount_cents.ts)_
|
|
304
310
|
|
|
311
|
+
### `commercelayer authorization:forward ID`
|
|
312
|
+
|
|
313
|
+
Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.
|
|
314
|
+
|
|
315
|
+
```sh-session
|
|
316
|
+
USAGE
|
|
317
|
+
$ commercelayer authorization:forward ID [-u [-j -p]]
|
|
318
|
+
|
|
319
|
+
ARGUMENTS
|
|
320
|
+
ID the unique id of the resource
|
|
321
|
+
|
|
322
|
+
FLAGS
|
|
323
|
+
-j, --json print result in JSON format
|
|
324
|
+
-p, --print print out the modified resource
|
|
325
|
+
-u, --unformatted print JSON output without indentation
|
|
326
|
+
|
|
327
|
+
DESCRIPTION
|
|
328
|
+
Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states
|
|
329
|
+
accordingly.
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
_See code: [src/commands/authorization/forward.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/authorization/forward.ts)_
|
|
333
|
+
|
|
305
334
|
### `commercelayer authorization:void ID`
|
|
306
335
|
|
|
307
336
|
Send this attribute if you want to create a void for this authorization.
|
|
@@ -524,6 +553,29 @@ DESCRIPTION
|
|
|
524
553
|
|
|
525
554
|
_See code: [src/commands/capture/index.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/capture/index.ts)_
|
|
526
555
|
|
|
556
|
+
### `commercelayer capture:forward ID`
|
|
557
|
+
|
|
558
|
+
Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.
|
|
559
|
+
|
|
560
|
+
```sh-session
|
|
561
|
+
USAGE
|
|
562
|
+
$ commercelayer capture:forward ID [-u [-j -p]]
|
|
563
|
+
|
|
564
|
+
ARGUMENTS
|
|
565
|
+
ID the unique id of the resource
|
|
566
|
+
|
|
567
|
+
FLAGS
|
|
568
|
+
-j, --json print result in JSON format
|
|
569
|
+
-p, --print print out the modified resource
|
|
570
|
+
-u, --unformatted print JSON output without indentation
|
|
571
|
+
|
|
572
|
+
DESCRIPTION
|
|
573
|
+
Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states
|
|
574
|
+
accordingly.
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
_See code: [src/commands/capture/forward.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/capture/forward.ts)_
|
|
578
|
+
|
|
527
579
|
### `commercelayer capture:refund ID`
|
|
528
580
|
|
|
529
581
|
Send this attribute if you want to create a refund for this capture.
|
|
@@ -548,7 +600,7 @@ _See code: [src/commands/capture/refund.ts](https://github.com/commercelayer/com
|
|
|
548
600
|
|
|
549
601
|
### `commercelayer capture:refund_amount_cents ID`
|
|
550
602
|
|
|
551
|
-
|
|
603
|
+
Send this attribute as a value in cents if you want to overwrite the amount to be refunded.
|
|
552
604
|
|
|
553
605
|
```sh-session
|
|
554
606
|
USAGE
|
|
@@ -563,7 +615,7 @@ FLAGS
|
|
|
563
615
|
-u, --unformatted print JSON output without indentation
|
|
564
616
|
|
|
565
617
|
DESCRIPTION
|
|
566
|
-
|
|
618
|
+
Send this attribute as a value in cents if you want to overwrite the amount to be refunded.
|
|
567
619
|
```
|
|
568
620
|
|
|
569
621
|
_See code: [src/commands/capture/refund_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/capture/refund_amount_cents.ts)_
|
|
@@ -678,6 +730,50 @@ DESCRIPTION
|
|
|
678
730
|
|
|
679
731
|
_See code: [src/commands/customer_password_reset/reset_password_token.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/customer_password_reset/reset_password_token.ts)_
|
|
680
732
|
|
|
733
|
+
### `commercelayer event ID`
|
|
734
|
+
|
|
735
|
+
Execute an action on a resource of type events.
|
|
736
|
+
|
|
737
|
+
```sh-session
|
|
738
|
+
USAGE
|
|
739
|
+
$ commercelayer event ID [-u [-j -p]]
|
|
740
|
+
|
|
741
|
+
ARGUMENTS
|
|
742
|
+
ID the unique id of the resource
|
|
743
|
+
|
|
744
|
+
FLAGS
|
|
745
|
+
-j, --json print result in JSON format
|
|
746
|
+
-p, --print print out the modified resource
|
|
747
|
+
-u, --unformatted print JSON output without indentation
|
|
748
|
+
|
|
749
|
+
DESCRIPTION
|
|
750
|
+
execute an action on a resource of type events
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
_See code: [src/commands/event/index.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/event/index.ts)_
|
|
754
|
+
|
|
755
|
+
### `commercelayer event:trigger ID`
|
|
756
|
+
|
|
757
|
+
Send this attribute if you want to force webhooks execution for this event.
|
|
758
|
+
|
|
759
|
+
```sh-session
|
|
760
|
+
USAGE
|
|
761
|
+
$ commercelayer event:trigger ID [-u [-j -p]]
|
|
762
|
+
|
|
763
|
+
ARGUMENTS
|
|
764
|
+
ID the unique id of the resource
|
|
765
|
+
|
|
766
|
+
FLAGS
|
|
767
|
+
-j, --json print result in JSON format
|
|
768
|
+
-p, --print print out the modified resource
|
|
769
|
+
-u, --unformatted print JSON output without indentation
|
|
770
|
+
|
|
771
|
+
DESCRIPTION
|
|
772
|
+
Send this attribute if you want to force webhooks execution for this event.
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
_See code: [src/commands/event/trigger.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/event/trigger.ts)_
|
|
776
|
+
|
|
681
777
|
### `commercelayer external_gateway ID`
|
|
682
778
|
|
|
683
779
|
Execute an action on a resource of type external_gateways.
|
|
@@ -1657,7 +1753,7 @@ _See code: [src/commands/order/archive.ts](https://github.com/commercelayer/comm
|
|
|
1657
1753
|
|
|
1658
1754
|
### `commercelayer order:authorization_amount_cents ID`
|
|
1659
1755
|
|
|
1660
|
-
|
|
1756
|
+
Send this attribute as a value in cents if you want to overwrite the amount to be authorized.
|
|
1661
1757
|
|
|
1662
1758
|
```sh-session
|
|
1663
1759
|
USAGE
|
|
@@ -1672,7 +1768,7 @@ FLAGS
|
|
|
1672
1768
|
-u, --unformatted print JSON output without indentation
|
|
1673
1769
|
|
|
1674
1770
|
DESCRIPTION
|
|
1675
|
-
|
|
1771
|
+
Send this attribute as a value in cents if you want to overwrite the amount to be authorized.
|
|
1676
1772
|
```
|
|
1677
1773
|
|
|
1678
1774
|
_See code: [src/commands/order/authorization_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/order/authorization_amount_cents.ts)_
|
|
@@ -1859,7 +1955,7 @@ _See code: [src/commands/order/customer_payment_source_id.ts](https://github.com
|
|
|
1859
1955
|
|
|
1860
1956
|
### `commercelayer order:fulfill ID`
|
|
1861
1957
|
|
|
1862
|
-
Send this attribute if you want to mark as fulfilled
|
|
1958
|
+
Send this attribute if you want to mark as fulfilled the order (shipments must be cancelled, shipped or delivered).
|
|
1863
1959
|
|
|
1864
1960
|
```sh-session
|
|
1865
1961
|
USAGE
|
|
@@ -1874,7 +1970,7 @@ FLAGS
|
|
|
1874
1970
|
-u, --unformatted print JSON output without indentation
|
|
1875
1971
|
|
|
1876
1972
|
DESCRIPTION
|
|
1877
|
-
Send this attribute if you want to mark as fulfilled
|
|
1973
|
+
Send this attribute if you want to mark as fulfilled the order (shipments must be cancelled, shipped or delivered).
|
|
1878
1974
|
```
|
|
1879
1975
|
|
|
1880
1976
|
_See code: [src/commands/order/fulfill.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/order/fulfill.ts)_
|
|
@@ -2680,6 +2776,50 @@ DESCRIPTION
|
|
|
2680
2776
|
|
|
2681
2777
|
_See code: [src/commands/return/receive.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/return/receive.ts)_
|
|
2682
2778
|
|
|
2779
|
+
### `commercelayer return:refund ID`
|
|
2780
|
+
|
|
2781
|
+
Send this attribute if you want to create a refund for this return.
|
|
2782
|
+
|
|
2783
|
+
```sh-session
|
|
2784
|
+
USAGE
|
|
2785
|
+
$ commercelayer return:refund ID [-u [-j -p]]
|
|
2786
|
+
|
|
2787
|
+
ARGUMENTS
|
|
2788
|
+
ID the unique id of the resource
|
|
2789
|
+
|
|
2790
|
+
FLAGS
|
|
2791
|
+
-j, --json print result in JSON format
|
|
2792
|
+
-p, --print print out the modified resource
|
|
2793
|
+
-u, --unformatted print JSON output without indentation
|
|
2794
|
+
|
|
2795
|
+
DESCRIPTION
|
|
2796
|
+
Send this attribute if you want to create a refund for this return.
|
|
2797
|
+
```
|
|
2798
|
+
|
|
2799
|
+
_See code: [src/commands/return/refund.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/return/refund.ts)_
|
|
2800
|
+
|
|
2801
|
+
### `commercelayer return:refund_amount_cents ID`
|
|
2802
|
+
|
|
2803
|
+
Send this attribute as a value in cents to specify the amount to be refunded.
|
|
2804
|
+
|
|
2805
|
+
```sh-session
|
|
2806
|
+
USAGE
|
|
2807
|
+
$ commercelayer return:refund_amount_cents ID [-u [-j -p]]
|
|
2808
|
+
|
|
2809
|
+
ARGUMENTS
|
|
2810
|
+
ID the unique id of the resource
|
|
2811
|
+
|
|
2812
|
+
FLAGS
|
|
2813
|
+
-j, --json print result in JSON format
|
|
2814
|
+
-p, --print print out the modified resource
|
|
2815
|
+
-u, --unformatted print JSON output without indentation
|
|
2816
|
+
|
|
2817
|
+
DESCRIPTION
|
|
2818
|
+
Send this attribute as a value in cents to specify the amount to be refunded.
|
|
2819
|
+
```
|
|
2820
|
+
|
|
2821
|
+
_See code: [src/commands/return/refund_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/return/refund_amount_cents.ts)_
|
|
2822
|
+
|
|
2683
2823
|
### `commercelayer return:reject ID`
|
|
2684
2824
|
|
|
2685
2825
|
Send this attribute if you want to mark this return as rejected.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class AuthorizationForward extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const authorizations_1 = require("../../triggers/authorizations");
|
|
6
|
+
const TRIGGER = 'forward';
|
|
7
|
+
class AuthorizationForward extends base_1.default {
|
|
8
|
+
static description = authorizations_1.triggers[TRIGGER].description;
|
|
9
|
+
static flags = {};
|
|
10
|
+
static args = {
|
|
11
|
+
...base_1.default.args,
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(AuthorizationForward);
|
|
15
|
+
const res = await this.executeAction('authorizations', args.id, TRIGGER, flags);
|
|
16
|
+
if (flags.print)
|
|
17
|
+
this.printOutput(res, flags);
|
|
18
|
+
this.successMessage('authorization', TRIGGER, res.id);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = AuthorizationForward;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class CaptureForward extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const captures_1 = require("../../triggers/captures");
|
|
6
|
+
const TRIGGER = 'forward';
|
|
7
|
+
class CaptureForward extends base_1.default {
|
|
8
|
+
static description = captures_1.triggers[TRIGGER].description;
|
|
9
|
+
static flags = {};
|
|
10
|
+
static args = {
|
|
11
|
+
...base_1.default.args,
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(CaptureForward);
|
|
15
|
+
const res = await this.executeAction('captures', args.id, TRIGGER, flags);
|
|
16
|
+
if (flags.print)
|
|
17
|
+
this.printOutput(res, flags);
|
|
18
|
+
this.successMessage('capture', TRIGGER, res.id);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = CaptureForward;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class EventIndex extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const exec_1 = tslib_1.__importDefault(require("../../exec"));
|
|
6
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
|
+
const cli_core_1 = require("@commercelayer/cli-core");
|
|
8
|
+
const events_1 = require("../../triggers/events");
|
|
9
|
+
const promptAction = async (id) => {
|
|
10
|
+
const answers = await inquirer_1.default.prompt([{
|
|
11
|
+
type: 'list',
|
|
12
|
+
name: 'trigger',
|
|
13
|
+
message: `Select an action to execute on event ${cli_core_1.clColor.api.id(id)}:`,
|
|
14
|
+
choices: Object.keys(events_1.triggers).sort().map(a => {
|
|
15
|
+
return { name: a, value: a };
|
|
16
|
+
}),
|
|
17
|
+
loop: false,
|
|
18
|
+
pageSize: 10,
|
|
19
|
+
}]);
|
|
20
|
+
return answers.trigger;
|
|
21
|
+
};
|
|
22
|
+
class EventIndex extends base_1.default {
|
|
23
|
+
static description = 'execute an action on a resource of type events';
|
|
24
|
+
static flags = {};
|
|
25
|
+
static args = {
|
|
26
|
+
...base_1.default.args,
|
|
27
|
+
};
|
|
28
|
+
async run() {
|
|
29
|
+
const { args, flags } = await this.parse(EventIndex);
|
|
30
|
+
const id = args.id;
|
|
31
|
+
const action = await promptAction(id);
|
|
32
|
+
const fields = [];
|
|
33
|
+
const res = await (0, exec_1.default)('events', id, action, flags, fields);
|
|
34
|
+
this.log();
|
|
35
|
+
this.printOutput(res, flags);
|
|
36
|
+
this.successMessage('event', action, res.id);
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = EventIndex;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class EventTrigger extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const events_1 = require("../../triggers/events");
|
|
6
|
+
const TRIGGER = 'trigger';
|
|
7
|
+
class EventTrigger extends base_1.default {
|
|
8
|
+
static description = events_1.triggers[TRIGGER].description;
|
|
9
|
+
static flags = {};
|
|
10
|
+
static args = {
|
|
11
|
+
...base_1.default.args,
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(EventTrigger);
|
|
15
|
+
const res = await this.executeAction('events', args.id, TRIGGER, flags);
|
|
16
|
+
if (flags.print)
|
|
17
|
+
this.printOutput(res, flags);
|
|
18
|
+
this.successMessage('event', TRIGGER, res.id);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = EventTrigger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class ReturnRefund extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const returns_1 = require("../../triggers/returns");
|
|
6
|
+
const TRIGGER = 'refund';
|
|
7
|
+
class ReturnRefund extends base_1.default {
|
|
8
|
+
static description = returns_1.triggers[TRIGGER].description;
|
|
9
|
+
static flags = {};
|
|
10
|
+
static args = {
|
|
11
|
+
...base_1.default.args,
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(ReturnRefund);
|
|
15
|
+
const res = await this.executeAction('returns', args.id, TRIGGER, flags);
|
|
16
|
+
if (flags.print)
|
|
17
|
+
this.printOutput(res, flags);
|
|
18
|
+
this.successMessage('return', TRIGGER, res.id);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = ReturnRefund;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class ReturnRefundAmountCents extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const returns_1 = require("../../triggers/returns");
|
|
6
|
+
const TRIGGER = 'refund_amount_cents';
|
|
7
|
+
class ReturnRefundAmountCents extends base_1.default {
|
|
8
|
+
static description = returns_1.triggers[TRIGGER].description;
|
|
9
|
+
static flags = {};
|
|
10
|
+
static args = {
|
|
11
|
+
...base_1.default.args,
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(ReturnRefundAmountCents);
|
|
15
|
+
const res = await this.executeAction('returns', args.id, TRIGGER, flags);
|
|
16
|
+
if (flags.print)
|
|
17
|
+
this.printOutput(res, flags);
|
|
18
|
+
this.successMessage('return', TRIGGER, res.id);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = ReturnRefundAmountCents;
|
package/lib/exec.js
CHANGED
|
@@ -19,10 +19,11 @@ const commercelayerInit = (flags, config) => {
|
|
|
19
19
|
const exec = async (resourceType, id, action, flags, fields, config) => {
|
|
20
20
|
const cl = commercelayerInit(flags, config);
|
|
21
21
|
const resSdk = cl[resourceType];
|
|
22
|
-
await
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
await resSdk.retrieve(id).catch((err) => {
|
|
23
|
+
if (cl.isApiError(err) && (err.status === 404)) {
|
|
24
|
+
const resource = cli_core_1.clApi.humanizeResource(cli_core_1.clText.singularize(resourceType));
|
|
25
25
|
throw new errors_1.CLIError(`Invalid ${resource} or ${resource} not found: ${cli_core_1.clColor.msg.error(id)}`);
|
|
26
|
+
}
|
|
26
27
|
});
|
|
27
28
|
const res = { id, [`_${action}`]: flags.value || true };
|
|
28
29
|
const params = {};
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.triggers = void 0;
|
|
4
4
|
exports.triggers = {
|
|
5
|
+
forward: {
|
|
6
|
+
action: 'forward',
|
|
7
|
+
trigger: '_forward',
|
|
8
|
+
description: 'Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.',
|
|
9
|
+
},
|
|
5
10
|
capture: {
|
|
6
11
|
action: 'capture',
|
|
7
12
|
trigger: '_capture',
|
|
@@ -10,7 +15,7 @@ exports.triggers = {
|
|
|
10
15
|
capture_amount_cents: {
|
|
11
16
|
action: 'capture_amount_cents',
|
|
12
17
|
trigger: '_capture_amount_cents',
|
|
13
|
-
description: '
|
|
18
|
+
description: 'Send this attribute as a value in cents if you want to overwrite the amount to be captured.',
|
|
14
19
|
},
|
|
15
20
|
void: {
|
|
16
21
|
action: 'void',
|
package/lib/triggers/captures.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.triggers = void 0;
|
|
4
4
|
exports.triggers = {
|
|
5
|
+
forward: {
|
|
6
|
+
action: 'forward',
|
|
7
|
+
trigger: '_forward',
|
|
8
|
+
description: 'Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.',
|
|
9
|
+
},
|
|
5
10
|
refund: {
|
|
6
11
|
action: 'refund',
|
|
7
12
|
trigger: '_refund',
|
|
@@ -10,6 +15,6 @@ exports.triggers = {
|
|
|
10
15
|
refund_amount_cents: {
|
|
11
16
|
action: 'refund_amount_cents',
|
|
12
17
|
trigger: '_refund_amount_cents',
|
|
13
|
-
description: '
|
|
18
|
+
description: 'Send this attribute as a value in cents if you want to overwrite the amount to be refunded.',
|
|
14
19
|
},
|
|
15
20
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.triggers = void 0;
|
|
4
|
+
exports.triggers = {
|
|
5
|
+
trigger: {
|
|
6
|
+
action: 'trigger',
|
|
7
|
+
trigger: '_trigger',
|
|
8
|
+
description: 'Send this attribute if you want to force webhooks execution for this event.',
|
|
9
|
+
},
|
|
10
|
+
};
|
package/lib/triggers/orders.js
CHANGED
|
@@ -45,7 +45,7 @@ exports.triggers = {
|
|
|
45
45
|
authorization_amount_cents: {
|
|
46
46
|
action: 'authorization_amount_cents',
|
|
47
47
|
trigger: '_authorization_amount_cents',
|
|
48
|
-
description: '
|
|
48
|
+
description: 'Send this attribute as a value in cents if you want to overwrite the amount to be authorized.',
|
|
49
49
|
},
|
|
50
50
|
capture: {
|
|
51
51
|
action: 'capture',
|
|
@@ -60,7 +60,7 @@ exports.triggers = {
|
|
|
60
60
|
fulfill: {
|
|
61
61
|
action: 'fulfill',
|
|
62
62
|
trigger: '_fulfill',
|
|
63
|
-
description: 'Send this attribute if you want to mark as fulfilled
|
|
63
|
+
description: 'Send this attribute if you want to mark as fulfilled the order (shipments must be cancelled, shipped or delivered).',
|
|
64
64
|
},
|
|
65
65
|
update_taxes: {
|
|
66
66
|
action: 'update_taxes',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Trigger } from '../common';
|
|
2
2
|
export declare const triggers: Record<string, Trigger>;
|
|
3
|
-
export type ActionType = 'request' | 'approve' | 'cancel' | 'ship' | 'reject' | 'receive' | 'restock' | 'archive' | 'unarchive';
|
|
3
|
+
export type ActionType = 'request' | 'approve' | 'cancel' | 'ship' | 'reject' | 'receive' | 'restock' | 'archive' | 'unarchive' | 'refund' | 'refund_amount_cents';
|
package/lib/triggers/returns.js
CHANGED
|
@@ -47,4 +47,14 @@ exports.triggers = {
|
|
|
47
47
|
trigger: '_unarchive',
|
|
48
48
|
description: 'Send this attribute if you want to unarchive the return.',
|
|
49
49
|
},
|
|
50
|
+
refund: {
|
|
51
|
+
action: 'refund',
|
|
52
|
+
trigger: '_refund',
|
|
53
|
+
description: 'Send this attribute if you want to create a refund for this return.',
|
|
54
|
+
},
|
|
55
|
+
refund_amount_cents: {
|
|
56
|
+
action: 'refund_amount_cents',
|
|
57
|
+
trigger: '_refund_amount_cents',
|
|
58
|
+
description: 'Send this attribute as a value in cents to specify the amount to be refunded.',
|
|
59
|
+
},
|
|
50
60
|
};
|