Skip to content

Commit

Permalink
Admixer Bid Adaper: add admixerwl alias (#10859)
Browse files Browse the repository at this point in the history
* Update README.md

update

* Add admixerwl alias for admixerBidAdapter.

---------

Co-authored-by: Yaroslav Masenko <intgr-user@admixer.ua>
  • Loading branch information
AdmixerTech and Yaroslav Masenko authored Dec 19, 2023
1 parent 9a0f012 commit 332a7d2
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 6 deletions.
10 changes: 7 additions & 3 deletions modules/admixerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ALIASES = [
{code: 'futureads', endpoint: 'https://ads.futureads.io/prebid.1.2.aspx'},
{code: 'smn', endpoint: 'https://ads.smn.rs/prebid.1.2.aspx'},
{code: 'admixeradx', endpoint: 'https://inv-nets.admixer.net/adxprebid.1.2.aspx'},
{code: 'admixerwl', endpoint: 'https://inv-nets-adxwl.admixer.com/adxwlprebid.aspx'},
];
export const spec = {
code: BIDDER_CODE,
Expand All @@ -23,7 +24,9 @@ export const spec = {
* Determines whether or not the given bid request is valid.
*/
isBidRequestValid: function (bid) {
return !!bid.params.zone;
return bid.bidder === 'admixerwl'
? !!bid.params.clientId && !!bid.params.endpointId
: !!bid.params.zone;
},
/**
* Make a server request from the list of BidRequests.
Expand Down Expand Up @@ -76,10 +79,11 @@ export const spec = {
imp.ortb2 && delete imp.ortb2;
payload.imps.push(imp);
});

let urlForRequest = endpointUrl || getEndpointUrl(bidderRequest.bidderCode)
return {
method: 'POST',
url:
endpointUrl || getEndpointUrl(bidderRequest.bidderCode),
url: bidderRequest.bidderCode === 'admixerwl' ? `${urlForRequest}?client=${payload.imps[0]?.params?.clientId}` : urlForRequest,
data: payload,
};
},
Expand Down
45 changes: 45 additions & 0 deletions modules/admixerBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,48 @@ Please use ```admixer``` as the bidder code.
},
];
```

### AdmixerWL Test Parameters
```
var adUnits = [
{
code: 'desktop-banner-ad-div',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: "admixer",
params: {
endpointId: 41512,
clientId: 62
}
}
]
},{
code: 'mobile-banner-ad-div',
sizes: [[300, 50]], // a mobile size
bids: [
{
bidder: "admixer",
params: {
endpointId: 41512,
clientId: 62
}
}
]
},{
code: 'video-ad',
sizes: [[300, 50]],
mediaType: 'video',
bids: [
{
bidder: "admixer",
params: {
endpointId: 41512,
clientId: 62
}
}
]
},
];
```

43 changes: 40 additions & 3 deletions test/spec/modules/admixerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {newBidder} from 'src/adapters/bidderFactory.js';
import {config} from '../../../src/config.js';

const BIDDER_CODE = 'admixer';
const BIDDER_CODE_ADX = 'admixeradx';
const WL_BIDDER_CODE = 'admixerwl'
const ENDPOINT_URL = 'https://inv-nets.admixer.net/prebid.1.2.aspx';
const ENDPOINT_URL_CUSTOM = 'https://custom.admixer.net/prebid.aspx';
const ENDPOINT_URL_ADX = 'https://inv-nets.admixer.net/adxprebid.1.2.aspx';
const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2';
const CLIENT_ID = 5124;
const ENDPOINT_ID = 81264;

describe('AdmixerAdapter', function () {
const adapter = newBidder(spec);
Expand Down Expand Up @@ -36,9 +37,28 @@ describe('AdmixerAdapter', function () {
auctionId: '1d1a030790a475',
};

let wlBid = {
bidder: WL_BIDDER_CODE,
params: {
clientId: CLIENT_ID,
endpointId: ENDPOINT_ID,
},
adUnitCode: 'adunit-code',
sizes: [
[300, 250],
[300, 600],
],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
};

it('should return true when required params found', function () {
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
it('should return true when params required by WL found', function () {
expect(spec.isBidRequestValid(wlBid)).to.equal(true);
});

it('should return false when required params are not passed', function () {
let bid = Object.assign({}, bid);
Expand All @@ -48,6 +68,14 @@ describe('AdmixerAdapter', function () {
};
expect(spec.isBidRequestValid(bid)).to.equal(false);
});
it('should return false when params required by WL are not passed', function () {
let wlBid = Object.assign({}, wlBid);
delete wlBid.params;
wlBid.params = {
clientId: 0,
};
expect(spec.isBidRequestValid(wlBid)).to.equal(false);
});
});

describe('buildRequests', function () {
Expand Down Expand Up @@ -105,7 +133,10 @@ describe('AdmixerAdapter', function () {
validRequest: [
{
bidder: bidder,
params: {
params: bidder === 'admixerwl' ? {
clientId: CLIENT_ID,
endpointId: ENDPOINT_ID
} : {
zone: ZONE_ID,
},
adUnitCode: 'adunit-code',
Expand Down Expand Up @@ -168,6 +199,12 @@ describe('AdmixerAdapter', function () {
expect(request.url).to.equal('https://inv-nets.admixer.net/adxprebid.1.2.aspx');
expect(request.method).to.equal('POST');
});
it('build request for admixerwl', function () {
const requestParams = requestParamsFor('admixerwl');
const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest);
expect(request.url).to.equal(`https://inv-nets-adxwl.admixer.com/adxwlprebid.aspx?client=${CLIENT_ID}`);
expect(request.method).to.equal('POST');
});
});

describe('checkFloorGetting', function () {
Expand Down

0 comments on commit 332a7d2

Please sign in to comment.