Skip to content

Commit

Permalink
New Adapter: HuaweiAds (#1905)
Browse files Browse the repository at this point in the history
* New Adapter: HuaweiAds

* add usersync, no support

* modify native

* modify usersync, just pass

* modify code for banner native

* modify code for banner, monitor url can be a array.

* correct some issues

* move clientTime, add extraInfo, correct some example, add mccmnc

* Optimize some examples

* Optimize some examples, native add new trackingUrl

* Optimize some examples, add adId creativeId

* Optimize some examples, add userclose event type

* Optimize some examples, add country, correct

* Optimize some examples, add zone

* Optimize some examples, add userclose event type

* correct issues in the pull request, delete useless parameters

* correct issues in the pull request on github

* correct issues in the pull request on github, add bad_response_not_native.json

* add test authorization, update test cases.

* Merge branch 'master' of https://github.com/prebid/prebid-server into prebid-master

* correct some issues, delete race files

Co-authored-by: w00522253 <wangyu249@huawei.com>
  • Loading branch information
wwwyyy and w00522253 authored Aug 25, 2021
1 parent 6f542fb commit 498d2cf
Show file tree
Hide file tree
Showing 33 changed files with 5,891 additions and 0 deletions.
1,261 changes: 1,261 additions & 0 deletions adapters/huaweiads/huaweiads.go

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions adapters/huaweiads/huaweiads_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package huaweiads

import (
"github.com/prebid/prebid-server/adapters/adapterstest"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/openrtb_ext"
"testing"
)

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderHuaweiAds, config.Adapter{
Endpoint: "https://huaweiads.com/adxtest/"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}
adapterstest.RunJSONBidderTest(t, "huaweiadstest", bidder)
}
254 changes: 254 additions & 0 deletions adapters/huaweiads/huaweiadstest/exemplary/banner1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"mockBidRequest": {
"id": "test-req-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
],
"w": 300,
"h": 250
},
"ext": {
"bidder": {
"slotid": "m8x9x3rzff",
"adtype": "banner",
"publisherid": "123",
"signkey": "signkey",
"keyid": "41",
"isTestAuthorization": "true"
}
}
}
],
"app": {
"bundle": "com.wavehk.android",
"name": "Huawei Browser",
"ver": "9.1.0.301",
"content": {
"language": "zh"
}
},
"device": {
"ua": "useragent",
"h": 1920,
"language": "zh",
"geoCountry": "CH",
"model": "COL-TEST",
"os": "android",
"osv": "10.0.0",
"devicetype": 4,
"make": "huawei",
"w": 1080,
"ip": "ip",
"pxratio": 23.01,
"geo": {
"country": "CHN"
}
},
"user": {
"ext": {
"data": {
"gaid": [
"gaid"
],
"oaid": [
"oaid"
],
"clientTime": [
"2018-11-02 16:34:07.981+1300"
]
}
}
},
"regs": {
"coppa": 1
},
"ext": {
}
},
"httpcalls": [
{
"expectedRequest": {
"uri": "https://huaweiads.com/adxtest/",
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json;charset=utf-8"
],
"User-Agent": [
"useragent"
],
"Authorization": [
"Digest username=123,realm=ppsadx/getResult,nonce=1629473330823,response=d1d61a13a83e1468aa4dff5c8a6cee0b8b381173ca3eb6fa9b313937684d87c0,algorithm=HmacSHA256,usertype=1,keyid=41"
]
},
"body": {
"app": {
"lang": "zh",
"country": "CN",
"name": "Huawei Browser",
"pkgname": "com.wavehk.android",
"version": "9.1.0.301"
},
"multislot": [
{
"adtype": 8,
"slotid": "m8x9x3rzff",
"test": 0,
"format": [
{
"w": 300,
"h": 250
}
],
"w": 300,
"h": 250
}
],
"device": {
"height": 1920,
"language": "zh",
"oaid": "oaid",
"os": "android",
"type": 4,
"ip": "ip",
"localeCountry": "CN",
"pxratio": 23.01,
"width": 1080,
"clientTime": "2018-11-02 16:34:07.981+1300",
"gaid": "gaid",
"useragent": "useragent",
"version": "10.0.0",
"maker": "huawei",
"model": "COL-TEST",
"belongCountry": "CN"
},
"geo": {
},
"network": {
"type": 0
},
"regs": {
"coppa": 1
},
"version": "3.4"
}
},
"mockResponse": {
"status": 200,
"body": {
"ctrlSwitchs": "0",
"dsp1cost": 61,
"dspcost": 108,
"multiad": [
{
"adtype": 8,
"brsetting": "Y",
"content": [
{
"clickActionList": [
1
],
"contentid": "58025103",
"creativetype": 2,
"ctrlSwitchs": "001011001001010112",
"endtime": 1621428898335,
"filterList": [
3
],
"interactiontype": 1,
"landingTitle": 1,
"metaData": {
"adSign": "2",
"appPromotionChannel": "401721412",
"clickUrl": "https://ads.huawei.com/usermgtportal/home/index.html#/",
"imageInfo": [
{
"checkSha256Flag": 1,
"height": 300,
"imageType": "img",
"sha256": "f5d8487cddaecec45b73fc078649478c80ec646bfec8ed7da4ff931f90eab232",
"url": "https://ads.huawei.com/usermgtportal/home/img/huawei_logo_black.aaec817d.svg",
"width": 250
}
],
"label": "Banner_API",
"landingPageType": "3"
},
"monitor": [
{
"eventType": "click",
"url": [
"http://test/click1",
"http://test/click2",
"http://test/click3"
]
},
{
"eventType": "imp",
"url": [
"http://test/imp1",
"http://test/imp2",
"http://test/imp3"
]
}
],
"paramfromserver": {
"a": "1||test",
"sig": "",
"t": "99990101235959"
},
"price": 2.8,
"starttime": 1621267200000,
"taskid": "48017658"
}
],
"retcode30": 200,
"slotid": "m8x9x3rzff"
}
],
"noReportAdTypeEventList": [
{
"adType": 8,
"eventTypeList": [
"exception_6"
]
}
],
"retcode": 200,
"totalCacheSize": 300
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"adm": "<style> html, body { margin: 0; padding: 0; width: 100%; height: 100%; vertical-align: middle; } html { display: table; } body { display: table-cell; vertical-align: middle; text-align: center; -webkit-text-size-adjust: none; } </style> <span class=\"title-link advertiser_label\"></span> <a href='https://ads.huawei.com/usermgtportal/home/index.html#/' style=\"text-decoration:none\" onclick=sendGetReq()> <img src='https://ads.huawei.com/usermgtportal/home/img/huawei_logo_black.aaec817d.svg' width='250' height='300'/> </a> <img height=\"1\" width=\"1\" src='http://test/imp1' > <img height=\"1\" width=\"1\" src='http://test/imp2' > <img height=\"1\" width=\"1\" src='http://test/imp3' > <script type=\"text/javascript\">var dspClickTrackings = [\"http://test/click1\",\"http://test/click2\",\"http://test/click3\"];function sendGetReq() {sendSomeGetReq(dspClickTrackings)}function sendOneGetReq(url) {var req = new XMLHttpRequest();req.open('GET', url, true);req.send(null);}function sendSomeGetReq(urls) {for (var i = 0; i < urls.length; i++) {sendOneGetReq(urls[i]);}}</script>",
"adomain": [
"huaweiads"
],
"crid": "58025103",
"id": "test-imp-id",
"impid": "test-imp-id",
"price": 2.8,
"h": 300,
"w": 250
},
"type": "banner"
}
]
}
]
}
Loading

0 comments on commit 498d2cf

Please sign in to comment.