diff --git a/modules/retailspotBidAdapter.js b/modules/retailspotBidAdapter.js index 557dd617274..da8e46bec81 100644 --- a/modules/retailspotBidAdapter.js +++ b/modules/retailspotBidAdapter.js @@ -5,17 +5,21 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest * @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid + * @typedef {import('../src/adapters/bidderFactory.js').BidderRequest} BidderRequest */ const BIDDER_CODE = 'retailspot'; -const DEFAULT_SUBDOMAIN = 'ssp'; -const PREPROD_SUBDOMAIN = 'ssp-preprod'; -const HOST = 'retail-spot.io'; -const ENDPOINT = '/prebid'; -const DEV_URL = 'http://localhost:8090/prebid'; +const GVL_ID = 1319; + +const DEFAULT_SUBDOMAIN = 'hbapi'; +const PREPROD_SUBDOMAIN = 'hbapi-preprod'; +const HOST = 'retailspotads.com'; +const ENDPOINT = '/'; +const DEV_URL = 'http://localhost:3030/'; export const spec = { code: BIDDER_CODE, + gvlid: GVL_ID, supportedMediaTypes: [BANNER, VIDEO], aliases: ['rs'], // short code /** @@ -25,7 +29,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - const sizes = getSize(getSizeArray(bid)); + const sizes = getSize(bid); const sizeValid = sizes.width > 0 && sizes.height > 0; return deepAccess(bid, 'params.placement') && sizeValid; @@ -33,7 +37,8 @@ export const spec = { /** * Make a server request from the list of BidRequests. * - * @param {BidRequests} - bidRequests.bids[] is an array of AdUnits and bids + * @param {BidRequest} bidRequests is an array of AdUnits and bids + * @param {BidderRequest} bidderRequest * @return ServerRequest Info describing the request to the server. */ buildRequests: function (bidRequests, bidderRequest) { @@ -96,40 +101,39 @@ export const spec = { } } -function getSizeArray(bid) { +/* Get parsed size from request size */ +function getSize(bid) { let inputSize = bid.sizes || []; - if (bid.mediaTypes && bid.mediaTypes.banner) { + if (bid.mediaTypes?.banner) { inputSize = bid.mediaTypes.banner.sizes || []; } - // handle size in bid.params in formats: [w, h] and [[w,h]]. - if (bid.params && Array.isArray(bid.params.size)) { + // Size can be [w, h] or array of sizes : [[w,h]]. + if (Array.isArray(bid.params?.size)) { inputSize = bid.params.size; if (!Array.isArray(inputSize[0])) { inputSize = [inputSize] } } - return parseSizesInput(inputSize); -} - -/* Get parsed size from request size */ -function getSize(sizesArray) { + const sizesArray = parseSizesInput(inputSize); const parsed = {}; - // the main requested size is the first one + + // Use the first size as the main requested one const size = sizesArray[0]; + // size is ready if (typeof size !== 'string') { return parsed; } - const parsedSize = size.toUpperCase().split('X'); + // size is given as string "wwwxhhh" or "www*hhh" + const parsedSize = size.includes('*') ? size.split('*') : size.toUpperCase().split('X'); const width = parseInt(parsedSize[0], 10); if (width) { parsed.width = width; } - const height = parseInt(parsedSize[1], 10); if (height) { parsed.height = height; diff --git a/modules/retailspotBidAdapter .md b/modules/retailspotBidAdapter.md similarity index 92% rename from modules/retailspotBidAdapter .md rename to modules/retailspotBidAdapter.md index a9b4cb4bec3..1f56f66fbc8 100644 --- a/modules/retailspotBidAdapter .md +++ b/modules/retailspotBidAdapter.md @@ -25,7 +25,7 @@ Banner and Video ad formats are supported. bids: [{ bidder: "retailspot", params: { - placement: "test-12345" + placement: "eq-609785-1856964-125234" } }] }; diff --git a/test/spec/modules/retailspotBidAdapter_spec.js b/test/spec/modules/retailspotBidAdapter_spec.js index f1fb5ae3fd3..c5cb001c1ba 100644 --- a/test/spec/modules/retailspotBidAdapter_spec.js +++ b/test/spec/modules/retailspotBidAdapter_spec.js @@ -246,7 +246,7 @@ describe('RetailSpot Adapter', function () { ]; const adapter = newBidder(spec); - const DEV_URL = 'http://localhost:8090/'; + const DEV_URL = 'http://localhost:3030/'; describe('inherited functions', function () { it('exists and is a function', function () { @@ -333,7 +333,7 @@ describe('RetailSpot Adapter', function () { const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); const payload = JSON.parse(request.data); - expect(request.url).to.contain('https://ssp.retail-spot.io/prebid'); + expect(request.url).to.contain('https://hbapi.retailspotads.com/'); expect(request.method).to.equal('POST'); expect(payload).to.deep.equal(bidderRequest); @@ -344,7 +344,7 @@ describe('RetailSpot Adapter', function () { const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); const payload = JSON.parse(request.data); - expect(request.url).to.contain('https://ssp.retail-spot.io/prebid'); + expect(request.url).to.contain('https://hbapi.retailspotads.com/'); expect(request.method).to.equal('POST'); expect(payload).to.deep.equal(bidderRequest); @@ -355,7 +355,7 @@ describe('RetailSpot Adapter', function () { const request = spec.buildRequests(bidRequestMultiPlacements, bidderRequest); const payload = JSON.parse(request.data); - expect(request.url).to.contain('https://ssp.retail-spot.io/prebid'); + expect(request.url).to.contain('https://hbapi.retailspotads.com/'); expect(request.method).to.equal('POST'); expect(payload).to.deep.equal(bidderRequest);