Skip to content

Commit

Permalink
Merge pull request #7 from PubMatic-OpenWrap/openrtb-v20.1.0
Browse files Browse the repository at this point in the history
Upgrade to openrtb v20.1.0
  • Loading branch information
pm-nilesh-chate authored Feb 22, 2024
2 parents 56ce40c + c76a5cc commit 2d647d1
Show file tree
Hide file tree
Showing 47 changed files with 208 additions and 85 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# openrtb [![Go Reference](https://pkg.go.dev/badge/github.com/prebid/openrtb/v19.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19) [![Test](https://github.com/prebid/openrtb/actions/workflows/test.yml/badge.svg)](https://github.com/prebid/openrtb/actions/workflows/test.yml)
# openrtb [![Go Reference](https://pkg.go.dev/badge/github.com/prebid/openrtb/v20.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20) [![Test](https://github.com/prebid/openrtb/actions/workflows/test.yml/badge.svg)](https://github.com/prebid/openrtb/actions/workflows/test.yml)

[OpenRTB](https://iabtechlab.com/standards/openrtb/), [AdCOM](https://iabtechlab.com/standards/openmedia) and [OpenRTB Dynamic Native Ads](https://iabtechlab.com/standards/openrtb-native/) types for [Go programming language](https://golang.org/)

Expand All @@ -9,24 +9,24 @@

**Requires Go 1.16+**

This library uses [Go modules](https://golang.org/ref/mod) ([tl;dr](https://blog.golang.org/using-go-modules)) and requires Go [1.16](https://golang.org/doc/go1.16)+ to enable the ability to issue release retractions.
This library uses [Go modules](https://golang.org/ref/mod) ([tl;dr](https://blog.golang.org/using-go-modules)) and requires Go [1.16](https://golang.org/doc/go1.16)+ for the ability to issue release retractions.

# Using

```bash
go get -u "github.com/prebid/openrtb/v19/..."
go get -u "github.com/prebid/openrtb/v20/..."
```

```go
import (
openrtb2 "github.com/prebid/openrtb/v19/openrtb2"
openrtb2 "github.com/prebid/openrtb/v20/openrtb2"

openrtb3 "github.com/prebid/openrtb/v19/openrtb3"
adcom1 "github.com/prebid/openrtb/v19/adcom1"
openrtb3 "github.com/prebid/openrtb/v20/openrtb3"
adcom1 "github.com/prebid/openrtb/v20/adcom1"

native1 "github.com/prebid/openrtb/v19/native1"
nreq "github.com/prebid/openrtb/v19/native1/request"
nres "github.com/prebid/openrtb/v19/native1/response"
native1 "github.com/prebid/openrtb/v20/native1"
nreq "github.com/prebid/openrtb/v20/native1/request"
nres "github.com/prebid/openrtb/v20/native1/response"
)
```

Expand All @@ -51,19 +51,19 @@ The `main` branch always contains latest code, so better use some package manage
- all enums, described in section 5, must be typed with section name singularized (e.g., "5.2 Banner Ad Types" -> `type BannerAdType int8`)
- all typed enums must have constants for each element, prefixed with type name (e.g., "5.2 Banner Ad Types - XHTML Text Ad (usually mobile)" -> `const BannerAdTypeXHTMLTextAd BannerAdType = 1`)
- never use `iota` for enum constants
- OpenRTB (2.x) section "5.1 Content Categories" should remain untyped and have no constants
- OpenRTB (2.x) "content categories" should remain untyped and have no constants

## Pointers/omitempty
Pointer | Omitempty | When to use | Example
------- | --------- | -------------------------------------------------------------------- | ---------------------------------
no | no | _required_ in spec | `Audio.mimes`
yes | yes | _required_ in spec, but is a part of mutually-exclusive group | `Imp.{banner,video,audio,native}`
no | yes | zero value (`""`, `0`) is useless / has no meaning | `Device.ua`
yes | yes | zero value (`""`, `0`) or value absence (`null`) has special meaning | `Device.{dnt,lmt}`
no | no | _required_ in spec | `Audio.MIMEs`
yes | yes | _required_ in spec, but is a part of mutually-exclusive group | `Imp.{Banner,Video,Audio,Native}`
no | yes | zero value (`""`, `0`) has no meaning, is defined in the spec as the default value, or represents time / duration | `Device.UA`
yes | yes | zero value (`""`, `0`) or value absence (`null`) has special meaning | `Device.{DNT,Lmt}`

Using both pointer and `omitempty` is mostly just to save traffic / generate more "canonical" (strict) JSON.

## Documentation ([pkg.go.dev](https://pkg.go.dev/github.com/prebid/openrtb/v19))
## Documentation ([pkg.go.dev](https://pkg.go.dev/github.com/prebid/openrtb/v20))
- [Godoc: documenting Go code](http://blog.golang.org/godoc-documenting-go-code)
- Each entity (type, struct key or constant) should be documented
- Ideally, copy-paste descriptions as-is, but feel free to omit section numbers, so just `<GoTypeName> defines <copy-pasted description from spec>`
Expand Down
2 changes: 1 addition & 1 deletion adcom1/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# adcom1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/adcom1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/adcom1)
# adcom1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/adcom1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/adcom1)

[AdCOM](https://iabtechlab.com/standards/openmedia/) [1.0](https://github.com/InteractiveAdvertisingBureau/AdCOM) types for [Go programming language](https://golang.org/)
2 changes: 1 addition & 1 deletion adcom1/adcom1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"

. "github.com/prebid/openrtb/v19/adcom1"
. "github.com/prebid/openrtb/v20/adcom1"
)

var _ = DescribeTable(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/prebid/openrtb/v19
module github.com/prebid/openrtb/v20

go 1.16

Expand Down
2 changes: 1 addition & 1 deletion native1/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# native1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/native1)
# native1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/native1)

[OpenRTB Dynamic Native Ads API](https://iabtechlab.com/standards/openrtb-native/) [1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) section "7 Reference Lists/Enumerations" types for [Go programming language](https://golang.org/)

Expand Down
2 changes: 1 addition & 1 deletion native1/request/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# native1/request [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/request?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/native1/request)
# native1/request [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/request?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/native1/request)

[OpenRTB Dynamic Native Ads API](https://iabtechlab.com/standards/openrtb-native/) [1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) section "4 Native Ad Request Markup Details" types for [Go programming language](https://golang.org/)
2 changes: 1 addition & 1 deletion native1/request/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.6 Data Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/event_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.7 Event Trackers Request Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.4 Image Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.1 Native Markup Request Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/native1/request"
. "github.com/prebid/openrtb/v20/native1/request"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
2 changes: 1 addition & 1 deletion native1/request/video.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package request

import (
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/openrtb/v20/openrtb2"
)

// 4.5 Video Object
Expand Down
2 changes: 1 addition & 1 deletion native1/response/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# native1/response [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/response?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/native1/response)
# native1/response [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/response?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/native1/response)

[OpenRTB Dynamic Native Ads API](https://iabtechlab.com/standards/openrtb-native/) [1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) section "5 Native Ad Response Markup Details" types for [Go programming language](https://golang.org/)
2 changes: 1 addition & 1 deletion native1/response/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package response
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 5.5 Object: Data
Expand Down
2 changes: 1 addition & 1 deletion native1/response/event_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package response
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 5.8 Event Tracker Response Object
Expand Down
2 changes: 1 addition & 1 deletion native1/response/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package response
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 5.4 Object: Image
Expand Down
2 changes: 1 addition & 1 deletion native1/response/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/native1/response"
. "github.com/prebid/openrtb/v20/native1/response"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# openrtb2 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/openrtb2?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/openrtb2)
# openrtb2 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/openrtb2?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/openrtb2)

[OpenRTB](https://iabtechlab.com/standards/openrtb/) [2.6](https://iabtechlab.com/wp-content/uploads/2022/04/OpenRTB-2-6_FINAL.pdf) types for [Go programming language](https://golang.org/)
6 changes: 3 additions & 3 deletions openrtb2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// Object: App
Expand Down Expand Up @@ -111,15 +111,15 @@ type App struct {
// integer
// Description:
// Indicates if the app has a privacy policy, where 0 = no, 1 = yes.
PrivacyPolicy int8 `json:"privacypolicy,omitempty"`
PrivacyPolicy *int8 `json:"privacypolicy,omitempty"`

// Attribute:
// paid
// Type:
// integer
// Description:
// 0 = app is free, 1 = the app is a paid version.
Paid int8 `json:"paid,omitempty"`
Paid *int8 `json:"paid,omitempty"`

// Attribute:
// publisher
Expand Down
17 changes: 13 additions & 4 deletions openrtb2/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.8 Object: Audio
Expand Down Expand Up @@ -170,15 +170,15 @@ type Audio struct {
// Type:
// integer
// Description:
// Minimum bit rate in Kbps.
// Minimum bit rate in Kbps (kilobits per second).
MinBitrate int64 `json:"minbitrate,omitempty"`

// Attribute:
// maxbitrate
// Type:
// integer
// Description:
// Maximum bit rate in Kbps.
// Maximum bit rate in Kbps (kilobits per second).
MaxBitrate int64 `json:"maxbitrate,omitempty"`

// Attribute:
Expand Down Expand Up @@ -245,7 +245,7 @@ type Audio struct {
// Description:
// Indicates if the ad is stitched with audio content or delivered
// independently, where 0 = no, 1 = yes.
Stitched int8 `json:"stitched,omitempty"`
Stitched *int8 `json:"stitched,omitempty"`

// Attribute:
// nvol
Expand All @@ -256,6 +256,15 @@ type Audio struct {
// Normalization Modes in AdCOM 1.0.
NVol *adcom1.VolumeNormalizationMode `json:"nvol,omitempty"`

// Attribute:
// durfloors
// Type:
// object array
// Description:
// An array of DurFloors objects (Section 3.2.35) indicating the floor
// prices for video creatives of various durations that the buyer may bid with.
DurFloors []DurFloors `json:"durfloors,omitempty"`

// Attribute:
// ext
// Type:
Expand Down
4 changes: 2 additions & 2 deletions openrtb2/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.6 Object: Banner
Expand Down Expand Up @@ -170,7 +170,7 @@ type Banner struct {
// (Section 3.2.7) in an array of companion ads. Indicates the
// companion banner rendering mode relative to the associated
// video, where 0 = concurrent, 1 = end-card.
VCm int8 `json:"vcm,omitempty"`
Vcm *int8 `json:"vcm,omitempty"`

// Attribute:
// ext
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 4.3.3 Object: Bid
Expand Down
21 changes: 17 additions & 4 deletions openrtb2/bid_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.1 Object: BidRequest
//
// The top-level bid request object contains a globally unique bid request or auction ID.
// The top-level bid request object contains an exchange unique bid request or auction ID.
// This id attribute is required as is at least one impression object (Section 3.2.4).
// Other attributes in this top-level object establish rules and restrictions that apply to all impressions being offered.
//
Expand All @@ -22,7 +22,9 @@ type BidRequest struct {
// Type:
// string; required
// Description:
// Unique ID of the bid request, provided by the exchange.
// ID of the bid request, assigned by the exchange, and unique for the
// exchange’s subsequent tracking of the responses. The exchange may use
// different values for different recipients.
ID string `json:"id"`

// Attribute:
Expand Down Expand Up @@ -182,6 +184,17 @@ type BidRequest struct {
// should be present.
WLangB []string `json:"wlangb,omitempty"`

// Attribute:
// acat
// Type:
// string array
// Description:
// Allowed advertiser categories using the specified category taxonomy.
// The taxonomy to be used is defined by the cattax field. If no cattax
// field is supplied IAB Content Taxonomy 1.0 is assumed. Only one of
// acat or bcat should be present.
ACat []string `json:"acat,omitempty"`

// Attribute:
// bcat
// Type:
Expand All @@ -191,7 +204,7 @@ type BidRequest struct {
// category taxonomy.
// The taxonomy to be used is defined by the cattax field. If no
// cattax field is supplied IAB Content Category Taxonomy 1.0 is
// assumed.
// assumed. Only one of acat or bcat should be present.
BCat []string `json:"bcat,omitempty"`

// Attribute:
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/openrtb2"
. "github.com/prebid/openrtb/v20/openrtb2"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/openrtb3"
"github.com/prebid/openrtb/v20/openrtb3"
)

// 4.3.1 Object: BidResponse
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/openrtb2"
. "github.com/prebid/openrtb/v20/openrtb2"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
Loading

0 comments on commit 2d647d1

Please sign in to comment.