Skip to content

Commit a290593

Browse files
Merging pull request #15028
* Added requested changes * Added requested changes * Added requested changes * Update components/bigdatacorp/common/constants.mjs Co-authored-by: michelle0927 <[email protected]> * Update components/bigdatacorp/actions/get-address-data/get-address-data.mjs Co-authored-by: michelle0927 <[email protected]> * Update components/bigdatacorp/actions/get-address-data/get-address-data.mjs Co-authored-by: michelle0927 <[email protected]> * Done requests changes * Done requests changes * Done requests changes * Update components/bigdatacorp/actions/get-address-data/get-address-data.mjs Co-authored-by: michelle0927 <[email protected]> * Update components/bigdatacorp/actions/get-address-data/get-address-data.mjs Co-authored-by: michelle0927 <[email protected]> * Update components/bigdatacorp/actions/get-person-data/get-person-data.mjs Co-authored-by: michelle0927 <[email protected]> * Update components/bigdatacorp/actions/get-company-data/get-company-data.mjs Co-authored-by: michelle0927 <[email protected]> * Done requests changes * updates * pnpm-lock.yaml --------- Co-authored-by: michelle0927 <[email protected]> Co-authored-by: michelle0927 <[email protected]>
1 parent e549fad commit a290593

File tree

7 files changed

+298
-7
lines changed

7 files changed

+298
-7
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import app from "../../bigdatacorp.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "bigdatacorp-get-address-data",
6+
name: "Get Address Data",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
doc: {
13+
propDefinition: [
14+
app,
15+
"doc",
16+
],
17+
description: "Zipcode of the address you want to search for, i.e.: `88048-656`",
18+
},
19+
dataset: {
20+
propDefinition: [
21+
app,
22+
"dataset",
23+
],
24+
options: constants.ADDRESS_DATASETS,
25+
},
26+
},
27+
28+
async run({ $ }) {
29+
const response = await this.app.getAddressData({
30+
$,
31+
data: {
32+
Datasets: this.dataset,
33+
q: `zipcode[${this.doc}]`,
34+
},
35+
});
36+
37+
const status = response.Status[this.dataset][0].Message;
38+
39+
if (status === "OK") {
40+
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
41+
} else {
42+
throw new Error(status);
43+
}
44+
45+
return response;
46+
},
47+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import app from "../../bigdatacorp.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "bigdatacorp-get-company-data",
6+
name: "Get Company Data",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
doc: {
13+
propDefinition: [
14+
app,
15+
"doc",
16+
],
17+
description: "Document Number of the entity you want to search for, i.e.: `27.823.957/0001-94`",
18+
},
19+
dataset: {
20+
propDefinition: [
21+
app,
22+
"dataset",
23+
],
24+
options: constants.COMPANY_DATASETS,
25+
},
26+
},
27+
28+
async run({ $ }) {
29+
const response = await this.app.getCompanyData({
30+
$,
31+
data: {
32+
Datasets: this.dataset,
33+
q: `doc{${this.doc}}`,
34+
},
35+
});
36+
37+
const status = response.Status[this.dataset][0].Message;
38+
39+
if (status === "OK") {
40+
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
41+
} else {
42+
throw new Error(status);
43+
}
44+
45+
return response;
46+
},
47+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import app from "../../bigdatacorp.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "bigdatacorp-get-person-data",
6+
name: "Get Person Data",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
doc: {
13+
propDefinition: [
14+
app,
15+
"doc",
16+
],
17+
description: "Document Number of the entity you want to search for, i.e.: `128.982.560-21`",
18+
},
19+
dataset: {
20+
propDefinition: [
21+
app,
22+
"dataset",
23+
],
24+
options: constants.PERSON_DATASETS,
25+
},
26+
},
27+
28+
async run({ $ }) {
29+
const response = await this.app.getPersonData({
30+
$,
31+
data: {
32+
Datasets: this.dataset,
33+
q: `doc{${this.doc}}`,
34+
},
35+
});
36+
37+
const status = response.Status[this.dataset][0].Message;
38+
39+
if (status === "OK") {
40+
$.export("$summary", `Successfully sent the request for the '${this.dataset}' dataset. Status: ${status}`);
41+
} else {
42+
throw new Error(status);
43+
}
44+
45+
return response;
46+
},
47+
};
Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,62 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "bigdatacorp",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
doc: {
8+
type: "string",
9+
label: "Document Number",
10+
description: "Document Number of the entity you want to search for",
11+
},
12+
dataset: {
13+
type: "string",
14+
label: "Dataset",
15+
description: "The target dataset to which the query will be sent",
16+
},
17+
},
518
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
19+
_baseUrl() {
20+
return "https://plataforma.bigdatacorp.com.br";
21+
},
22+
async _makeRequest(opts = {}) {
23+
const {
24+
$ = this,
25+
path,
26+
headers,
27+
...otherOpts
28+
} = opts;
29+
return axios($, {
30+
...otherOpts,
31+
url: this._baseUrl() + path,
32+
headers: {
33+
...headers,
34+
"Accept": "application/json",
35+
"AccessToken": `${this.$auth.access_token}`,
36+
"TokenId": `${this.$auth.token_id}`,
37+
},
38+
});
39+
},
40+
async getPersonData(args = {}) {
41+
return this._makeRequest({
42+
path: "/pessoas",
43+
method: "post",
44+
...args,
45+
});
46+
},
47+
async getCompanyData(args = {}) {
48+
return this._makeRequest({
49+
path: "/empresas",
50+
method: "post",
51+
...args,
52+
});
53+
},
54+
async getAddressData(args = {}) {
55+
return this._makeRequest({
56+
path: "/enderecos",
57+
method: "post",
58+
...args,
59+
});
960
},
1061
},
1162
};
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
export default {
2+
PERSON_DATASETS: [
3+
{
4+
"value": "emails_extended",
5+
"label": "Emails",
6+
},
7+
{
8+
"value": "phones_extended",
9+
"label": "Phones",
10+
},
11+
{
12+
"value": "registration_data",
13+
"label": "Registration Data",
14+
},
15+
{
16+
"value": "related_people_emails",
17+
"label": "Related People Emails",
18+
},
19+
{
20+
"value": "related_people_phones",
21+
"label": "Related People Phones",
22+
},
23+
{
24+
"value": "related_people_addresses",
25+
"label": "Related People Addresses",
26+
},
27+
{
28+
"value": "vehicles",
29+
"label": "Vehicles",
30+
},
31+
],
32+
COMPANY_DATASETS: [
33+
{
34+
"value": "emails_extended",
35+
"label": "Emails",
36+
},
37+
{
38+
"value": "phones_extended",
39+
"label": "Phones",
40+
},
41+
{
42+
"value": "registration_data",
43+
"label": "Registration Data",
44+
},
45+
{
46+
"value": "related_people_emails",
47+
"label": "Related People Emails",
48+
},
49+
{
50+
"value": "related_people_phones",
51+
"label": "Related People Phones",
52+
},
53+
{
54+
"value": "related_people_addresses",
55+
"label": "Related People Addresses",
56+
},
57+
{
58+
"value": "political_involvement",
59+
"label": "Political Involvement",
60+
},
61+
{
62+
"value": "online_ads",
63+
"label": "Online Ads",
64+
},
65+
],
66+
ADDRESS_DATASETS: [
67+
{
68+
"value": "legal_amazon",
69+
"label": "Legal Amazon",
70+
},
71+
{
72+
"value": "environmental_preservation_areas",
73+
"label": "Enviromental Preservation Areas",
74+
},
75+
{
76+
"value": "biomes_data",
77+
"label": "Biomes Data",
78+
},
79+
{
80+
"value": "embargoed_areas",
81+
"label": "Embargoed Areas",
82+
},
83+
{
84+
"value": "legal_reserve",
85+
"label": "Legal Reserve",
86+
},
87+
{
88+
"value": "basic_data",
89+
"label": "Basic Data",
90+
},
91+
],
92+
};

components/bigdatacorp/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/bigdatacorp",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream BigDataCorp Components",
55
"main": "bigdatacorp.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)