forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
axisBidAdapter.js
79 lines (64 loc) · 2.57 KB
/
axisBidAdapter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { deepAccess } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import {
isBidRequestValid,
buildRequestsBase,
interpretResponse,
buildPlacementProcessingFunction,
} from '../libraries/teqblazeUtils/bidderUtils.js';
const BIDDER_CODE = 'axis';
const AD_URL = 'https://prebid.axis-marketplace.com/pbjs';
const SYNC_URL = 'https://cs.axis-marketplace.com';
const addPlacementType = (bid, bidderRequest, placement) => {
placement.integration = bid.params.integration;
placement.token = bid.params.token;
};
const addCustomFieldsToPlacement = (bid, bidderRequest, placement) => {
const { mediaTypes } = bid;
if (placement.adFormat === BANNER) {
placement.pos = mediaTypes[BANNER].pos;
} else if (placement.adFormat === VIDEO) {
placement.pos = mediaTypes[VIDEO].pos;
placement.context = mediaTypes[VIDEO].context;
}
};
const placementProcessingFunction = buildPlacementProcessingFunction({ addPlacementType, addCustomFieldsToPlacement });
const buildRequests = (validBidRequests = [], bidderRequest = {}) => {
const request = buildRequestsBase({ adUrl: AD_URL, validBidRequests, bidderRequest, placementProcessingFunction });
request.data.iabCat = deepAccess(bidderRequest, 'ortb2.site.cat');
return request;
};
export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
isBidRequestValid: isBidRequestValid(['integration', 'token'], 'every'),
buildRequests,
interpretResponse,
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) => {
let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image';
let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`;
if (gdprConsent && gdprConsent.consentString) {
if (typeof gdprConsent.gdprApplies === 'boolean') {
syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`;
}
}
if (uspConsent && uspConsent.consentString) {
syncUrl += `&ccpa=${uspConsent.consentString}`;
}
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
syncUrl += '&gpp=' + gppConsent.gppString;
syncUrl += '&gpp_sid=' + gppConsent.applicableSections.join(',');
}
const coppa = config.getConfig('coppa') ? 1 : 0;
syncUrl += `&coppa=${coppa}`;
return [{
type: syncType,
url: syncUrl
}];
}
}
registerBidder(spec);