From fbfffffcc0a8220ca150af259e7825ff7c4745dd Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Sun, 23 Apr 2017 15:22:53 -0400 Subject: [PATCH 1/9] initial revs to support prebid server --- format.go | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ source.go | 42 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 format.go create mode 100644 source.go diff --git a/format.go b/format.go new file mode 100644 index 0000000..fb4df51 --- /dev/null +++ b/format.go @@ -0,0 +1,57 @@ +package openrtb + +// 3.2.10 Object: Format +// +// OpenRTB 2.5: +// This object represents an allowed size (i.e., height and width combination) or Flex Ad parameters for a banner impression. +// These are typically used in an array where multiple sizes are permitted. It is recommended that either the w/h pair or +// the wratio/hratio/wmin set (i.e., for Flex Ads) be specified. +type Format struct { + // Attribute: + // w + // Type: + // integer + // Description: + // Width in device independent pixels (DIPS). + W uint64 `json:"w"` + + // Attribute: + // h + // Type: + // integer + // Description: + // Height in device independent pixels (DIPS). + H uint64 `json:"h"` + + // Attribute: + // wratio + // Type: + // integer + // Description: + // Relative width when expressing size as a ratio. + WRatio int `json:"wratio"` + + // Attribute: + // hratio + // Type: + // integer + // Description: + // Relative height when expressing size as a ratio. + HRatio int `json:"hratio"` + + // Attribute: + // wmin + // Type: + // integer + // Description: + // The minimum width in device independent pixels (DIPS) at which the ad will be displayed the size is expressed as a ratio. + WMin int `json:"wmin"` + + // Attribute: + // ext + // Type: + // object + // Description: + // Placeholder for exchange-specific extensions to OpenRTB. + Ext RawJSON `json:"ext,omitempty"` +} diff --git a/source.go b/source.go new file mode 100644 index 0000000..dd889e5 --- /dev/null +++ b/source.go @@ -0,0 +1,42 @@ +package openrtb + +// 3.2.2 Object: Source +// +// OpenRTB 2.5: +// This object describes the nature and behavior of the entity that is the source of the bid request upstream from the exchange. +// The primary purpose of this object is to define post-auction or upstream decisioning when the exchange itself does not control +// the final decision. A common example of this is header bidding, but it can also apply to upstream server entities such as another +// RTB exchange, a mediation platform, or an ad server combines direct campaigns with 3rd party demand in decisioning. +type Source struct { + // Attribute: + // fd + // Type: + // integer, recommended + // Description: + // Entity responsible for the final impression sale decision, where 0 = exchange, 1 = upstream source. + FD uint8 `json:"fd,omitempty"` + + // Attribute: + // tid + // Type: + // string, recommended + // Description: + // Transaction ID that must be common across all participants in this bid request (e.g., potentially multiple exchanges). + TID string `json:"tid,omitempty"` + + // Attribute: + // pchain + // Type: + // string; recommended + // Description: + // Payment ID chain string containing embedded syntax described in the TAG Payment ID Protocol v1.0. + PChain int `json:"pchain,omitempty"` + + // Attribute: + // ext + // Type: + // object + // Description: + // Placeholder for exchange-specific extensions to OpenRTB. + Ext RawJSON `json:"ext,omitempty"` +} From 2a139cf623d9eaeaf1b0b79c9423a3b8d79229a2 Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Mon, 24 Apr 2017 09:55:29 -0400 Subject: [PATCH 2/9] add rest of files --- README.md | 14 ++++++++------ banner.go | 16 ++++++++++++---- bid_request.go | 8 ++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bd34858..9905fc6 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,23 @@ # openrtb -[![GoDoc](https://godoc.org/gopkg.in/mxmCherry/openrtb.v3?status.svg)](https://godoc.org/gopkg.in/mxmCherry/openrtb.v3) +[![GoDoc](https://godoc.org/github.com/prebid/openrtb?status.svg)](https://godoc.org/github.com/prebid/openrtb) [OpenRTB](//github.com/openrtb/OpenRTB) [v2.3.1](//github.com/openrtb/OpenRTB/blob/master/OpenRTB-API-Specification-Version-2-3-1-FINAL.pdf) types for Go programming language (golang) -**Warning!** Using [glide](https://github.com/Masterminds/glide) is recommended to vendor specific commit hash. - # Using ```bash -go get -u "gopkg.in/mxmCherry/openrtb.v3" +go get -u "github.com/prebid/openrtb" ``` ```go -import "gopkg.in/mxmCherry/openrtb.v3" +import "github.com/prebid/openrtb" ``` +# History + +Forked on April 23, 2017 from [mxmCherry](//github.com/mxmCherry/openrtb.v3) + # Goals Provide base for OpenRTB-related projects, focusing on: @@ -31,7 +33,7 @@ Provide base for OpenRTB-related projects, focusing on: - Capitalized ID keys ## Types -- Key types should be chosen according to OpenRTB v2.3.1 specification (attribute types) +- Key types should be chosen according to OpenRTB v2.5 specification (attribute types) - Numeric types: - architecture-independent, e.g., ```int32``` instead of ```int``` - signed integral types should be used only when absolutely needed (value may contain negative numbers), unsigned integral types are preferred diff --git a/banner.go b/banner.go index 00be11c..9c49bbc 100644 --- a/banner.go +++ b/banner.go @@ -34,10 +34,18 @@ type Banner struct { // height requirement. Otherwise it is a preferred height. H uint64 `json:"h,omitempty"` + // Attribute: + // format + // Type: + // array of formats + // Description: + // Creative sizes allowed by this tag. Overrides h and w if provided + Format []Format `json:"format,omitempty"` + // Attribute: // wmax // Type: - // integer + // integer; deprecated // Description: // Maximum width of the impression in pixels. // If included along with a w value then w should be interpreted @@ -47,7 +55,7 @@ type Banner struct { // Attribute: // hmax // Type: - // integer + // integer; deprecated // Description: // Maximum height of the impression in pixels. // If included along with an h value then h should be interpreted @@ -57,7 +65,7 @@ type Banner struct { // Attribute: // wmin // Type: - // integer + // integer; deprecated // Description: // Minimum width of the impression in pixels. // If included along with a w value then w should be interpreted @@ -67,7 +75,7 @@ type Banner struct { // Attribute: // hmin // Type: - // integer + // integer; deprecated // Description: // Minimum height of the impression in pixels. // If included along with an h value then h should be interpreted diff --git a/bid_request.go b/bid_request.go index 0071fb9..8e7b40a 100644 --- a/bid_request.go +++ b/bid_request.go @@ -135,6 +135,14 @@ type BidRequest struct { // Block list of advertisers by their domains (e.g., “ford.com”). BAdv []string `json:"badv,omitempty"` + // Attribute: + // source + // Type: + // object + // Description: + // A Source object (Section 3.2.2) that provides data about the inventory source and which entity makes the final decision. + Source *Source `json:"source,omitempty"` + // Attribute: // regs // Type: From caae377f7d16914042c00364845fad0abc2496ba Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Wed, 26 Apr 2017 18:12:50 -0400 Subject: [PATCH 3/9] omitempty on non-required fields --- format.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/format.go b/format.go index fb4df51..9521ee5 100644 --- a/format.go +++ b/format.go @@ -29,7 +29,7 @@ type Format struct { // integer // Description: // Relative width when expressing size as a ratio. - WRatio int `json:"wratio"` + WRatio int `json:"wratio,omitempty"` // Attribute: // hratio @@ -37,7 +37,7 @@ type Format struct { // integer // Description: // Relative height when expressing size as a ratio. - HRatio int `json:"hratio"` + HRatio int `json:"hratio,omitempty"` // Attribute: // wmin @@ -45,7 +45,7 @@ type Format struct { // integer // Description: // The minimum width in device independent pixels (DIPS) at which the ad will be displayed the size is expressed as a ratio. - WMin int `json:"wmin"` + WMin int `json:"wmin,omitempty"` // Attribute: // ext From b5b1fb39df3f412d1ddc4d861f2a3e5c2ef86c3b Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Sun, 7 May 2017 14:20:27 -0400 Subject: [PATCH 4/9] Update device and geo to openrtb 2.5 --- README.md | 3 ++- device.go | 25 ++++++++++++++++++++++--- geo.go | 29 ++++++++++++++++++++++++++++- openrtb_test.go | 2 +- raw_json_test.go | 2 +- 5 files changed, 54 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9905fc6..e514bd6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ import "github.com/prebid/openrtb" # History -Forked on April 23, 2017 from [mxmCherry](//github.com/mxmCherry/openrtb.v3) +- Forked on April 23, 2017 from [mxmCherry](//github.com/mxmCherry/openrtb.v3) +- Updated Device, Geo to OpenRTB 2.5 # Goals diff --git a/device.go b/device.go index 55241c3..26750af 100644 --- a/device.go +++ b/device.go @@ -1,6 +1,7 @@ package openrtb -// 3.2.11 Object: Device +// OpenRTB 2.5 +// 3.2.18 Object: Device // // This object provides information pertaining to the device through which the user is interacting. Device // information includes its hardware, platform, location, and carrier data. The device can refer to a mobile @@ -21,7 +22,7 @@ type Device struct { // object; recommended // Description: // Location of the device assumed to be the user’s current - // location defined by a Geo object (Section 3.2.12). + // location defined by a Geo object (Section 3.2.19). Geo *Geo `json:"geo,omitempty"` // Attribute: @@ -147,6 +148,14 @@ type Device struct { // Support for JavaScript, where 0 = no, 1 = yes. JS int8 `json:"js,omitempty"` + // Attribute: + // geofetch + // Type: + // integer + // Description: + // Indicates if the geolocation API will be available to JavaScript code running in the banner, where 0 = no, 1 = yes. + GeoFetch int8 `json:"geofetch,omitempty"` + // Attribute: // flashver // Type: @@ -172,12 +181,22 @@ type Device struct { // to indicate high bandwidth (e.g., video friendly vs. cellular). Carrier string `json:"carrier,omitempty"` + // Attribute: + // mccmnc + // Type: + // string + // Description: + // Mobile carrier as the concatenated MCC-MNC code (e.g., “310-005” identifies Verizon Wireless CDMA in the USA). + // Refer to https://en.wikipedia.org/wiki/Mobile_country_code for further examples. Note that the dash between + // the MCC and MNC parts is required to remove parsing ambiguity. + MCCMNC string `json:"mccmnc,omitempty"` + // Attribute: // connectiontype // Type: // integer // Description: - // Network connection type. Refer to List 5.18. + // Network connection type. Refer to List 5.22. Connectiontype int8 `json:"connectiontype,omitempty"` // Attribute: diff --git a/geo.go b/geo.go index 280195a..a71d32c 100644 --- a/geo.go +++ b/geo.go @@ -1,6 +1,6 @@ package openrtb -// 3.2.12 Object: Geo +// 3.2.19 Object: Geo // // This object encapsulates various methods for specifying a geographic location. When subordinate to a // Device object, it indicates the location of the device which can also be interpreted as the user’s current @@ -35,6 +35,33 @@ type Geo struct { // lat/lon. Refer to List 5.16. Type int8 `json:"type,omitempty"` + // Attribute: + // accuracy + // Type: + // integer + // Description: + // Estimated location accuracy in meters; recommended when lat/lon are specified + // and derived from a device’s location services (i.e., type = 1). Note that this is the accuracy as + // reported from the device. Consult OS specific documentation (e.g., Android, iOS) for exact interpretation. + Accuracy int32 `json:"accuracy,omitempty"` + + // Attribute: + // lastfix + // Type: + // integer + // Description: + // Number of seconds since this geolocation fix was established. Note that devices may cache location data + // across multiple fetches. Ideally, this value should be from the time the actual fix was taken. + LastFix int32 `json:"lastfix,omitempty"` + + // Attribute: + // ipservice + // Type: + // integer + // Description: + // Service or provider used to determine geolocation from IP address if applicable (i.e., type = 2). Refer to List 5.23. + IPService int8 `json:"ipservice,omitempty"` + // Attribute: // country // Type: diff --git a/openrtb_test.go b/openrtb_test.go index 7d6f7c3..e026325 100644 --- a/openrtb_test.go +++ b/openrtb_test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "testing" - "github.com/mxmCherry/openrtb" + "github.com/prebid/openrtb" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" diff --git a/raw_json_test.go b/raw_json_test.go index b06b24e..ab2c313 100644 --- a/raw_json_test.go +++ b/raw_json_test.go @@ -3,7 +3,7 @@ package openrtb_test import ( "encoding/json" - "github.com/mxmCherry/openrtb" + "github.com/prebid/openrtb" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" From 4abcf757715a1a5e13211dd6c67c8e21c73b4668 Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Sun, 7 May 2017 14:20:40 -0400 Subject: [PATCH 5/9] Update device and geo to openrtb 2.5 --- device.go | 6 +++--- geo.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/device.go b/device.go index 26750af..39e25d7 100644 --- a/device.go +++ b/device.go @@ -186,9 +186,9 @@ type Device struct { // Type: // string // Description: - // Mobile carrier as the concatenated MCC-MNC code (e.g., “310-005” identifies Verizon Wireless CDMA in the USA). - // Refer to https://en.wikipedia.org/wiki/Mobile_country_code for further examples. Note that the dash between - // the MCC and MNC parts is required to remove parsing ambiguity. + // Mobile carrier as the concatenated MCC-MNC code (e.g., “310-005” identifies Verizon Wireless CDMA in the USA). + // Refer to https://en.wikipedia.org/wiki/Mobile_country_code for further examples. Note that the dash between + // the MCC and MNC parts is required to remove parsing ambiguity. MCCMNC string `json:"mccmnc,omitempty"` // Attribute: diff --git a/geo.go b/geo.go index a71d32c..1e3bbde 100644 --- a/geo.go +++ b/geo.go @@ -41,8 +41,8 @@ type Geo struct { // integer // Description: // Estimated location accuracy in meters; recommended when lat/lon are specified - // and derived from a device’s location services (i.e., type = 1). Note that this is the accuracy as - // reported from the device. Consult OS specific documentation (e.g., Android, iOS) for exact interpretation. + // and derived from a device’s location services (i.e., type = 1). Note that this is the accuracy as + // reported from the device. Consult OS specific documentation (e.g., Android, iOS) for exact interpretation. Accuracy int32 `json:"accuracy,omitempty"` // Attribute: @@ -50,8 +50,8 @@ type Geo struct { // Type: // integer // Description: - // Number of seconds since this geolocation fix was established. Note that devices may cache location data - // across multiple fetches. Ideally, this value should be from the time the actual fix was taken. + // Number of seconds since this geolocation fix was established. Note that devices may cache location data + // across multiple fetches. Ideally, this value should be from the time the actual fix was taken. LastFix int32 `json:"lastfix,omitempty"` // Attribute: @@ -59,7 +59,7 @@ type Geo struct { // Type: // integer // Description: - // Service or provider used to determine geolocation from IP address if applicable (i.e., type = 2). Refer to List 5.23. + // Service or provider used to determine geolocation from IP address if applicable (i.e., type = 2). Refer to List 5.23. IPService int8 `json:"ipservice,omitempty"` // Attribute: From c349c04bbbc41f37fc413d2d2eee43ede3f5ce46 Mon Sep 17 00:00:00 2001 From: Nicole Hedley Date: Thu, 19 Oct 2017 12:52:51 -0400 Subject: [PATCH 6/9] Width and height can be 0 so do not omitempty --- banner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/banner.go b/banner.go index 9c49bbc..67d63ee 100644 --- a/banner.go +++ b/banner.go @@ -22,7 +22,7 @@ type Banner struct { // Width of the impression in pixels. // If neither wmin nor wmax are specified, this value is an exact // width requirement. Otherwise it is a preferred width. - W uint64 `json:"w,omitempty"` + W uint64 `json:"w"` // Attribute: // h @@ -32,7 +32,7 @@ type Banner struct { // Height of the impression in pixels. // If neither hmin nor hmax are specified, this value is an exact // height requirement. Otherwise it is a preferred height. - H uint64 `json:"h,omitempty"` + H uint64 `json:"h"` // Attribute: // format From b14edb631c953db35fe464d1e944f83aa8304f40 Mon Sep 17 00:00:00 2001 From: Nicole Hedley Date: Thu, 19 Oct 2017 13:10:32 -0400 Subject: [PATCH 7/9] Get rid of extra differences between fork and upstream --- banner.go | 14 +++++++------- format.go | 1 - geo.go | 27 --------------------------- openrtb_test.go | 2 +- raw_json_test.go | 2 +- source.go | 1 - 6 files changed, 9 insertions(+), 38 deletions(-) diff --git a/banner.go b/banner.go index 365bf92..0a9a538 100644 --- a/banner.go +++ b/banner.go @@ -39,13 +39,13 @@ type Banner struct { // recommended if no format objects are specified. H uint64 `json:"h"` - // Attribute: - // format - // Type: - // array of formats - // Description: - // Creative sizes allowed by this tag. Overrides h and w if provided - Format []Format `json:"format,omitempty"` + // Attribute: + // format + // Type: + // array of formats + // Description: + // Creative sizes allowed by this tag. Overrides h and w if provided + Format []Format `json:"format,omitempty"` // Attribute: // wmax diff --git a/format.go b/format.go index 5f4459f..cafd08e 100644 --- a/format.go +++ b/format.go @@ -2,7 +2,6 @@ package openrtb // 3.2.10 Object: Format // - // This object represents an allowed size (i.e., height and width combination) or Flex Ad parameters for a banner impression. // These are typically used in an array where multiple sizes are permitted. // It is recommended that either the w/h pair or the wratio/hratio/wmin set (i.e., for Flex Ads) be specified. diff --git a/geo.go b/geo.go index d75c657..63afe1b 100644 --- a/geo.go +++ b/geo.go @@ -68,33 +68,6 @@ type Geo struct { // address if applicable (i.e., type = 2). Refer to List 5.23. IPService IPLocationService `json:"ipservice,omitempty"` - // Attribute: - // accuracy - // Type: - // integer - // Description: - // Estimated location accuracy in meters; recommended when lat/lon are specified - // and derived from a device’s location services (i.e., type = 1). Note that this is the accuracy as - // reported from the device. Consult OS specific documentation (e.g., Android, iOS) for exact interpretation. - Accuracy int32 `json:"accuracy,omitempty"` - - // Attribute: - // lastfix - // Type: - // integer - // Description: - // Number of seconds since this geolocation fix was established. Note that devices may cache location data - // across multiple fetches. Ideally, this value should be from the time the actual fix was taken. - LastFix int32 `json:"lastfix,omitempty"` - - // Attribute: - // ipservice - // Type: - // integer - // Description: - // Service or provider used to determine geolocation from IP address if applicable (i.e., type = 2). Refer to List 5.23. - IPService int8 `json:"ipservice,omitempty"` - // Attribute: // country // Type: diff --git a/openrtb_test.go b/openrtb_test.go index e026325..7d6f7c3 100644 --- a/openrtb_test.go +++ b/openrtb_test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "testing" - "github.com/prebid/openrtb" + "github.com/mxmCherry/openrtb" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" diff --git a/raw_json_test.go b/raw_json_test.go index ab2c313..b06b24e 100644 --- a/raw_json_test.go +++ b/raw_json_test.go @@ -3,7 +3,7 @@ package openrtb_test import ( "encoding/json" - "github.com/prebid/openrtb" + "github.com/mxmCherry/openrtb" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/source.go b/source.go index a58c351..89211e7 100644 --- a/source.go +++ b/source.go @@ -2,7 +2,6 @@ package openrtb // 3.2.2 Object: Source // - // This object describes the nature and behavior of the entity that is the source of the bid request upstream from the exchange. // The primary purpose of this object is to define post-auction or upstream decisioning when the exchange itself does not control the final decision. // A common example of this is header bidding, but it can also apply to upstream server entities such as another RTB exchange, a mediation platform, or an ad server combines direct campaigns with 3rd party demand in decisioning. From 8e66d6428e61544dc34150508c871ad2724ab8d0 Mon Sep 17 00:00:00 2001 From: Nicole Hedley Date: Thu, 19 Oct 2017 13:11:37 -0400 Subject: [PATCH 8/9] Also remove format --- banner.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/banner.go b/banner.go index 0a9a538..df93c5d 100644 --- a/banner.go +++ b/banner.go @@ -39,14 +39,6 @@ type Banner struct { // recommended if no format objects are specified. H uint64 `json:"h"` - // Attribute: - // format - // Type: - // array of formats - // Description: - // Creative sizes allowed by this tag. Overrides h and w if provided - Format []Format `json:"format,omitempty"` - // Attribute: // wmax // Type: From daf9ad5605ad254c21f6ac4f450df6f4f1ba1500 Mon Sep 17 00:00:00 2001 From: Nicole Hedley Date: Thu, 19 Oct 2017 13:21:23 -0400 Subject: [PATCH 9/9] Add unit test case for instl : 1 with width and height = 0 --- testdata/bid-request-mobile.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/testdata/bid-request-mobile.json b/testdata/bid-request-mobile.json index 898d7bd..725fe35 100644 --- a/testdata/bid-request-mobile.json +++ b/testdata/bid-request-mobile.json @@ -32,6 +32,26 @@ 3 ] } + }, + { + "id": "2", + "bidfloor": 0.5, + "tagid": "agltb3B1Yi1pbmNyDQsSBFNpdGUY7fD0FAwa", + "instl":1, + "banner": { + "w": 0, + "h": 0, + "pos": 2, + "btype": [ + 4 + ], + "battr": [ + 14 + ], + "api": [ + 3 + ] + } } ], "app": {