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

Update Yieldlab adapter and add official maintainer #2231

Merged
merged 9 commits into from
Mar 19, 2018
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
22 changes: 11 additions & 11 deletions modules/yieldlabBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { VIDEO, BANNER } from 'src/mediaTypes'

const ENDPOINT = 'https://ad.yieldlab.net'
const BIDDER_CODE = 'yieldlab'
const BID_RESPONSE_TTL_SEC = 600
const BID_RESPONSE_TTL_SEC = 300
const CURRENCY_CODE = 'EUR'

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [VIDEO, BANNER],

isBidRequestValid: function (bid) {
if (bid && bid.params && bid.params.placementId && bid.params.adSize) {
if (bid && bid.params && bid.params.adslotId && bid.params.adSize) {
return true
}
return false
Expand All @@ -25,18 +25,18 @@ export const spec = {
* @returns {{method: string, url: string}}
*/
buildRequests: function (validBidRequests) {
const placementIds = []
const adslotIds = []
const timestamp = Date.now()

utils._each(validBidRequests, function (bid) {
placementIds.push(bid.params.placementId)
adslotIds.push(bid.params.adslotId)
})

const placements = placementIds.join(',')
const adslots = adslotIds.join(',')

return {
method: 'GET',
url: `${ENDPOINT}/yp/${placements}?ts=${timestamp}&json=true`,
url: `${ENDPOINT}/yp/${adslots}?ts=${timestamp}&json=true`,
validBidRequests: validBidRequests
}
},
Expand All @@ -56,7 +56,7 @@ export const spec = {
}

let matchedBid = find(serverResponse.body, function (bidResponse) {
return bidRequest.params.placementId == bidResponse.id
return bidRequest.params.adslotId == bidResponse.id
})

if (matchedBid) {
Expand All @@ -67,16 +67,16 @@ export const spec = {
width: sizes[0],
height: sizes[1],
creativeId: '' + matchedBid.id,
dealId: matchedBid.did,
dealId: matchedBid.pid,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to add a test that verifies pid is being mapped to dealId as you expect. Would also help verify that this was an intended change!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment. I agree and added a commit: 4010d70

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thx. will get this merged.

currency: CURRENCY_CODE,
netRevenue: true,
netRevenue: false,
ttl: BID_RESPONSE_TTL_SEC,
referrer: '',
ad: `<script src="${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.accountId}/${sizes[0]}x${sizes[1]}?ts=${timestamp}"></script>`
ad: `<script src="${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${sizes[0]}x${sizes[1]}?ts=${timestamp}"></script>`
}
if (isVideo(bidRequest)) {
bidResponse.mediaType = VIDEO
bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.accountId}/1x1?ts=${timestamp}`
bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/${sizes[0]}x${sizes[1]}?ts=${timestamp}`
}

bidResponses.push(bidResponse)
Expand Down
22 changes: 11 additions & 11 deletions modules/yieldlabBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```
Module Name: Yieldlab Bidder Adapter
Module Type: Bidder Adapter
Maintainer: api@platform-lunar.com
Maintainer: solutions@yieldlab.de
```

# Description
Expand All @@ -14,19 +14,19 @@ Module that connects to Yieldlab's demand sources
```
var adUnits = [
{
code: "test1",
sizes: [[800, 250]]
code: "banner",
sizes: [[728, 90]],
bids: [{
bidder: "yieldlab",
params: {
placement: "4206978",
accountId: "2358365",
adSize: "800x250"
adslotId: "5220336",
supplyId: "1381604",
adSize: "728x90"
}
}]
}, {
code: "test2",
sizes: [[1, 1]],
code: "video",
sizes: [[640, 480]],
mediaTypes: {
video: {
context: "instream"
Expand All @@ -35,9 +35,9 @@ Module that connects to Yieldlab's demand sources
bids: [{
bidder: "yieldlab",
params: {
placementId: "4207034",
accountId: "2358365",
adSize: "1x1"
adslotId: "5220339",
supplyId: "1381604",
adSize: "640x480"
}
}]
}
Expand Down
31 changes: 16 additions & 15 deletions test/spec/modules/yieldlabBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ import { newBidder } from 'src/adapters/bidderFactory'
const REQUEST = {
'bidder': 'yieldlab',
'params': {
'placementId': '1111',
'accountId': '2222',
'adSize': '800x250'
'adslotId': '1111',
'supplyId': '2222',
'adSize': '728x90'
},
'bidderRequestId': '143346cf0f1731',
'auctionId': '2e41f65424c87c',
'adUnitCode': 'adunit-code',
'bidId': '2d925f27f5079f',
'sizes': [1, 1]
'sizes': [728, 90]
}

const RESPONSE = {
advertiser: 'yieldlab',
curl: 'https://www.yieldlab.de',
format: 0,
id: 1111,
price: 1
price: 1,
pid: 2222
}

describe('yieldlabBidAdapter', () => {
Expand All @@ -37,9 +38,9 @@ describe('yieldlabBidAdapter', () => {
it('should return true when required params found', () => {
const request = {
'params': {
'placementId': '1111',
'accountId': '2222',
'adSize': '800x250'
'adslotId': '1111',
'supplyId': '2222',
'adSize': '728x90'
}
}
expect(spec.isBidRequestValid(request)).to.equal(true)
Expand Down Expand Up @@ -78,15 +79,15 @@ describe('yieldlabBidAdapter', () => {

expect(result[0].requestId).to.equal('2d925f27f5079f')
expect(result[0].cpm).to.equal(0.01)
expect(result[0].width).to.equal(800)
expect(result[0].height).to.equal(250)
expect(result[0].width).to.equal(728)
expect(result[0].height).to.equal(90)
expect(result[0].creativeId).to.equal('1111')
expect(result[0].dealId).to.equal(undefined)
expect(result[0].dealId).to.equal(2222)
expect(result[0].currency).to.equal('EUR')
expect(result[0].netRevenue).to.equal(true)
expect(result[0].ttl).to.equal(600)
expect(result[0].netRevenue).to.equal(false)
expect(result[0].ttl).to.equal(300)
expect(result[0].referrer).to.equal('')
expect(result[0].ad).to.include('<script src="https://ad.yieldlab.net/d/1111/2222/800x250?ts=')
expect(result[0].ad).to.include('<script src="https://ad.yieldlab.net/d/1111/2222/728x90?ts=')
})

it('should add vastUrl when type is video', () => {
Expand All @@ -105,7 +106,7 @@ describe('yieldlabBidAdapter', () => {
expect(result[0].requestId).to.equal('2d925f27f5079f')
expect(result[0].cpm).to.equal(0.01)
expect(result[0].mediaType).to.equal('video')
expect(result[0].vastUrl).to.include('https://ad.yieldlab.net/d/1111/2222/1x1?ts=')
expect(result[0].vastUrl).to.include('https://ad.yieldlab.net/d/1111/2222/728x90?ts=')
})
})
})