Skip to content
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

[Components] agility_cms #13864 #13957

Merged
merged 2 commits into from
Sep 23, 2024
Merged
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
@@ -0,0 +1,28 @@
import app from "../../agility_cms.app.mjs";

export default {
key: "agility_cms-get-content-items",
name: "Get Content Items",
description: "Retrieves all content items. [See the documentation](https://api.aglty.io/swagger/index.html#operations-Sync-get__guid___apitype___locale__sync_items)",
version: "0.0.1",
type: "action",
props: {
app,
locale: {
propDefinition: [
app,
"locale",
],
},
},
async run({ $ }) {
const response = await this.app.getItems({
$,
locale: this.locale,
});

$.export("$summary", `Successfully retrieved ${response.items.length} Items`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import app from "../../agility_cms.app.mjs";

export default {
key: "agility_cms-get-content-models",
name: "Get Content Models",
description: "Retrieve content models for the Agility instance. [See the documentation](https://api.aglty.io/swagger/index.html#operations-ContentModels-get__guid___apitype__contentmodels)",
version: "0.0.1",
type: "action",
props: {
app,
},
async run({ $ }) {
const response = await this.app.getContentModels({
$,
});

$.export("$summary", `Successfully retrieved ${Object.keys(response).length} content models`);

return response;
},
};
38 changes: 38 additions & 0 deletions components/agility_cms/actions/get-item/get-item.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../agility_cms.app.mjs";

export default {
key: "agility_cms-get-item",
name: "Get Item Details",
description: "Get details of the specified item. [See the documentation](https://api.aglty.io/swagger/index.html#operations-Item-get__guid___apitype___locale__item__id_)",
version: "0.0.1",
type: "action",
props: {
app,
locale: {
propDefinition: [
app,
"locale",
],
},
itemId: {
propDefinition: [
app,
"itemId",
(c) => ({
locale: c.locale,
}),
],
},
},
async run({ $ }) {
const response = await this.app.getItem({
$,
locale: this.locale,
itemId: this.itemId,
});

$.export("$summary", `Successfully retrieved details of item ID '${response.contentID}'`);

return response;
},
};
75 changes: 70 additions & 5 deletions components/agility_cms/agility_cms.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,76 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "agility_cms",
propDefinitions: {},
propDefinitions: {
locale: {
type: "string",
label: "Locale",
description: "The locale code you want to retrieve content for (it must already be in `Locales Settings` of your Agility account)",
options: constants.LOCALE_OPTIONS,
default: "en-us",
},
itemId: {
type: "string",
label: "Item ID",
description: "ID of the item to get details of",
async options({ locale }) {
const response = await this.getItems({
locale,
});
const itemsIds = response.items;
return itemsIds.map(({
contentID, properties,
}) => ({
value: contentID,
label: properties.referenceName,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `${this.$auth.api_url}/${this.$auth.guid}/${this.$auth.api_type}`;
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"APIKey": `${this.$auth.api_key}`,
},
});
},
async getContentModels(args = {}) {
return this._makeRequest({
path: "/contentmodels",
...args,
});
},
async getItems({
locale, ...args
}) {
return this._makeRequest({
path: `/${locale}/sync/items`,
...args,
});
},
async getItem({
locale, itemId, ...args
}) {
return this._makeRequest({
path: `/${locale}/item/${itemId}`,
...args,
});
},
},
};
};
Loading
Loading