@pipedream/everstox 0.0.1 → 0.2.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.
@@ -0,0 +1,33 @@
1
+ import everstox from "../../everstox.app.mjs";
2
+
3
+ export default {
4
+ key: "everstox-get-order",
5
+ name: "Get Order",
6
+ description: "Get an order from Everstox. [See the documentation](https://api.everstox.com/api/v1/ui/#/Order/district_core.api.shops.orders.orders.Orders.get)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ everstox,
16
+ orderId: {
17
+ propDefinition: [
18
+ everstox,
19
+ "orderId",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const response = await this.everstox.getOrder({
25
+ $,
26
+ orderId: this.orderId,
27
+ });
28
+
29
+ $.export("$summary", `Successfully retrieved order with ID \`${this.orderId}\`.`);
30
+
31
+ return response;
32
+ },
33
+ };
@@ -0,0 +1,31 @@
1
+ import everstox from "../../everstox.app.mjs";
2
+
3
+ export default {
4
+ key: "everstox-get-return",
5
+ name: "Get Return",
6
+ description: "Get a return from Everstox. [See the documentation](https://api.everstox.com/api/v1/ui/#/Returns%20V2/district_core.api.shops.returns_v2.returns_v2.ReturnsV2.get)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ everstox,
16
+ returnId: {
17
+ propDefinition: [
18
+ everstox,
19
+ "returnId",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const response = await this.everstox.getReturn({
25
+ $,
26
+ returnId: this.returnId,
27
+ });
28
+ $.export("$summary", `Successfully retrieved return with ID \`${this.returnId}\`.`);
29
+ return response;
30
+ },
31
+ };
@@ -0,0 +1,110 @@
1
+ import everstox from "../../everstox.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ key: "everstox-list-returns",
6
+ name: "List Returns",
7
+ description: "List returns from Everstox. [See the documentation](https://api.everstox.com/api/v1/ui/#/Returns%20V2/district_core.api.shops.returns_v2.returns_v2.ReturnsV2.index)",
8
+ version: "0.0.2",
9
+ type: "action",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: true,
14
+ },
15
+ props: {
16
+ everstox,
17
+ orderNumber: {
18
+ propDefinition: [
19
+ everstox,
20
+ "orderNumber",
21
+ ],
22
+ optional: true,
23
+ },
24
+ rmaNumber: {
25
+ type: "string",
26
+ label: "RMA Number",
27
+ description: "Filter by RMA number",
28
+ optional: true,
29
+ },
30
+ updatedDateGte: {
31
+ type: "string",
32
+ label: "Updated Date Greater Than or Equal To",
33
+ description: "Filter returns with updated date greater than or equal to the provided date. Example: `2021-02-23`",
34
+ optional: true,
35
+ },
36
+ updatedDateLte: {
37
+ type: "string",
38
+ label: "Updated Date Less Than or Equal To",
39
+ description: "Filter returns with updated date less than or equal to the provided date. Example: `2021-02-23`",
40
+ optional: true,
41
+ },
42
+ createdDateGte: {
43
+ type: "string",
44
+ label: "Created Date Greater Than or Equal To",
45
+ description: "Filter returns with created date greater than or equal to the provided date. Example: `2021-02-23`",
46
+ optional: true,
47
+ },
48
+ createdDateLte: {
49
+ type: "string",
50
+ label: "Created Date Less Than or Equal To",
51
+ description: "Filter returns with created date less than or equal to the provided date. Example: `2021-02-23`",
52
+ optional: true,
53
+ },
54
+ returnReviewed: {
55
+ type: "boolean",
56
+ label: "Return Reviewed",
57
+ description: "Filter returns by return reviewed status",
58
+ optional: true,
59
+ },
60
+ productSku: {
61
+ type: "string",
62
+ label: "Product SKU",
63
+ description: "Filter returns by product SKU",
64
+ optional: true,
65
+ },
66
+ limit: {
67
+ type: "integer",
68
+ label: "Limit",
69
+ description: "The number of items to return (default 10)",
70
+ optional: true,
71
+ },
72
+ offset: {
73
+ type: "integer",
74
+ label: "Offset",
75
+ description: "The number of items to skip before starting to collect the result set",
76
+ optional: true,
77
+ },
78
+ orderBy: {
79
+ type: "string",
80
+ label: "Order By",
81
+ description: "The field to order by",
82
+ options: constants.ORDER_BY_OPTIONS,
83
+ optional: true,
84
+ },
85
+ },
86
+ async run({ $ }) {
87
+ const response = await this.everstox.listReturns({
88
+ $,
89
+ params: {
90
+ order_number: this.orderNumber,
91
+ stategroup: "all",
92
+ rma_num: this.rmaNumber,
93
+ updated_date_gte: this.updatedDateGte,
94
+ updated_date_lte: this.updatedDateLte,
95
+ creation_date_gte: this.createdDateGte,
96
+ creation_date_lte: this.createdDateLte,
97
+ return_reviewed: this.returnReviewed,
98
+ product_sku: this.productSku,
99
+ limit: this.limit,
100
+ offset: this.offset,
101
+ order_by: this.orderBy,
102
+ exact_search: false,
103
+ },
104
+ });
105
+ $.export("$summary", `Successfully retrieved ${response.items.length} return${response.items.length === 1
106
+ ? ""
107
+ : "s"}`);
108
+ return response;
109
+ },
110
+ };
@@ -0,0 +1,145 @@
1
+ import constants from "../../common/constants.mjs";
2
+ import everstox from "../../everstox.app.mjs";
3
+
4
+ export default {
5
+ key: "everstox-search-orders",
6
+ name: "Search Orders by Order Number",
7
+ description: "Search orders from Everstox. [See the documentation](https://api.everstox.com/api/v1/ui/#/Order/district_core.api.shops.orders.orders.Orders.index)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: true,
14
+ },
15
+ props: {
16
+ everstox,
17
+ warehouseIds: {
18
+ propDefinition: [
19
+ everstox,
20
+ "warehouseIds",
21
+ ],
22
+ optional: true,
23
+ },
24
+ fields: {
25
+ propDefinition: [
26
+ everstox,
27
+ "fields",
28
+ ],
29
+ type: "string[]",
30
+ label: "Fields",
31
+ description: "Fields to filter for",
32
+ optional: true,
33
+ },
34
+ orderNumber: {
35
+ propDefinition: [
36
+ everstox,
37
+ "orderNumber",
38
+ ],
39
+ description: "Filter for order number",
40
+ optional: true,
41
+ },
42
+ hoursLateLte: {
43
+ type: "integer",
44
+ label: "Hours Late Less Than or Equal to",
45
+ description: "Filter for orders late for the amount of hours less or equal than the provided value",
46
+ optional: true,
47
+ },
48
+ hoursLateGte: {
49
+ type: "integer",
50
+ label: "Hours Late Greater Than or Equal to",
51
+ description: "Filter for orders late for the amount of hours greater or equal than the provided value",
52
+ optional: true,
53
+ },
54
+ search: {
55
+ type: "string",
56
+ label: "Search",
57
+ description: "Multi-attribute-search filters either for Customer Email or Billing Address or Order Number. Returns set of orders where at least one of those attributes match the search term",
58
+ optional: true,
59
+ },
60
+ fulfillmentState: {
61
+ type: "string",
62
+ label: "Fulfillment State",
63
+ description: "Fulfillment State to filter for order where the corresponding fulfillment is in the given state",
64
+ options: constants.FULFILLMENT_STATE_OPTIONS,
65
+ optional: true,
66
+ },
67
+ fulfillmentStategroup: {
68
+ type: "string",
69
+ label: "Fulfillment Stategroup",
70
+ description: "Fulfillment Stategroup to filter for order where the corresponding fulfillment is in the given stategroup",
71
+ options: constants.FULFILLMENT_STATEGROUP_OPTIONS,
72
+ optional: true,
73
+ },
74
+ stategroup: {
75
+ type: "string",
76
+ label: "Stategroup",
77
+ description: "Stategroup to filter for, e.g. open includes states like new, in_progress etc",
78
+ options: constants.STATEGROUP_OPTIONS,
79
+ optional: true,
80
+ },
81
+ cancellationState: {
82
+ type: "string",
83
+ label: "Cancellation State",
84
+ description: "Cancellation State to filter for order with min 1 cancellation in that state",
85
+ options: constants.CANCELLATION_STATE_OPTIONS,
86
+ optional: true,
87
+ },
88
+ shipmentDateGte: {
89
+ type: "string",
90
+ label: "Shipment Date Greater Than or Equal",
91
+ description: "Find orders whose shipment date is greater than or equal to the provided value",
92
+ optional: true,
93
+ },
94
+ updatedDateGte: {
95
+ type: "string",
96
+ label: "Updated Date Greater Than or Equal",
97
+ description: "Find orders whose updated date is greater than or equal to the provided value",
98
+ optional: true,
99
+ },
100
+ createdDateGte: {
101
+ type: "string",
102
+ label: "Created Date Greater Than or Equal",
103
+ description: "Find orders whose creation date is greater than or equal to the provided value",
104
+ optional: true,
105
+ },
106
+ createdDateLte: {
107
+ type: "string",
108
+ label: "Created Date Less Than or Equal",
109
+ description: "Find orders whose created date is less than or equal to the provided value",
110
+ optional: true,
111
+ },
112
+ shipmentsForwardedToShop: {
113
+ type: "boolean",
114
+ label: "Shipments Forwarded to Shop",
115
+ description: "Boolean returning orders with shipments forwarded to shop",
116
+ optional: true,
117
+ },
118
+ },
119
+ async run({ $ }) {
120
+ const response = await this.everstox.listOrders({
121
+ $,
122
+ params: {
123
+ warehouse_ids: this.warehouseIds,
124
+ fields: this.fields,
125
+ order_number: this.orderNumber,
126
+ hours_late_lte: this.hoursLateLte,
127
+ hours_late_gte: this.hoursLateGte,
128
+ search: this.search,
129
+ fulfillment_state: this.fulfillmentState,
130
+ fulfillment_stategroup: this.fulfillmentStategroup,
131
+ stategroup: this.stategroup,
132
+ cancellation_state: this.cancellationState,
133
+ shipment_date_gte: this.shipmentDateGte,
134
+ updated_date_gte: this.updatedDateGte,
135
+ created_date_gte: this.createdDateGte,
136
+ created_date_lte: this.createdDateLte,
137
+ shipments_forwarded_to_shop: this.shipmentsForwardedToShop,
138
+ },
139
+ });
140
+ $.export("$summary", `Successfully retrieved ${response.items.length} return${response.items.length === 1
141
+ ? ""
142
+ : "s"}`);
143
+ return response;
144
+ },
145
+ };
@@ -0,0 +1,52 @@
1
+ const LIMIT = 100;
2
+
3
+ const ORDER_BY_OPTIONS = [
4
+ "creation_date",
5
+ "order_number",
6
+ "rma_number",
7
+ ];
8
+
9
+ const FULFILLMENT_STATE_OPTIONS = [
10
+ "new",
11
+ "created",
12
+ "warehouse_confirmation_pending",
13
+ "accepted_by_connector",
14
+ "accepted_by_warehouse",
15
+ "rejected_by_warehouse",
16
+ "in_fulfillment",
17
+ "partially_shipped",
18
+ "shipped",
19
+ "cancelled",
20
+ ];
21
+
22
+ const FULFILLMENT_STATEGROUP_OPTIONS = [
23
+ "open",
24
+ "canceled",
25
+ "completed",
26
+ "all",
27
+ ];
28
+
29
+ const STATEGROUP_OPTIONS = [
30
+ "open",
31
+ "closed",
32
+ "requires_attention",
33
+ "all",
34
+ ];
35
+
36
+ const CANCELLATION_STATE_OPTIONS = [
37
+ "new",
38
+ "rejected",
39
+ "connector_confirmation_pending",
40
+ "accepted_by_connector",
41
+ "warehouse_cancellation_pending",
42
+ "completed",
43
+ ];
44
+
45
+ export default {
46
+ LIMIT,
47
+ ORDER_BY_OPTIONS,
48
+ FULFILLMENT_STATE_OPTIONS,
49
+ FULFILLMENT_STATEGROUP_OPTIONS,
50
+ STATEGROUP_OPTIONS,
51
+ CANCELLATION_STATE_OPTIONS,
52
+ };
package/everstox.app.mjs CHANGED
@@ -1,11 +1,135 @@
1
+ import { axios } from "@pipedream/platform";
2
+ import constants from "./common/constants.mjs";
3
+ const LIMIT = constants.LIMIT;
4
+
1
5
  export default {
2
6
  type: "app",
3
7
  app: "everstox",
4
- propDefinitions: {},
8
+ propDefinitions: {
9
+ warehouseIds: {
10
+ type: "string[]",
11
+ label: "Warehouse IDs",
12
+ description: "Warehouse IDs",
13
+ async options({ page }) {
14
+ const { items } = await this.listWarehouses({
15
+ params: {
16
+ limit: LIMIT,
17
+ offset: page * LIMIT,
18
+ },
19
+ });
20
+ return items?.map(({
21
+ id, name,
22
+ }) => ({
23
+ label: name,
24
+ value: id,
25
+ })) || [];
26
+ },
27
+ },
28
+ orderId: {
29
+ type: "string",
30
+ label: "Order ID",
31
+ description: "The ID of the order",
32
+ async options({ page }) {
33
+ const { items } = await this.listOrders({
34
+ params: {
35
+ limit: LIMIT,
36
+ offset: page * LIMIT,
37
+ },
38
+ });
39
+ return items?.map(({
40
+ id, order_number: orderNumber,
41
+ }) => ({
42
+ label: `Order Number: ${orderNumber}`,
43
+ value: id,
44
+ })) || [];
45
+ },
46
+ },
47
+ orderNumber: {
48
+ type: "string",
49
+ label: "Order Number",
50
+ description: "The number of the order",
51
+ async options({ page }) {
52
+ const { items } = await this.listOrders({
53
+ params: {
54
+ limit: LIMIT,
55
+ offset: page * LIMIT,
56
+ },
57
+ });
58
+ return items?.map(({ order_number: orderNumber }) => ({
59
+ label: `Order ${orderNumber}`,
60
+ value: orderNumber.replace(/^#/, ""),
61
+ })) || [];
62
+ },
63
+ },
64
+ returnId: {
65
+ type: "string",
66
+ label: "Return ID",
67
+ description: "The ID of the return",
68
+ async options({ page }) {
69
+ const { items } = await this.listReturns({
70
+ params: {
71
+ limit: LIMIT,
72
+ offset: page * LIMIT,
73
+ stategroup: "all",
74
+ },
75
+ });
76
+ return items?.map(({
77
+ id, order_number: orderNumber,
78
+ }) => ({
79
+ label: `Return for Order Number: ${orderNumber}`,
80
+ value: id,
81
+ })) || [];
82
+ },
83
+ },
84
+ },
5
85
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
86
+ _baseUrl() {
87
+ return `${this.$auth.api_url}shops/${this.$auth.shop_id}`;
88
+ },
89
+ _makeRequest({
90
+ $ = this, path, ...opts
91
+ }) {
92
+ return axios($, {
93
+ url: `${this._baseUrl()}${path}`,
94
+ headers: {
95
+ "everstox-shop-api-token": `${this.$auth.api_token}`,
96
+ },
97
+ ...opts,
98
+ });
99
+ },
100
+ getOrder({
101
+ orderId, ...opts
102
+ }) {
103
+ return this._makeRequest({
104
+ path: `/orders/${orderId}`,
105
+ ...opts,
106
+ });
107
+ },
108
+ getReturn({
109
+ returnId, ...opts
110
+ }) {
111
+ return this._makeRequest({
112
+ path: `/returns/v2/${returnId}`,
113
+ ...opts,
114
+ });
115
+ },
116
+ listOrders(opts = {}) {
117
+ return this._makeRequest({
118
+ path: "/orders",
119
+ ...opts,
120
+ });
121
+ },
122
+ listReturns(opts = {}) {
123
+ return this._makeRequest({
124
+ path: "/returns/v2",
125
+ ...opts,
126
+ });
127
+ },
128
+ listWarehouses(opts = {}) {
129
+ return this._makeRequest({
130
+ path: "/warehouses",
131
+ ...opts,
132
+ });
9
133
  },
10
134
  },
11
- };
135
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/everstox",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Pipedream Everstox Components",
5
5
  "main": "everstox.app.mjs",
6
6
  "keywords": [
@@ -11,5 +11,8 @@
11
11
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
12
  "publishConfig": {
13
13
  "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@pipedream/platform": "^3.3.0"
14
17
  }
15
18
  }