Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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,46 @@
import app from "../../bigdatacorp.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "bigdatacorp-get-address-data",
name: "Get Address Data",
description: "Returns the available data for a Zipcode number according to the selected dataset. [See the documentation](https://docs.bigdatacorp.com.br/plataforma/reference/enderecos_legal_amazon)",
version: "0.0.1",
type: "action",
props: {
app,
doc: {
propDefinition: [
app,
"doc",
],
description: "Zipcode of the address you want to search for, i.e.: `88048-656`",
},
dataset: {
propDefinition: [
app,
"dataset",
],
options: constants.ADDRESS_DATASETS,
},
},

async run({ $ }) {
const response = await this.app.getAddressData({
$,
data: {
Datasets: this.dataset,
q: `zipcode[${this.doc}]`,
},
});

const status = response.Status[this.dataset[0].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix syntax error in status check.

There's a syntax error in the status check that's causing pipeline failures.

-    const status = response.Status[this.dataset[0].Message;
+    const status = response.Status[this.dataset[0]].Message;
     if (status === "OK") {
        $.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
     } else {
        throw new Error(status);
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const status = response.Status[this.dataset[0].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}
const status = response.Status[this.dataset[0]].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 37-37: expected ] but instead found ;

Remove ;

(parse)

🪛 GitHub Actions: Pull Request Checks

[error] 37-37: Parsing error: Unexpected token ;


return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import app from "../../bigdatacorp.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "bigdatacorp-get-company-data",
name: "Get Company Data",
description: "Returns the available data for a CNPJ number according to the selected dataset. [See the documentation](https://docs.bigdatacorp.com.br/plataforma/reference/empresas_emails_extended)",
version: "0.0.1",
type: "action",
props: {
app,
doc: {
propDefinition: [
app,
"doc",
],
description: "Document Number of the entity you want to search for, i.e.: `27.823.957/0001-94`",
},
dataset: {
propDefinition: [
app,
"dataset",
],
options: constants.COMPANY_DATASETS,
},
},

async run({ $ }) {
const response = await this.app.getCompanyData({
$,
data: {
Datasets: this.dataset,
q: `doc{${this.doc}}`,
},
});

const status = response.Status[this.dataset[0].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}

return response;
},
};
46 changes: 46 additions & 0 deletions components/bigdatacorp/actions/get-person-data/get-person-data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import app from "../../bigdatacorp.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "bigdatacorp-get-person-data",
name: "Get Person Data",
description: "Returns the available data for a CPF number according to the selected dataset. [See the documentation](https://docs.bigdatacorp.com.br/plataforma/reference/pessoas_registration_data)",
version: "0.0.1",
type: "action",
props: {
app,
doc: {
propDefinition: [
app,
"doc",
],
description: "Document Number of the entity you want to search for, i.e.: `128.982.560-21`",
},
dataset: {
propDefinition: [
app,
"dataset",
],
options: constants.PERSON_DATASETS,
},
},

async run({ $ }) {
const response = await this.app.getPersonData({
$,
data: {
Datasets: this.dataset,
q: `doc{${this.doc}}`,
},
});

const status = response.Status[this.dataset[0].Message;
if (status === "OK") {
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
} else {
throw new Error(status);
}

return response;
},
};
59 changes: 55 additions & 4 deletions components/bigdatacorp/bigdatacorp.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "bigdatacorp",
propDefinitions: {},
propDefinitions: {
doc: {
type: "string",
label: "Document Number",
description: "Document Number of the entity you want to search for",
},
dataset: {
type: "string",
label: "Dataset",
description: "The target dataset to which the query will be sent",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://plataforma.bigdatacorp.com.br";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"Accept": "application/json",
"AccessToken": `${this.$auth.access_token}`,
"TokenId": `${this.$auth.token_id}`,
},
});
},
async getPersonData(args = {}) {
return this._makeRequest({
path: "/pessoas",
method: "post",
...args,
});
},
async getCompanyData(args = {}) {
return this._makeRequest({
path: "/empresas",
method: "post",
...args,
});
},
async getAddressData(args = {}) {
return this._makeRequest({
path: "/enderecos",
method: "post",
...args,
});
},
},
};
92 changes: 92 additions & 0 deletions components/bigdatacorp/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
export default {
PERSON_DATASETS: [
{
"value": "emails_extended",
"label": "Emails",
},
{
"value": "phones_extended",
"label": "Phones",
},
{
"value": "registration_data",
"label": "Registration Data",
},
{
"value": "related_people_emails",
"label": "Related People Emails",
},
{
"value": "related_people_phones",
"label": "Related People Phones",
},
{
"value": "related_people_addresses",
"label": "Related People Addresses",
},
{
"value": "vehicles",
"label": "Vehicles",
},
],
COMPANY_DATASETS: [
{
"value": "emails_extended",
"label": "Emails",
},
{
"value": "phones_extended",
"label": "Phones",
},
{
"value": "registration_data",
"label": "Registration Data",
},
{
"value": "related_people_emails",
"label": "Related People Emails",
},
{
"value": "related_people_phones",
"label": "Related People Phones",
},
{
"value": "related_people_addresses",
"label": "Related People Addresses",
},
{
"value": "political_involvement",
"label": "Political Involvement",
},
{
"value": "online_ads",
"label": "Online Ads",
},
],
ADDRESS_DATASETS: [
{
"value": "legal_amazon",
"label": "Legal Amazon",
},
{
"value": "environmental_preservation_areas",
"label": "Enviromental Preservation Areas",
},
{
"value": "biomes_data",
"label": "Biomes Data",
},
{
"value": "embargoed_areas",
"label": "Embargoed Areas",
},
{
"value": "legal_reserve",
"label": "Legal Reserve",
},
{
"value": "basic_data",
"label": "Basic Data",
},
],
};
7 changes: 5 additions & 2 deletions components/bigdatacorp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/bigdatacorp",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream BigDataCorp Components",
"main": "bigdatacorp.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

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

Loading