@pipedream/linkedin_ads 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/linkedin_ads.app.mjs +92 -0
- package/package.json +2 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import app from "../linkedin/linkedin.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...app,
|
|
5
|
+
type: "app",
|
|
6
|
+
app: "linkedin_ads",
|
|
7
|
+
propDefinitions: {
|
|
8
|
+
...app.propDefinitions,
|
|
9
|
+
adAccountId: {
|
|
10
|
+
type: "string",
|
|
11
|
+
label: "Ad Account Id",
|
|
12
|
+
description: "Sponsored ad account id to match results by",
|
|
13
|
+
async options({
|
|
14
|
+
page, mapper = ({
|
|
15
|
+
id: value, name: label,
|
|
16
|
+
}) => ({
|
|
17
|
+
value,
|
|
18
|
+
label,
|
|
19
|
+
}),
|
|
20
|
+
}) {
|
|
21
|
+
const limit = 10;
|
|
22
|
+
const { elements } = await this.searchAdAccounts({
|
|
23
|
+
params: {
|
|
24
|
+
count: 10,
|
|
25
|
+
start: limit * page,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return elements?.map(mapper);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
campaignId: {
|
|
32
|
+
type: "string",
|
|
33
|
+
label: "Campaign Id",
|
|
34
|
+
description: "Sponsored campaign account id to match results by",
|
|
35
|
+
async options({
|
|
36
|
+
page, adAccountId,
|
|
37
|
+
}) {
|
|
38
|
+
const count = 60;
|
|
39
|
+
const { elements } = await this.searchCampaigns({
|
|
40
|
+
adAccountId,
|
|
41
|
+
params: {
|
|
42
|
+
count,
|
|
43
|
+
start: count * page,
|
|
44
|
+
search: "(test:False)",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return elements?.map(({
|
|
48
|
+
name: label, id: value,
|
|
49
|
+
}) => ({
|
|
50
|
+
label,
|
|
51
|
+
value,
|
|
52
|
+
}));
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
accounts: {
|
|
56
|
+
type: "string[]",
|
|
57
|
+
label: "Accounts",
|
|
58
|
+
description: "An [Array of Account URN](https://docs.microsoft.com/en-us/linkedin/shared/references/v2/ads/adaccounts?context=linkedin/marketing/context). Required unless another facet is provided.",
|
|
59
|
+
optional: true,
|
|
60
|
+
async options() {
|
|
61
|
+
const {
|
|
62
|
+
searchAdAccounts,
|
|
63
|
+
getSponsoredAccountUrn,
|
|
64
|
+
} = this;
|
|
65
|
+
const { elements } = await searchAdAccounts();
|
|
66
|
+
return elements.map(({
|
|
67
|
+
id, name: label,
|
|
68
|
+
}) => ({
|
|
69
|
+
value: getSponsoredAccountUrn(id),
|
|
70
|
+
label,
|
|
71
|
+
}));
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
methods: {
|
|
76
|
+
...app.methods,
|
|
77
|
+
getSponsoredAccountUrn(id) {
|
|
78
|
+
return `urn:li:sponsoredAccount:${id}`;
|
|
79
|
+
},
|
|
80
|
+
getSponsoredCampaignUrn(id) {
|
|
81
|
+
return `urn:li:sponsoredCampaign:${id}`;
|
|
82
|
+
},
|
|
83
|
+
searchCampaigns({
|
|
84
|
+
adAccountId, ...args
|
|
85
|
+
} = {}) {
|
|
86
|
+
return this._makeRequest({
|
|
87
|
+
path: `/adAccounts/${adAccountId}/adCampaigns?q=search`,
|
|
88
|
+
...args,
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
package/package.json
CHANGED