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] bigdatacorp #14751 #15028

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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,40 @@
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 CEP 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",
],
},
lcaresia marked this conversation as resolved.
Show resolved Hide resolved
dataset: {
propDefinition: [
app,
"dataset",
],
options: constants.ADDRESS_DATASETS,
},
},

async run({ $ }) {
const response = await this.app.getAddressData({
$,
data: {
Datasets: this.dataset,
q: `zipcode{${this.doc}}`,
lcaresia marked this conversation as resolved.
Show resolved Hide resolved
lcaresia marked this conversation as resolved.
Show resolved Hide resolved
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
});

$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset`);

return response;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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",
],
},
dataset: {
propDefinition: [
app,
"dataset",
],
options: constants.COMPANY_DATASETS,
},
},

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

$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset`);

return response;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
};
40 changes: 40 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,40 @@
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",
],
},
dataset: {
propDefinition: [
app,
"dataset",
],
options: constants.PERSON_DATASETS,
},
},

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

$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset`);

return response;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
};
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, i.e.: `128.982.560-21` for CPF, `27.823.957/0001-94` CNPJ and `88048-656` for CEP",
},
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}`,
},
});
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
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,
});
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
},
},
};
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",
lcaresia marked this conversation as resolved.
Show resolved Hide resolved
},
{
"value": "biomes_data",
"label": "Biomes Data",
},
{
"value": "embargoed_areas",
"label": "Embargoed Areas",
},
{
"value": "legal_reserve",
"label": "Legal Reserve",
},
{
"value": "basic_data",
"label": "Basic Data",
},
],
};
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
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 <[email protected]> (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