Skip to content

Commit

Permalink
Ras Bid Adapter: support for SlotSequence parameter (prebid#8792)
Browse files Browse the repository at this point in the history
* add rasbidadapter pos param

* Read pos off the adunit

* rename conflicting pos parameter for clarity
  • Loading branch information
wsusrasp authored and JacobKlein26 committed Feb 8, 2023
1 parent 65bce97 commit ba3a84e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
8 changes: 8 additions & 0 deletions modules/rasBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { isEmpty, getAdUnitSizes, parseSizesInput, deepAccess } from '../src/utils.js';
Expand Down Expand Up @@ -92,11 +93,18 @@ const getSlots = (bidRequests) => {
const batchSize = bidRequests.length;
for (let i = 0; i < batchSize; i++) {
const adunit = bidRequests[i];
const slotSequence = utils.deepAccess(adunit, 'params.slotSequence');

const sizes = parseSizesInput(getAdUnitSizes(adunit)).join(',');

queryString += `&slot${i}=${encodeURIComponent(adunit.params.slot)}&id${i}=${encodeURIComponent(adunit.bidId)}&composition${i}=CHILD`;

if (sizes.length) {
queryString += `&iusizes${i}=${encodeURIComponent(sizes)}`;
}
if (slotSequence !== undefined) {
queryString += `&pos${i}=${encodeURIComponent(slotSequence)}`;
}
}
return queryString;
};
Expand Down
27 changes: 14 additions & 13 deletions modules/rasBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ var adUnits = [{

# Parameters

| Name | Scope | Type | Description | Example
| --- | --- | --- | --- | ---
| network | required | String | Specific identifier provided by RAS | `"4178463"`
| site | required | String | Specific identifier name (case-insensitive) that is associated with this ad unit and provided by RAS | `"example_com"`
| area | required | String | Ad unit category name; only case-insensitive alphanumeric with underscores and hyphens are allowed | `"sport"`
| slot | required | String | Ad unit placement name (case-insensitive) provided by RAS | `"slot"`
| pageContext | optional | Object | Web page context data | `{}`
| pageContext.dr | optional | String | Document referrer URL address | `"https://example.com/"`
| pageContext.du | optional | String | Document URL address | `"https://example.com/sport/football/article.html?id=932016a5-02fc-4d5c-b643-fafc2f270f06"`
| Name | Scope | Type | Description | Example
| --- | --- | --- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ---
| network | required | String | Specific identifier provided by RAS | `"4178463"`
| site | required | String | Specific identifier name (case-insensitive) that is associated with this ad unit and provided by RAS | `"example_com"`
| area | required | String | Ad unit category name; only case-insensitive alphanumeric with underscores and hyphens are allowed | `"sport"`
| slot | required | String | Ad unit placement name (case-insensitive) provided by RAS | `"slot"`
| slotSequence | optional | Number | Ad unit sequence position provided by RAS | `1`
| pageContext | optional | Object | Web page context data | `{}`
| pageContext.dr | optional | String | Document referrer URL address | `"https://example.com/"`
| pageContext.du | optional | String | Document URL address | `"https://example.com/sport/football/article.html?id=932016a5-02fc-4d5c-b643-fafc2f270f06"`
| pageContext.dv | optional | String | Document virtual address as slash-separated path that may consist of any number of parts (case-insensitive alphanumeric with underscores and hyphens); first part should be the same as `site` value and second as `area` value; next parts may reflect website navigation | `"example_com/sport/football"`
| pageContext.keyWords | optional | String[] | List of keywords associated with this ad unit; only case-insensitive alphanumeric with underscores and hyphens are allowed | `["euro", "lewandowski"]`
| pageContext.keyValues | optional | Object | Key-values associated with this ad unit (case-insensitive); following characters are not allowed in the values: `" ' = ! + # * ~ ; ^ ( ) < > [ ] & @` | `{}`
| pageContext.keyValues.ci | optional | String | Content unique identifier | `"932016a5-02fc-4d5c-b643-fafc2f270f06"`
| pageContext.keyValues.adunit | optional | String | Ad unit name | `"example_com/sport"`
| pageContext.keyWords | optional | String[] | List of keywords associated with this ad unit; only case-insensitive alphanumeric with underscores and hyphens are allowed | `["euro", "lewandowski"]`
| pageContext.keyValues | optional | Object | Key-values associated with this ad unit (case-insensitive); following characters are not allowed in the values: `" ' = ! + # * ~ ; ^ ( ) < > [ ] & @` | `{}`
| pageContext.keyValues.ci | optional | String | Content unique identifier | `"932016a5-02fc-4d5c-b643-fafc2f270f06"`
| pageContext.keyValues.adunit | optional | String | Ad unit name | `"example_com/sport"`
2 changes: 2 additions & 0 deletions test/spec/modules/rasBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('rasBidAdapter', function () {
slot: 'test',
area: 'areatest',
site: 'test',
slotSequence: '0',
network: '4178463'
}
};
Expand Down Expand Up @@ -140,6 +141,7 @@ describe('rasBidAdapter', function () {
expect(requests[0].url).to.have.string('DV=test%2Fareatest');
expect(requests[0].url).to.have.string('kwrd=val1%2Bval2');
expect(requests[0].url).to.have.string('kvadunit=test%2Fareatest');
expect(requests[0].url).to.have.string('pos0=0');
});
});

Expand Down

0 comments on commit ba3a84e

Please sign in to comment.