Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taboola Bid Adapter: Support Dynamic Endpoint Url Param #8949

Merged
merged 20 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const spec = {
buildRequests: (validBidRequests, bidderRequest) => {
const [bidRequest] = validBidRequests;
const {refererInfo, gdprConsent = {}, uspConsent} = bidderRequest;
const {publisherId} = bidRequest.params;
const {publisherId, endpointUrl} = bidRequest.params;
const site = getSiteProperties(bidRequest.params, refererInfo);
const device = {ua: navigator.userAgent};
const imps = getImps(validBidRequests);
Expand Down Expand Up @@ -128,7 +128,7 @@ export const spec = {
regs
};

const url = [END_POINT_URL, publisherId].join('/');
const url = [endpointUrl || END_POINT_URL, publisherId].join('/');

return {
url,
Expand Down
18 changes: 10 additions & 8 deletions modules/taboolaBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ The Taboola Bidding adapter requires setup before beginning. Please contact us o
publisherId: 'tester-pub', // your-publisher-id
bidfloor: 0.25, // Optional - default is null
bcat: ['IAB1-1'], // Optional - default is []
badv: ['example.com'] // Optional - default is []
badv: ['example.com'], // Optional - default is []
endpointUrl: ['https://example.com'] // Optional
}
}]
}];
```

# Parameters

| Name | Scope | Description | Example | Type |
|----------------|----------|---------------------------------------------------------|----------------------------|--------------|
| `tagId` | required | Tag ID / Placement Name <br> | `'Below The Article'` | `String` |
| `publisherId` | required | Numeric Publisher ID <br>(as provided by Taboola) | `'1234567'` | `String` |
| `bcat` | optional | List of blocked advertiser categories (IAB) | `['IAB1-1']` | `Array` |
| `badv` | optional | Blocked Advertiser Domains | `'example.com'` | `String Url` |
| `bidfloor` | optional | CPM bid floor | `0.25` | `Float` |
| Name | Scope | Description | Example | Type |
|---------------|----------|---------------------------------------------------------|----------------------------|--------------|
| `tagId` | required | Tag ID / Placement Name <br> | `'Below The Article'` | `String` |
| `publisherId` | required | Numeric Publisher ID <br>(as provided by Taboola) | `'1234567'` | `String` |
| `bcat` | optional | List of blocked advertiser categories (IAB) | `['IAB1-1']` | `Array` |
| `badv` | optional | Blocked Advertiser Domains | `'example.com'` | `String Url` |
| `bidfloor` | optional | CPM bid floor | `0.25` | `Float` |
| `endpointUrl` | optional | Endpoint Url (only if provided by Taboola) | `https://example.com` | `String` |


77 changes: 77 additions & 0 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,45 @@ describe('Taboola Adapter', function () {
}
expect(spec.isBidRequestValid(bid)).to.equal(true)
})

it('should succeed when url is null', function () {
const bid = {
bidder: 'taboola',
params: {
publisherId: 'publisherId',
tagId: 'below the article',
endpointUrl: null
},
...displayBidRequestParams
}
expect(spec.isBidRequestValid(bid)).to.equal(true)
})

it('should succeed when url is empty string', function () {
const bid = {
bidder: 'taboola',
params: {
publisherId: 'publisherId',
tagId: 'below the article',
endpointUrl: ''
},
...displayBidRequestParams
}
expect(spec.isBidRequestValid(bid)).to.equal(true)
})

it('should succeed when url is filled', function () {
const bid = {
bidder: 'taboola',
params: {
publisherId: 'publisherId',
tagId: 'below the article',
endpointUrl: 'https://example.com'
},
...displayBidRequestParams
}
expect(spec.isBidRequestValid(bid)).to.equal(true)
})
})

describe('buildRequests', function () {
Expand Down Expand Up @@ -148,6 +187,44 @@ describe('Taboola Adapter', function () {

expect(res.url).to.equal(`${END_POINT_URL}/${commonBidRequest.params.publisherId}`);
expect(res.data).to.deep.equal(JSON.stringify(expectedData));
});

it('should fill the url when it is passed', function () {
const commonBidRequestWithUrl = {
bidder: 'taboola',
params: {
publisherId: 'publisherId',
tagId: 'placement name',
endpointUrl: 'https://example.com'
},
bidId: 'aa43860a-4644-442a-b5e0-93f268cs4d19',
auctionId: '65746dca-26f3-4186-be13-dfa63469b1b7',
}
let defaultBidRequestWithUrl = {
...commonBidRequestWithUrl,
...displayBidRequestParams,
}
const res = spec.buildRequests([defaultBidRequestWithUrl], commonBidderRequest);
expect(res.url).to.equal(`${commonBidRequestWithUrl.params.endpointUrl}/${commonBidRequest.params.publisherId}`);
})

it('should fill default url when url param is empty string', function () {
const commonBidRequestWithUrl = {
bidder: 'taboola',
params: {
publisherId: 'publisherId',
tagId: 'placement name',
endpointUrl: ''
},
bidId: 'aa43860a-4644-442a-b5e0-93f268cs4d19',
auctionId: '65746dca-26f3-4186-be13-dfa63469b1b7',
}
let defaultBidRequestWithUrl = {
...commonBidRequestWithUrl,
...displayBidRequestParams,
}
const res = spec.buildRequests([defaultBidRequestWithUrl], commonBidderRequest);
expect(res.url).to.equal(`${END_POINT_URL}/${commonBidRequestWithUrl.params.publisherId}`);
})

it('should pass optional parameters in request', function () {
Expand Down