@pipedream/everstox 0.0.1 → 0.1.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.1",
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.1",
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.1",
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,12 @@
1
+ const LIMIT = 100;
2
+
3
+ const ORDER_BY_OPTIONS = [
4
+ "creation_date",
5
+ "order_number",
6
+ "rma_number",
7
+ ];
8
+
9
+ export default {
10
+ LIMIT,
11
+ ORDER_BY_OPTIONS,
12
+ };
package/everstox.app.mjs CHANGED
@@ -1,11 +1,110 @@
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
+ orderId: {
10
+ type: "string",
11
+ label: "Order ID",
12
+ description: "The ID of the order",
13
+ async options({ page }) {
14
+ const { items } = await this.listOrders({
15
+ params: {
16
+ limit: LIMIT,
17
+ offset: page * LIMIT,
18
+ },
19
+ });
20
+ return items?.map(({
21
+ id, order_number: orderNumber,
22
+ }) => ({
23
+ label: `Order Number: ${orderNumber}`,
24
+ value: id,
25
+ })) || [];
26
+ },
27
+ },
28
+ orderNumber: {
29
+ type: "string",
30
+ label: "Order Number",
31
+ description: "The number 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(({ order_number: orderNumber }) => ({
40
+ label: `Order ${orderNumber}`,
41
+ value: orderNumber.replace(/^#/, ""),
42
+ })) || [];
43
+ },
44
+ },
45
+ returnId: {
46
+ type: "string",
47
+ label: "Return ID",
48
+ description: "The ID of the return",
49
+ async options({ page }) {
50
+ const { items } = await this.listReturns({
51
+ params: {
52
+ limit: LIMIT,
53
+ offset: page * LIMIT,
54
+ stategroup: "all",
55
+ },
56
+ });
57
+ return items?.map(({
58
+ id, order_number: orderNumber,
59
+ }) => ({
60
+ label: `Return for Order Number: ${orderNumber}`,
61
+ value: id,
62
+ })) || [];
63
+ },
64
+ },
65
+ },
5
66
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
67
+ _baseUrl() {
68
+ return `${this.$auth.api_url}shops/${this.$auth.shop_id}`;
69
+ },
70
+ _makeRequest({
71
+ $ = this, path, ...opts
72
+ }) {
73
+ return axios($, {
74
+ url: `${this._baseUrl()}${path}`,
75
+ headers: {
76
+ "everstox-shop-api-token": `${this.$auth.api_token}`,
77
+ },
78
+ ...opts,
79
+ });
80
+ },
81
+ getOrder({
82
+ orderId, ...opts
83
+ }) {
84
+ return this._makeRequest({
85
+ path: `/orders/${orderId}`,
86
+ ...opts,
87
+ });
88
+ },
89
+ getReturn({
90
+ returnId, ...opts
91
+ }) {
92
+ return this._makeRequest({
93
+ path: `/returns/v2/${returnId}`,
94
+ ...opts,
95
+ });
96
+ },
97
+ listOrders(opts = {}) {
98
+ return this._makeRequest({
99
+ path: "/orders",
100
+ ...opts,
101
+ });
102
+ },
103
+ listReturns(opts = {}) {
104
+ return this._makeRequest({
105
+ path: "/returns/v2",
106
+ ...opts,
107
+ });
9
108
  },
10
109
  },
11
- };
110
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/everstox",
3
- "version": "0.0.1",
3
+ "version": "0.1.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
  }