Skip to content

Commit

Permalink
New Components - fireberry (PipedreamHQ#10011)
Browse files Browse the repository at this point in the history
* fireberry init

* Added actions
  • Loading branch information
lcaresia authored Jan 26, 2024
1 parent 470c5ce commit 1060385
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 7 deletions.
57 changes: 57 additions & 0 deletions components/fireberry/actions/create-account/create-account.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import app from "../../fireberry.app.mjs";

export default {
key: "fireberry-create-account",
name: "Create Account",
description: "Creates a new account in Fireberry. [See the documentation](https://developers.fireberry.com/reference/create-an-account)",
version: "0.0.1",
type: "action",
props: {
app,
accountName: {
propDefinition: [
app,
"accountName",
],
},
emailAddress1: {
propDefinition: [
app,
"emailAddress1",
],
},
firstName: {
propDefinition: [
app,
"firstName",
],
},
lastName: {
propDefinition: [
app,
"lastName",
],
},
websiteUrl: {
propDefinition: [
app,
"websiteUrl",
],
},
},
async run({ $ }) {
const response = await this.app.createAccount({
$,
data: {
accountname: this.accountName,
emailaddress1: this.emailAddress1,
firstname: this.firstName,
lastname: this.lastName,
websiteurl: this.websiteUrl,
},
});

$.export("$summary", `Created account with name: ${this.accountName}`);
return response;
},
};
50 changes: 50 additions & 0 deletions components/fireberry/actions/create-article/create-article.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../fireberry.app.mjs";

export default {
key: "fireberry-create-article",
name: "Create an Article",
description: "Creates a new article in Fireberry. [See the documentation](https://developers.fireberry.com/reference/create-an-article)",
version: "0.0.1",
type: "action",
props: {
app,
articleName: {
propDefinition: [
app,
"articleName",
],
},
articleSubject: {
propDefinition: [
app,
"articleSubject",
],
},
articleBody: {
propDefinition: [
app,
"articleBody",
],
},
description: {
propDefinition: [
app,
"description",
],
},
},
async run({ $ }) {
const response = await this.app.createArticle({
$,
data: {
articlename: this.articleName,
articlesubject: this.articleSubject,
articlebody: this.articleBody,
description: this.description,
},
});

$.export("$summary", `Successfully created the article '${this.articleName}'`);
return response;
},
};
36 changes: 36 additions & 0 deletions components/fireberry/actions/list-accounts/list-accounts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import app from "../../fireberry.app.mjs";

export default {
key: "fireberry-list-accounts",
name: "List Accounts",
description: "List all accounts in Fireberry. [See the documentation](https://developers.fireberry.com/reference/get-all-accounts)",
version: "0.0.1",
type: "action",
props: {
app,
},
async run({ $ }) {
let hasNextPage = true;
let page = 0;
let allResources = [];

while (hasNextPage) {
const { data: { Records: resources } } = await this.app.getAllAccounts({
$,
data: {
pageNumber: page,
},
});

hasNextPage = resources.length > 0;

allResources = allResources.concat(resources);

page++;
}

$.export("$summary", `Successfully retrieved the list of ${allResources.length} projects`);

return allResources;
},
};
36 changes: 36 additions & 0 deletions components/fireberry/actions/list-articles/list-articles.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import app from "../../fireberry.app.mjs";

export default {
key: "fireberry-list-articles",
name: "List Articles",
description: "List all articles from Fireberry. [See the documentation](https://developers.fireberry.com/reference/get-all-articles)",
version: "0.0.1",
type: "action",
props: {
app,
},
async run({ $ }) {
let hasNextPage = true;
let page = 0;
let allResources = [];

while (hasNextPage) {
const { data: { Records: resources } } = await this.app.getAllArticles({
$,
data: {
page,
},
});

hasNextPage = resources.length > 0;

allResources = allResources.concat(resources);

page++;
}

$.export("$summary", `Successfully retrieved the list of ${allResources.length} projects`);

return allResources;
},
};
106 changes: 102 additions & 4 deletions components/fireberry/fireberry.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,109 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "fireberry",
propDefinitions: {},
propDefinitions: {
accountName: {
type: "string",
label: "Account Name",
description: "Name of the account",
},
emailAddress1: {
type: "string",
label: "Email Address",
description: "Email address",
optional: true,
},
firstName: {
type: "string",
label: "First Name",
description: "First name",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "Last name",
optional: true,
},
websiteUrl: {
type: "string",
label: "Website URL",
description: "URL of the website",
optional: true,
},
articleName: {
type: "string",
label: "Article Name",
description: "Name of the article",
},
articleSubject: {
type: "string", //O type na verdade é 'int32' segundo as refs, mas a descrição é 'Short text subject of the article.', então imagino que seja um erro deles
label: "Article Subject",
description: "Subject of the article",
},
articleBody: {
type: "string",
label: "Article Body",
description: "Body of the article",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "Article description",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.fireberry.com/api";
},
async _makeRequest(opts = {}) {
const {
$ = this,
method = "GET",
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
method,
url: this._baseUrl() + path,
headers: {
...headers,
"Content-Type": "application/json",
"tokenid": `${this.$auth.api_access_token}`,
},
});
},
async createArticle(args = {}) {
return this._makeRequest({
method: "POST",
path: "/record/article",
...args,
});
},
async getAllArticles(args = {}) {
return this._makeRequest({
path: "/record/article",
...args,
});
},
async createAccount(args = {}) {
return this._makeRequest({
method: "POST",
path: "/record/account",
...args,
});
},
async getAllAccounts(args = {}) {
return this._makeRequest({
path: "/record/account",
...args,
});
},
},
};
7 changes: 5 additions & 2 deletions components/fireberry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/fireberry",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Fireberry Components",
"main": "fireberry.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.0"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1060385

Please sign in to comment.