Skip to content

Commit bf95853

Browse files
authored
Merging pull request #17561
* [FEATURE] Create new action to create Wix draft post #17460 Actions - Publish Draft Post * pnpm update
1 parent 8f4598a commit bf95853

File tree

10 files changed

+96
-11
lines changed

10 files changed

+96
-11
lines changed

components/wix_api_key/actions/add-products-to-collection/add-products-to-collection.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "wix_api_key-add-products-to-collection",
55
name: "Add Products To Collection",
66
description: "Adds a product or products to a specified collection. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/collections/add-products-to-collection)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
wix,

components/wix_api_key/actions/create-contact/create-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "wix_api_key-create-contact",
55
name: "Create Contact",
66
description: "Creates a new contact. [See the documentation](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/create-contact)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
wix,

components/wix_api_key/actions/create-product/create-product.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "wix_api_key-create-product",
55
name: "Create Product",
66
description: "Creates a new product. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/products/create-product)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
wix,

components/wix_api_key/actions/get-contact/get-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "wix_api_key-get-contact",
55
name: "Get Contact",
66
description: "Retrieves information about a contact. [See the documentation](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/get-contact)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
wix,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import wix from "../../wix_api_key.app.mjs";
2+
3+
export default {
4+
key: "wix_api_key-publish-draft-post",
5+
name: "Publish Draft Post",
6+
description: "Publish a draft blog post [See the documentation](https://dev.wix.com/docs/rest/business-solutions/blog/draft-posts/publish-draft-post)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
wix,
11+
alert: {
12+
type: "alert",
13+
alertType: "info",
14+
content: "Note: You must have 'Blog' installed in your Wix website or this will return an error.",
15+
},
16+
site: {
17+
propDefinition: [
18+
wix,
19+
"site",
20+
],
21+
},
22+
draftPostId: {
23+
propDefinition: [
24+
wix,
25+
"draftPostId",
26+
(c) => ({
27+
siteId: c.site,
28+
}),
29+
],
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.wix.publishDraftPost({
34+
$,
35+
siteId: this.site,
36+
postId: this.draftPostId,
37+
});
38+
39+
$.export("$summary", `Successfully published draft post ${this.draftPostId}`);
40+
return response;
41+
},
42+
};

components/wix_api_key/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/wix_api_key",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Wix Components",
55
"main": "wix_api_key.app.mjs",
66
"keywords": [

components/wix_api_key/sources/new-member-registered/new-member-registered.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import common from "../common/common.mjs";
21
import constants from "../../common/constants.mjs";
2+
import common from "../common/common.mjs";
33

44
export default {
55
...common,
66
key: "wix_api_key-new-member-registered",
77
name: "New Member Registered",
88
description: "Emit new event when a new member is registered. [See the documentation](https://dev.wix.com/api/rest/members/members/list-members)",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "source",
1111
methods: {
1212
...common.methods,

components/wix_api_key/sources/new-order-created/new-order-created.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import common from "../common/common.mjs";
21
import constants from "../../common/constants.mjs";
2+
import common from "../common/common.mjs";
33

44
export default {
55
...common,
66
key: "wix_api_key-new-order-created",
77
name: "New Order Created",
88
description: "Emit new event when a new order is created. [See the documentation](https://dev.wix.com/api/rest/wix-stores/orders/query-orders)",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "source",
1111
methods: {
1212
...common.methods,

components/wix_api_key/sources/new-product-created/new-product-created.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import common from "../common/common.mjs";
21
import constants from "../../common/constants.mjs";
2+
import common from "../common/common.mjs";
33

44
export default {
55
...common,
66
key: "wix_api_key-new-product-created",
77
name: "New Product Created",
88
description: "Emit new event when a new product is created. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/products/query-products)",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "source",
1111
methods: {
1212
...common.methods,

components/wix_api_key/wix_api_key.app.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,33 @@ export default {
133133
})) || [];
134134
},
135135
},
136+
draftPostId: {
137+
type: "string",
138+
label: "Draft Post ID",
139+
description: "The ID of the draft post to publish",
140+
async options({
141+
page, siteId,
142+
}) {
143+
const limit = constants.DEFAULT_LIMIT;
144+
const params = {
145+
"paging.limit": limit,
146+
"paging.offset": page * limit,
147+
"status": "UNPUBLISHED",
148+
};
149+
150+
const { draftPosts } = await this.listDraftPosts({
151+
siteId,
152+
params,
153+
});
154+
155+
return draftPosts?.map(({
156+
id: value, title: label,
157+
}) => ({
158+
label,
159+
value,
160+
})) || [];
161+
},
162+
},
136163
},
137164
methods: {
138165
_baseUrl() {
@@ -259,5 +286,21 @@ export default {
259286
...args,
260287
});
261288
},
289+
listDraftPosts(opts = {}) {
290+
return this._makeRequest({
291+
path: "/blog/v3/draft-posts",
292+
...opts,
293+
});
294+
},
295+
publishDraftPost({
296+
postId,
297+
...opts
298+
}) {
299+
return this._makeRequest({
300+
method: "POST",
301+
path: `/blog/v3/draft-posts/${postId}/publish`,
302+
...opts,
303+
});
304+
},
262305
},
263306
};

0 commit comments

Comments
 (0)