Skip to content

Commit

Permalink
Automatad Bid Adapter: changes to ajax request options for bid reques…
Browse files Browse the repository at this point in the history
…ts (#8444)

* changes for ajax request options for automatad bid request

* add test for isCredentials changes
  • Loading branch information
Kanchika - Automatad authored May 31, 2022
1 parent 9179779 commit f26ae66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modules/automatadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const spec = {
data: payloadString,
options: {
contentType: 'application/json',
withCredentials: false,
withCredentials: true,
crossOrigin: true,
},
}
Expand Down Expand Up @@ -114,7 +114,7 @@ export const spec = {
},
onTimeout: function(timeoutData) {
const timeoutUrl = ENDPOINT_URL + '/timeout'
ajax(timeoutUrl, null, JSON.stringify(timeoutData))
spec.ajaxCall(timeoutUrl, null, JSON.stringify(timeoutData), {method: 'POST', withCredentials: true})
},
onBidWon: function(bid) {
if (!bid.nurl) { return }
Expand All @@ -136,11 +136,15 @@ export const spec = {
/\$\{AUCTION_ID\}/,
bid.auctionId
)
spec.ajaxCall(winUrl, null)
spec.ajaxCall(winUrl, null, null, {method: 'GET', withCredentials: true})
return true
},
ajaxCall: function(endpoint, data) {
ajax(endpoint, data)

ajaxCall: function(endpoint, callback, data, options = {}) {
if (data) {
options.contentType = 'application/json'
}
ajax(endpoint, callback, data, options)
},

}
Expand Down
4 changes: 4 additions & 0 deletions test/spec/modules/automatadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ describe('automatadBidAdapter', function () {
let req = spec.buildRequests([ bidRequestRequiredParams ], { refererInfo: { } })
let rdata

it('should have withCredentials option as true', function() {
expect(req.options.withCredentials).to.equal(true)
})

it('should return request object', function () {
expect(req).to.not.be.null
})
Expand Down

0 comments on commit f26ae66

Please sign in to comment.