@bprotsyk/aso-core 2.1.43 → 2.1.44
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.
|
@@ -72,17 +72,12 @@ async function createStreamForMatchingCampaigns(streamPayloads, campaignRegExp,
|
|
|
72
72
|
for (const { payload, offerId } of streamPayloads) {
|
|
73
73
|
const identicalStream = streams.find(stream => stream.name.includes(offerId));
|
|
74
74
|
if (identicalStream) {
|
|
75
|
-
await http_1.default.
|
|
76
|
-
campaign_id: matchingCampaign.id,
|
|
77
|
-
...payload
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
await http_1.default.post('streams', {
|
|
82
|
-
campaign_id: matchingCampaign.id,
|
|
83
|
-
...payload
|
|
84
|
-
});
|
|
75
|
+
await http_1.default.delete(`streams/${identicalStream.id}`);
|
|
85
76
|
}
|
|
77
|
+
await http_1.default.post('streams', {
|
|
78
|
+
campaign_id: matchingCampaign.id,
|
|
79
|
+
...payload
|
|
80
|
+
});
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
}
|
package/package.json
CHANGED
|
@@ -75,8 +75,8 @@ async function updateCampaign(id: number, payload: Partial<IKeitaroCampaign>) {
|
|
|
75
75
|
async function createStreamForMatchingCampaigns(streamPayloads: { payload: any, offerId: string }[], campaignRegExp: RegExp, avoidGroup?: number) {
|
|
76
76
|
// Get all campaigns once
|
|
77
77
|
const allCampaigns = await getAllCampaigns();
|
|
78
|
-
const matchingCampaigns = allCampaigns.filter(campaign =>
|
|
79
|
-
(avoidGroup ? campaign.group_id != avoidGroup : true) &&
|
|
78
|
+
const matchingCampaigns = allCampaigns.filter(campaign =>
|
|
79
|
+
(avoidGroup ? campaign.group_id != avoidGroup : true) &&
|
|
80
80
|
campaignRegExp.exec(campaign.name)
|
|
81
81
|
);
|
|
82
82
|
|
|
@@ -95,16 +95,13 @@ async function createStreamForMatchingCampaigns(streamPayloads: { payload: any,
|
|
|
95
95
|
const identicalStream = streams.find(stream => stream.name.includes(offerId));
|
|
96
96
|
|
|
97
97
|
if (identicalStream) {
|
|
98
|
-
await keitaroApi.
|
|
99
|
-
campaign_id: matchingCampaign.id,
|
|
100
|
-
...payload
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
await keitaroApi.post('streams', {
|
|
104
|
-
campaign_id: matchingCampaign.id,
|
|
105
|
-
...payload
|
|
106
|
-
});
|
|
98
|
+
await keitaroApi.delete(`streams/${identicalStream.id}`);
|
|
107
99
|
}
|
|
100
|
+
|
|
101
|
+
await keitaroApi.post('streams', {
|
|
102
|
+
campaign_id: matchingCampaign.id,
|
|
103
|
+
...payload
|
|
104
|
+
});
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
}
|
|
@@ -160,15 +157,15 @@ function createStreamPartialPayload(keitaroOfferId: number, offerName: string, o
|
|
|
160
157
|
|
|
161
158
|
async function addOffersToKeitaro(offers: IOffer[], affiliateId: number, links: string[], avoidGroup?: number, groupId?: number) {
|
|
162
159
|
const allOffers = await getAllOffers();
|
|
163
|
-
|
|
160
|
+
|
|
164
161
|
const streamPayloads = [];
|
|
165
|
-
|
|
162
|
+
|
|
166
163
|
for (let i = 0; i < offers.length; i++) {
|
|
167
164
|
const offer = offers[i];
|
|
168
165
|
const link = links[i];
|
|
169
|
-
|
|
166
|
+
|
|
170
167
|
const identicalOffer = allOffers.find(o => o.name.includes(offer.name));
|
|
171
|
-
|
|
168
|
+
|
|
172
169
|
let keitaroOfferId;
|
|
173
170
|
if (identicalOffer) {
|
|
174
171
|
keitaroOfferId = identicalOffer.id;
|
|
@@ -184,11 +181,11 @@ async function addOffersToKeitaro(offers: IOffer[], affiliateId: number, links:
|
|
|
184
181
|
payout_auto: true,
|
|
185
182
|
payout_upsell: true,
|
|
186
183
|
};
|
|
187
|
-
|
|
184
|
+
|
|
188
185
|
const { data: keitaroOffer } = await keitaroApi.post('offers', offerPayload);
|
|
189
186
|
keitaroOfferId = keitaroOffer.id;
|
|
190
187
|
}
|
|
191
|
-
|
|
188
|
+
|
|
192
189
|
streamPayloads.push({
|
|
193
190
|
payload: createStreamPartialPayload(
|
|
194
191
|
keitaroOfferId,
|
|
@@ -199,7 +196,7 @@ async function addOffersToKeitaro(offers: IOffer[], affiliateId: number, links:
|
|
|
199
196
|
offerId: offer.name
|
|
200
197
|
});
|
|
201
198
|
}
|
|
202
|
-
|
|
199
|
+
|
|
203
200
|
await createStreamForMatchingCampaigns(streamPayloads, /◈/, avoidGroup);
|
|
204
201
|
}
|
|
205
202
|
|
|
@@ -369,7 +366,7 @@ async function getClicks(request: IKeitaroClicksRequest | KeitaroClicksInterval)
|
|
|
369
366
|
} : {
|
|
370
367
|
...request
|
|
371
368
|
};
|
|
372
|
-
|
|
369
|
+
|
|
373
370
|
const { data } = await keitaroApi.post('/clicks/log', defaultRequest);
|
|
374
371
|
return data.rows;
|
|
375
372
|
}
|