forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Components - fireberry (PipedreamHQ#10011)
* fireberry init * Added actions
- Loading branch information
Showing
7 changed files
with
290 additions
and
7 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
components/fireberry/actions/create-account/create-account.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
50
components/fireberry/actions/create-article/create-article.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
components/fireberry/actions/list-accounts/list-accounts.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
36
components/fireberry/actions/list-articles/list-articles.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^1.6.0" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.