Skip to content

[Components] Create Blog Post - WIX #15954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "wix_api_key-add-products-to-collection",
name: "Add Products To Collection",
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)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
wix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "wix_api_key-create-contact",
name: "Create Contact",
description: "Creates a new contact. [See the documentation](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/create-contact)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
wix,
Expand Down
160 changes: 160 additions & 0 deletions components/wix_api_key/actions/create-draft-post/create-draft-post.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import app from "../../wix_api_key.app.mjs";

export default {
key: "wix_api_key-create-draft-post",
name: "Create Draft Post",
description: "Creates a new draft post. [See the documentation](https://dev.wix.com/docs/rest/business-solutions/blog/draft-posts/create-draft-post).",
version: "0.0.1",
type: "action",
props: {
app,
title: {
type: "string",
label: "Title",
description: "Draft post title",
},
featured: {
type: "boolean",
label: "Featured",
description: "Whether the draft post is marked as featured",
optional: true,
},
categoryIds: {
type: "string[]",
label: "Category IDs",
description: "Category IDs of the draft post",
propDefinition: [
app,
"categoryId",
],
},
memberId: {
description: "Draft post owner's member ID",
propDefinition: [
app,
"memberId",
],
},
hashtags: {
type: "string[]",
label: "Hashtags",
description: "Hashtags of the draft post",
optional: true,
},
commentingEnabled: {
type: "boolean",
label: "Commenting Enabled",
description: "Whether commenting is enabled on the draft post",
optional: true,
},
tagIds: {
type: "string[]",
label: "Tag IDs",
description: "Tag IDs the draft post is tagged with",
propDefinition: [
app,
"tagId",
],
},
relatedPostIds: {
type: "string[]",
label: "Related Post IDs",
description: "IDs of posts related to this draft post",
propDefinition: [
app,
"postId",
],
},
language: {
type: "string",
label: "Language",
description: "Language the draft post is written in. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Eg. `en`",
optional: true,
},
publish: {
type: "boolean",
label: "Publish",
description: "Whether to publish the post after creation",
optional: true,
},
fieldsets: {
type: "string[]",
label: "Fieldsets",
description: "List of additional draft post fields to include in the response. For example, use the `URL` fieldset to retrieve the url field in the response in addition to the draft post's base fields. Base fields don't include any of the supported fieldset values. By default only the draft post's base fields are returned.",
optional: true,
options: [
{
label: "If the user has not set excerpt, returns the one autogenerated from content.",
value: "GENERATED_EXCERPT",
},
{
label: "Includes rich content field.",
value: "RICH_CONTENT",
},
{
label: "Includes content field.",
value: "CONTENT",
},
{
label: "Includes internal id field. Reserved for internal use.",
value: "INTERNAL_ID",
},
{
label: "Includes draft post preview URL.",
value: "URL",
},
{
label: "Unknown field.",
value: "UNKNOWN",
},
],
},
},
methods: {
createDraftPost(args = {}) {
return this.app._makeRequest({
method: "POST",
path: "/blog/v3/draft-posts",
...args,
});
},
},
async run({ $ }) {
const {
createDraftPost,
title,
featured,
categoryIds,
memberId,
hashtags,
commentingEnabled,
tagIds,
relatedPostIds,
language,
publish,
fieldsets,
} = this;

const response = await createDraftPost({
$,
data: {
draftPost: {
title,
featured,
categoryIds,
memberId,
hashtags,
commentingEnabled,
tagIds,
relatedPostIds,
language,
},
publish,
fieldsets,
},
});

$.export("$summary", `Successfully created draft post with ID \`${response.draftPost.id}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "wix_api_key-create-product",
name: "Create Product",
description: "Creates a new product. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/products/create-product)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
wix,
Expand Down
2 changes: 1 addition & 1 deletion components/wix_api_key/actions/get-contact/get-contact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "wix_api_key-get-contact",
name: "Get Contact",
description: "Retrieves information about a contact. [See the documentation](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/get-contact)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
wix,
Expand Down
4 changes: 2 additions & 2 deletions components/wix_api_key/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/wix_api_key",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream Wix Components",
"main": "wix_api_key.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
"@pipedream/platform": "^3.0.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "wix_api_key-new-member-registered",
name: "New Member Registered",
description: "Emit new event when a new member is registered. [See the documentation](https://dev.wix.com/api/rest/members/members/list-members)",
version: "0.0.1",
version: "0.0.2",
type: "source",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "wix_api_key-new-order-created",
name: "New Order Created",
description: "Emit new event when a new order is created. [See the documentation](https://dev.wix.com/api/rest/wix-stores/orders/query-orders)",
version: "0.0.1",
version: "0.0.2",
type: "source",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "wix_api_key-new-product-created",
name: "New Product Created",
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)",
version: "0.0.1",
version: "0.0.2",
type: "source",
methods: {
...common.methods,
Expand Down
125 changes: 124 additions & 1 deletion components/wix_api_key/wix_api_key.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,107 @@ export default {
})) || [];
},
},
categoryId: {
type: "string",
label: "Category ID",
description: "Category ID of the draft post",
optional: true,
async options({ page }) {
const limit = constants.DEFAULT_LIMIT;
const { categories } = await this.listCategories({
params: {
"paging.limit": limit,
"paging.offset": page * limit,
},
});
return categories?.map(({
id: value, label,
}) => ({
value,
label,
}));
},
},
memberId: {
type: "string",
label: "Member ID",
description: "The identifier of a member",
optional: true,
async options({ page }) {
const limit = constants.DEFAULT_LIMIT;
const { members } = await this.listMembers({
params: {
"paging.limit": limit,
"paging.offset": page * limit,
},
});
return members?.map(({
id: value, loginEmail: label,
}) => ({
value,
label,
}));
},
},
tagId: {
type: "string",
label: "Tag ID",
description: "Tag ID of the draft post",
optional: true,
async options({ page }) {
const limit = constants.DEFAULT_LIMIT;
const { tags } = await this.queryTags({
data: {
query: {
paging: {
limit,
offset: page * limit,
},
},
},
});
return tags?.map(({
id: value, label,
}) => ({
value,
label,
}));
},
},
postId: {
type: "string",
label: "Post ID",
description: "ID of a post",
optional: true,
useQuery: true,
async options({
page, query,
filter = {
title: {
"$contains": query,
},
},
}) {
const limit = constants.DEFAULT_LIMIT;
const { posts } = await this.queryPosts({
data: {
query: {
filter,
paging: {
limit,
offset: page * limit,
},
},
},
});
return posts?.map(({
id: value, title,
}) => ({
value,
label: title,
}));
},
},
},
methods: {
_baseUrl() {
Expand All @@ -146,7 +247,9 @@ export default {
},
async getSiteHeaders(siteId) {
if (!siteId) {
return {};
return {
"wix-account-id": this.$auth.account_id,
};
}
const accountId = await this.getSiteAccountId(siteId);
return {
Expand Down Expand Up @@ -236,6 +339,26 @@ export default {
...args,
});
},
listCategories(args = {}) {
return this._makeRequest({
path: "/blog/v3/categories",
...args,
});
},
queryTags(args = {}) {
return this._makeRequest({
method: "POST",
path: "/blog/v2/tags/query",
...args,
});
},
queryPosts(args = {}) {
return this._makeRequest({
method: "POST",
path: "/blog/v3/posts/query",
...args,
});
},
createContact(args = {}) {
return this._makeRequest({
path: "/contacts/v4/contacts",
Expand Down
Loading
Loading