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

[PAT-376] Sync Fork to get ORTB 2.6 changes #35

Merged
merged 52 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6880b63
fix StringOrNumber for empty strings
venediktov Nov 2, 2017
6442b40
add test for empty StringOrNumber encoder/decoder
Nov 2, 2017
7b145eb
Merge pull request #46 from vanilla-rtb/master
dim Nov 3, 2017
8bc7f15
Content, fix typo in Album property json tag
sgodart Apr 23, 2018
8d41110
Merge pull request #50 from ividence/master
dim Apr 23, 2018
cb99031
Change type on Content.Context from int to NumberOrString
AaronReboot Sep 14, 2018
fd328b9
Add test for quoted context field in Content object
AaronReboot Sep 19, 2018
de6e90d
Merge pull request #54 from MadHive/master
dim Sep 27, 2018
87b0a29
Bump CI config
dim Sep 27, 2018
678b6f1
Use go mod
dim Nov 29, 2018
9c04274
Fix build
dim Nov 29, 2018
0438498
Add omitempty to Native Ad Response Link struct
saifat29 Feb 21, 2019
643b4f1
Merge pull request #58 from saifat29/patch-1
dim Mar 12, 2019
9e640fb
switch back custom Extension to json.RawMessage
mxmCherry Jun 24, 2019
d4bd648
readme: add a Requirements section, mentioning Go 1.8+
mxmCherry Jun 24, 2019
88dbbc5
Merge pull request #63 from mxmCherry/feature/use-json-rawmessage
dim Jun 24, 2019
b972a5c
Bump deps, tidy
dim Aug 19, 2019
3b1a908
add vcm attr to banner
Oct 28, 2019
75ebdae
fix banner test for vcm
Oct 28, 2019
f0c31f9
Merge pull request #67 from EastResident/feature/vcm
dim Oct 28, 2019
62ce92d
New major release
dim Oct 28, 2019
da7bfdf
Merge pull request #68 from bsm/feature/v3
dim Oct 28, 2019
ebea466
remove min and max duration validation
Nov 1, 2019
665256b
Merge pull request #69 from EastResident/feature/video_duration_optional
dim Nov 1, 2019
dfdddca
fix ContentCategory.
Sky-Zeng Feb 17, 2020
43045f3
Merge pull request #72 from Sky-Zeng/skz_cat
dim Feb 17, 2020
c72f27d
fix a typo in 3D Graphics Content Category
Mar 13, 2020
ebc36e8
Merge pull request #74 from ollevche/fix-typo
dim Mar 13, 2020
a958dfa
Fix formatting
dim Apr 14, 2020
385531a
fix a typo in 7-12 Education Content Category
ollevche Apr 14, 2020
1edcd29
Merge pull request #76 from ollevche/fix-typo
dim Apr 14, 2020
7b78264
Format ratio added
Sep 16, 2022
6f64bb3
Merge pull request #91 from jrobin42/master
dim Sep 20, 2022
ac42b90
Add device.sua
stokito Jan 5, 2023
12c76e8
Merge pull request #92 from stokito/add_sua
dim Jan 9, 2023
b106b7e
Modernise, remove deps (#93)
dim Jan 9, 2023
56ba587
Fix sua browsers type (#96)
Katsukiniwa Jan 20, 2023
24701da
Fix sua source type (#98)
MasatoraAtarashi Feb 9, 2023
4cbc130
- Introduction of ooh device type | (#100)
shivakumarss Apr 6, 2023
7dda58d
Add ortb 2.6 features to video object (#101)
pd-pranay Apr 8, 2023
74f390a
Add open rtb 2.6 features in Bid Response (seatbid.bid) (#102)
pd-pranay Apr 11, 2023
5129f80
Request to add new Video Placement support. (#104)
pd-pranay May 25, 2023
2214def
Remove omitempty from w and h of Video object (bsm#105) (#106)
saifat29 Jun 1, 2023
071ec74
Add ortb 2.6 features to content object (#108)
pd-pranay Jun 15, 2023
5563255
full support for `langb` fields (#109)
codenaugh Aug 21, 2023
5547ba6
support oRTB 2.6 qty field in impressions object (#111)
teixeiratho Sep 15, 2023
e622479
Add OpenRTB 2.6 Regulation fields (#115)
codenaugh Feb 19, 2024
53155b9
sync fork. pulls in additive changes only to not break existing refer…
rourkewhite Mar 25, 2024
8288bbc
fix go mod
rourkewhite Mar 25, 2024
54bcae9
fix seatbid test
rourkewhite Mar 25, 2024
0d1b208
fix quantity test
rourkewhite Mar 25, 2024
f9fae6e
fix extension marshaling and tests
rourkewhite Mar 26, 2024
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
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
go:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.18.x, 1.19.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
cache: true
- run: make test
golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.x
cache: true
- uses: golangci/golangci-lint-action@v3
with:
version: latest
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.makefile

.idea
.vscode
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2015 Black Square Media Ltd. All rights reserved.
(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Some test examples were taken from:
https://code.google.com/p/openrtb/wiki/OpenRTB_Examples
41 changes: 8 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Go OpenRTB v2.x
# OpenRTB

[![Build Status](https://travis-ci.org/UnityTech/openrtb.svg?branch=master)](https://travis-ci.org/UnityTech/openrtb)

OpenRTB implementation for Go
OpenRTB structs and validations for Go.

## Requirements

Requires Go 1.8+ for proper `json.RawMessage` marshaling.

## Installation

Expand All @@ -14,13 +18,12 @@ go get github.com/UnityTech/openrtb

## Usage

Import the package:

```go
package main

import (
"log"

"github.com/UnityTech/openrtb"
)

Expand All @@ -32,38 +35,10 @@ func main() {
defer file.Close()

var req *openrtb.BidRequest
err = json.NewDecoder(file).Decode(&req)
if err != nil {
if err := json.NewDecoder(file).Decode(&req); err != nil {
log.Fatal(err)
}

log.Printf("%+v\n", req)
}
```

## Licence

Copyright (c) 2015 Black Square Media Ltd. All rights reserved.
(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Some test examples were taken from:
https://code.google.com/p/openrtb/wiki/OpenRTB_Examples
4 changes: 2 additions & 2 deletions audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var (
ErrInvalidAudioNoMimes = errors.New("openrtb: audio has no mimes")
)

// The "audio" object must be included directly in the impression object
// Audio object must be included directly in the impression object
type Audio struct {
Mimes []string `json:"mimes"` // Content MIME types supported.
MinDuration int `json:"minduration,omitempty"` // Minimum video ad duration in seconds
Expand All @@ -35,7 +35,7 @@ type Audio struct {

type jsonAudio Audio

// Validates the object
// Validate the object
func (a *Audio) Validate() error {
if len(a.Mimes) == 0 {
return ErrInvalidAudioNoMimes
Expand Down
106 changes: 55 additions & 51 deletions audio_test.go
Original file line number Diff line number Diff line change
@@ -1,58 +1,62 @@
package openrtb
package openrtb_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"errors"
"reflect"
"testing"

. "github.com/UnityTech/openrtb"
)

var _ = Describe("Audio", func() {
func TestAudio(t *testing.T) {
var subject *Audio
if err := fixture("audio", &subject); err != nil {
t.Fatalf("expected no error, got %v", err)
}

BeforeEach(func() {
err := fixture("audio", &subject)
Expect(err).NotTo(HaveOccurred())
})

It("should parse correctly", func() {
Expect(subject).To(Equal(&Audio{
Mimes: []string{
"audio/mp4",
},
MinDuration: 5,
MaxDuration: 30,
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper},
Sequence: 1,
BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert},
MaxExtended: 30,
MinBitrate: 300,
MaxBitrate: 1500,
Delivery: []int{ContentDeliveryProgressive},
CompanionAd: []Banner{
{W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}},
{W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}},
},
API: []int{APIFrameworkVPAID1, APIFrameworkVPAID2},
CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML},
}))
})

It("should validate", func() {
Expect((&Audio{
MinDuration: 5,
MaxDuration: 30,
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper},
Sequence: 1,
BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert},
MaxExtended: 30,
MinBitrate: 300,
MaxBitrate: 1500,
Delivery: []int{ContentDeliveryProgressive},
CompanionAd: []Banner{
{W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}},
{W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}},
},
CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML},
}).Validate()).To(Equal(ErrInvalidAudioNoMimes))
})
exp := &Audio{
Mimes: []string{
"audio/mp4",
},
MinDuration: 5,
MaxDuration: 30,
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper},
Sequence: 1,
BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert},
MaxExtended: 30,
MinBitrate: 300,
MaxBitrate: 1500,
Delivery: []int{ContentDeliveryProgressive},
CompanionAd: []Banner{
{W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}},
{W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}},
},
API: []int{APIFrameworkVPAID1, APIFrameworkVPAID2},
CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML},
}
if got := subject; !reflect.DeepEqual(exp, got) {
t.Errorf("expected %+v, got %+v", exp, got)
}
}

})
func TestAudio_Validate(t *testing.T) {
subject := &Audio{
MinDuration: 5,
MaxDuration: 30,
Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper},
Sequence: 1,
BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert},
MaxExtended: 30,
MinBitrate: 300,
MaxBitrate: 1500,
Delivery: []int{ContentDeliveryProgressive},
CompanionAd: []Banner{
{W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}},
{W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}},
},
CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML},
}
if exp, got := ErrInvalidAudioNoMimes, subject.Validate(); !errors.Is(exp, got) {
t.Fatalf("expected %v, got %v", exp, got)
}
}
2 changes: 1 addition & 1 deletion banner.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package openrtb

// The "banner" object must be included directly in the impression object if the impression offered
// Banner object must be included directly in the impression object if the impression offered
// for auction is display or rich media, or it may be optionally embedded in the video object to
// describe the companion banners available for the linear or non-linear video ad. The banner
// object may include a unique identifier; this can be useful if these IDs can be leveraged in the
Expand Down
43 changes: 22 additions & 21 deletions banner_test.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package openrtb
package openrtb_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"reflect"
"testing"

. "github.com/UnityTech/openrtb"
)

var _ = Describe("Banner", func() {
func TestBanner(t *testing.T) {
var subject *Banner
if err := fixture("banner", &subject); err != nil {
t.Fatalf("expected no error, got %v", err)
}

BeforeEach(func() {
err := fixture("banner", &subject)
Expect(err).NotTo(HaveOccurred())
})

It("should parse correctly", func() {
Expect(subject).To(Equal(&Banner{
W: 728,
H: 90,
Pos: AdPosAboveFold,
BType: []int{BannerTypeFrame},
BAttr: []int{CreativeAttributeWindowsDialogOrAlert},
Api: []int{APIFrameworkMRAID1},
}))
})

})
exp := &Banner{
W: 728,
H: 90,
Pos: AdPosAboveFold,
BType: []int{BannerTypeFrame},
BAttr: []int{CreativeAttributeWindowsDialogOrAlert},
Api: []int{APIFrameworkMRAID1},
VCM: 1,
}
if got := subject; !reflect.DeepEqual(exp, got) {
t.Errorf("expected %+v, got %+v", exp, got)
}
}
6 changes: 3 additions & 3 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package openrtb

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"testing"
)

func BenchmarkBidRequest_Unmarshal(b *testing.B) {
data, err := ioutil.ReadFile(filepath.Join("testdata", "breq.video.json"))
data, err := os.ReadFile(filepath.Join("testdata", "breq.video.json"))
if err != nil {
b.Fatal(err.Error())
}
Expand All @@ -23,7 +23,7 @@ func BenchmarkBidRequest_Unmarshal(b *testing.B) {
}

func BenchmarkBidRequest_Marshal(b *testing.B) {
data, err := ioutil.ReadFile(filepath.Join("testdata", "breq.video.json"))
data, err := os.ReadFile(filepath.Join("testdata", "breq.video.json"))
if err != nil {
b.Fatal(err.Error())
}
Expand Down
21 changes: 15 additions & 6 deletions bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var (
ErrInvalidBidNoImpID = errors.New("openrtb: bid is missing impression ID")
)

// Bid object contains bid information.
// ID, ImpID and Price are required; all other optional.
// If the bidder wins the impression, the exchange calls notice URL (nurl)
// a) to inform the bidder of the win;
Expand All @@ -32,7 +33,7 @@ type Bid struct {
Tactic string `json:"tactic,omitempty"` // Tactic ID to enable buyers to label bids for reporting to the exchange the tactic through which their bid was submitted.
Cat []string `json:"cat,omitempty"` // IAB content categories of the creative. Refer to List 5.1
Attr []int `json:"attr,omitempty"` // Array of creative attributes.
API int `json:"api,omitempty"` // API required by the markup if applicable
API int `json:"api,omitempty"` // API required by the markup if applicable, NOTE: for ORTB ver <= 2.5 APIFramework supported is 1 to 6.
Protocol int `json:"protocol,omitempty"` // Video response protocol of the markup if applicable
QAGMediaRating int `json:"qagmediarating,omitempty"` // Creative media rating per IQG guidelines.
Language string `json:"language,omitempty"` // Language of the creative using ISO-639-1-alpha-2.
Expand All @@ -41,11 +42,19 @@ type Bid struct {
W int `json:"w,omitempty"` // Width of the ad in pixels.
WRatio int `json:"wratio,omitempty"` // Relative width of the creative when expressing size as a ratio.
HRatio int `json:"hratio,omitempty"` // Relative height of the creative when expressing size as a ratio.
Exp int `json:"exp,omitempty"` // Advisory as to the number of seconds the bidder is willing to wait between the auction and the actual impression.
ContentType string `json:"-"` // Content of the bid
MediaType string `json:"-"` // Media of the impression e.g. video/display
IsOMEnabled bool `json:"-"` // Flag to send indicate to the Sdk whether or not to run om scripts
Ext Extension `json:"ext,omitempty"`

APIS []int `json:"apis,omitempty"` // APIS required by the markup if applicable.
LangB string `json:"langb,omitempty"` // Language of the creative using IETF BCP 47. Only one of language or langb should be present.
Duration int `json:"dur,omitempty"` // Duration of the video or audio creative in seconds.
MarkupType MarkupType `json:"mtype,omitempty"` // Creative markup so that it can properly be associated.
SlotInPod SlotPositionInPod `json:"slotinpod,omitempty"` // Indicates that the bid response is only eligible for a specific position.
CategoryTaxonomy CategoryTaxonomy `json:"cattax,omitempty"` // Defines the taxonomy in use.

Exp int `json:"exp,omitempty"` // Advisory as to the number of seconds the bidder is willing to wait between the auction and the actual impression.
ContentType string `json:"-"` // Content of the bid
MediaType string `json:"-"` // Media of the impression e.g. video/display
IsOMEnabled bool `json:"-"` // Flag to send indicate to the Sdk whether or not to run om scripts
Ext Extension `json:"ext,omitempty"`
}

// Validate required attributes
Expand Down
Loading
Loading