Skip to content

Commit

Permalink
Update cwire adapter for new inventory management (#12066)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMilica authored Jul 31, 2024
1 parent 2f43ed6 commit 62e6d89
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
22 changes: 13 additions & 9 deletions modules/cwireBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,18 @@ export const spec = {
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
if (!bid.params?.placementId || !isNumber(bid.params.placementId)) {
logError('placementId not provided or not a number');
return false;
}
if (!bid.params?.domainId || !isNumber(bid.params.domainId)) {
logError('domainId not provided or not a number');
if (!bid.params?.placementId || !isNumber(bid.params.placementId)) {
logError('placementId not provided or not a number');
return false;
}

if (!bid.params?.pageId || !isNumber(bid.params.pageId)) {
logError('pageId not provided or not a number');
return false;
if (!bid.params?.pageId || !isNumber(bid.params.pageId)) {
logError('pageId not provided or not a number');
return false;
}
return true;
}
return true;
},
Expand All @@ -176,8 +180,8 @@ export const spec = {
// process bid requests
let processed = validBidRequests
.map(bid => slotDimensions(bid))
// Flattens the pageId and placement Id for backwards compatibility.
.map((bid) => ({...bid, pageId: bid.params?.pageId, placementId: bid.params?.placementId}));
// Flattens the pageId, domainId and placement Id for backwards compatibility.
.map((bid) => ({...bid, pageId: bid.params?.pageId, domainId: bid.params?.domainId, placementId: bid.params?.placementId}));

const extensions = getCwExtension();
const payload = {
Expand Down
39 changes: 29 additions & 10 deletions modules/cwireBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ Prebid.js Adapter for C-Wire.

Below, the list of C-WIRE params and where they can be set.

| Param name | URL parameter | AdUnit config | Type | Required |
|-------------|:-------------:|:-------------:|:--------:|:-------------:|
| pageId | | x | number | YES |
| placementId | | x | number | YES |
| cwgroups | x | | string | NO |
| cwcreative | x | | string | NO |
| cwdebug | x | | boolean | NO |
| cwfeatures | x | | string | NO |
| Param name | URL parameter | AdUnit config | Type | Required |
|-------------|:-------------:|:-------------:|:--------:|:--------:|
| pageId | | x | number | NO |
| domainId | | x | number | YES |
| placementId | | x | number | NO |
| cwgroups | x | | string | NO |
| cwcreative | x | | string | NO |
| cwdebug | x | | boolean | NO |
| cwfeatures | x | | string | NO |


### adUnit configuration
Expand All @@ -38,12 +39,30 @@ var adUnits = [
}
},
params: {
pageId: 1422, // required - number
placementId: 2211521, // required - number
domainId: 1422, // required - number
placementId: 2211521, // optional - number
}
}]
}
];
// old version for the compatibility
var adUnits = [
{
code: 'target_div_id', // REQUIRED
bids: [{
bidder: 'cwire',
mediaTypes: {
banner: {
sizes: [[400, 600]],
}
},
params: {
pageId: 1422, // required - number
placementId: 2211521, // required - number
}
}]
}
];
```

### URL parameters
Expand Down

0 comments on commit 62e6d89

Please sign in to comment.