diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..11209c8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +name: release.yml +on: + release: + types: + - created + pull_request: + types: + - opened + - reopened + - synchronize + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [ 1.18.x, 1.19.x ] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Golang + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + + - name: Generate msgpack files + run: make generate-msgp diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 18ff30b..e5293a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,10 @@ jobs: with: go-version: ${{ matrix.go-version }} cache: true + + - name: Generate msgpack files + run: make generate-msgp + - run: make test golangci: runs-on: ubuntu-latest @@ -27,6 +31,10 @@ jobs: with: go-version: 1.x cache: true + + - name: Generate msgpack files + run: make generate-msgp + - uses: golangci/golangci-lint-action@v3 with: version: latest diff --git a/.gitignore b/.gitignore index 6aa8b3a..83739c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,9 @@ *.makefile + +.deps +*_gen.go +*_gen_test.go +#native/request/*_gen.go +#native/request/*_gen_test.go +#native/reponse/*_gen.go +#native/reponse/*_gen_test.go diff --git a/Makefile b/Makefile index bdffdab..c8cb4e8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,22 @@ default: test +DEPENDENCIES_FOLDER := .deps +MSGP_BIN := msgp +MSGP_VERSION := v1.3.0 +MSGP := $(DEPENDENCIES_FOLDER)/$(MSGP_BIN)_$(MSGP_VERSION) + + .minimal.makefile: curl -fsSL -o $@ https://gitlab.com/bsm/misc/raw/master/make/go/minimal.makefile include .minimal.makefile + + +$(MSGP): + GOBIN=$(PWD)/$(DEPENDENCIES_FOLDER) go install github.com/tinylib/msgp@$(MSGP_VERSION) + $(call clean_tool,$(MSGP_BIN),$@) + + +.PHONY: generate-msgp ## Generate mocks +generate-msgp:$(MSGP) + go generate ./... diff --git a/audio.go b/audio.go index b446681..cd015cc 100644 --- a/audio.go +++ b/audio.go @@ -1,8 +1,8 @@ package openrtb import ( - "encoding/json" "errors" + "github.com/tinylib/msgp/msgp" "github.com/bytedance/sonic" ) @@ -12,27 +12,29 @@ var ( ErrInvalidAudioNoMIMEs = errors.New("openrtb: audio has no mimes") ) +//go:generate .deps/msgp + // 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 - MaxDuration int `json:"maxduration,omitempty"` // Maximum video ad duration in seconds - Protocols []Protocol `json:"protocols,omitempty"` // Video bid response protocols - StartDelay StartDelay `json:"startdelay,omitempty"` // Indicates the start delay in seconds - Sequence int `json:"sequence,omitempty"` // Default: 1 - BlockedAttrs []CreativeAttribute `json:"battr,omitempty"` // Blocked creative attributes - MaxExtended int `json:"maxextended,omitempty"` // Maximum extended video ad duration - MinBitrate int `json:"minbitrate,omitempty"` // Minimum bit rate in Kbps - MaxBitrate int `json:"maxbitrate,omitempty"` // Maximum bit rate in Kbps - Delivery []ContentDelivery `json:"delivery,omitempty"` // List of supported delivery methods - CompanionAds []Banner `json:"companionad,omitempty"` - APIs []APIFramework `json:"api,omitempty"` - CompanionTypes []CompanionType `json:"companiontype,omitempty"` - MaxSequence int `json:"maxseq,omitempty"` // The maximumnumber of ads that canbe played in an ad pod. - Feed FeedType `json:"feed,omitempty"` // Type of audio feed. - Stitched int `json:"stitched,omitempty"` // Indicates if the ad is stitched with audio content or delivered independently - VolumeNorm VolumeNorm `json:"nvol,omitempty"` // Volume normalization mode. - Ext json.RawMessage `json:"ext,omitempty"` + MIMEs []string `json:"mimes" msgp:"mimes"` // Content MIME types supported. + MinDuration int `json:"minduration,omitempty" msgp:"minduration,omitempty"` // Minimum video ad duration in seconds + MaxDuration int `json:"maxduration,omitempty" msgp:"maxduration,omitempty"` // Maximum video ad duration in seconds + Protocols []Protocol `json:"protocols,omitempty" msgp:"protocols,omitempty"` // Video bid response protocols + StartDelay StartDelay `json:"startdelay,omitempty" msgp:"startdelay,omitempty"` // Indicates the start delay in seconds + Sequence int `json:"sequence,omitempty" msgp:"sequence,omitempty"` // Default: 1 + BlockedAttrs []CreativeAttribute `json:"battr,omitempty" msgp:"battr,omitempty"` // Blocked creative attributes + MaxExtended int `json:"maxextended,omitempty" msgp:"maxextended,omitempty"` // Maximum extended video ad duration + MinBitrate int `json:"minbitrate,omitempty" msgp:"minbitrate,omitempty"` // Minimum bit rate in Kbps + MaxBitrate int `json:"maxbitrate,omitempty" msgp:"maxbitrate,omitempty"` // Maximum bit rate in Kbps + Delivery []ContentDelivery `json:"delivery,omitempty" msgp:"delivery,omitempty"` // List of supported delivery methods + CompanionAds []Banner `json:"companionad,omitempty" msgp:"companionad,omitempty"` + APIs []APIFramework `json:"api,omitempty" msgp:"api,omitempty"` + CompanionTypes []CompanionType `json:"companiontype,omitempty" msgp:"companiontype,omitempty"` + MaxSequence int `json:"maxseq,omitempty" msgp:"maxseq,omitempty"` // The maximumnumber of ads that canbe played in an ad pod. + Feed FeedType `json:"feed,omitempty" msgp:"feed,omitempty"` // Type of audio feed. + Stitched int `json:"stitched,omitempty" msgp:"stitched,omitempty"` // Indicates if the ad is stitched with audio content or delivered independently + VolumeNorm VolumeNorm `json:"nvol,omitempty" msgp:"nvol,omitempty"` // Volume normalization mode. + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } type jsonAudio Audio diff --git a/banner.go b/banner.go index 0b8fc98..2b7c8c1 100644 --- a/banner.go +++ b/banner.go @@ -1,6 +1,8 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) // 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 @@ -8,22 +10,25 @@ import "encoding/json" // object may include a unique identifier; this can be useful if these IDs can be leveraged in the // VAST response to dictate placement of the companion creatives when multiple companion ad // opportunities of the same size are available on a page. + +//go:generate .deps/msgp + type Banner struct { - Width int `json:"w,omitempty"` // Width - Height int `json:"h,omitempty"` // Height - Formats []Format `json:"format,omitempty"` // Array of format objects representing the banner sizes permitted. - WidthMax int `json:"wmax,omitempty"` // Width maximum DEPRECATED - HeightMax int `json:"hmax,omitempty"` // Height maximum DEPRECATED - WidthMin int `json:"wmin,omitempty"` // Width minimum DEPRECATED - HeightMin int `json:"hmin,omitempty"` // Height minimum DEPRECATED - ID string `json:"id,omitempty"` // A unique identifier - BlockedTypes []BannerType `json:"btype,omitempty"` // Blocked banner types - BlockedAttrs []CreativeAttribute `json:"battr,omitempty"` // Blocked creative attributes - Position AdPosition `json:"pos,omitempty"` // Ad Position - MIMEs []string `json:"mimes,omitempty"` // Whitelist of content MIME types supported - TopFrame int `json:"topframe,omitempty"` // Default: 0 ("1": Delivered in top frame, "0": Elsewhere) - ExpDirs []ExpDir `json:"expdir,omitempty"` // Specify properties for an expandable ad - APIs []APIFramework `json:"api,omitempty"` // List of supported API frameworks - VCM int `json:"vcm,omitempty"` // Represents the relationship with video. 0 = concurrent, 1 = end-card - Ext json.RawMessage `json:"ext,omitempty"` + Width int `json:"w,omitempty" msgp:"w,omitempty"` // Width + Height int `json:"h,omitempty" msgp:"h,omitempty"` // Height + Formats []Format `json:"format,omitempty" msgp:"format,omitempty"` // Array of format objects representing the banner sizes permitted. + WidthMax int `json:"wmax,omitempty" msgp:"wmax,omitempty"` // Width maximum DEPRECATED + HeightMax int `json:"hmax,omitempty" msgp:"hmax,omitempty"` // Height maximum DEPRECATED + WidthMin int `json:"wmin,omitempty" msgp:"wmin,omitempty"` // Width minimum DEPRECATED + HeightMin int `json:"hmin,omitempty" msgp:"hmin,omitempty"` // Height minimum DEPRECATED + ID string `json:"id,omitempty" msgp:"id,omitempty"` // A unique identifier + BlockedTypes []BannerType `json:"btype,omitempty" msgp:"btype,omitempty"` // Blocked banner types + BlockedAttrs []CreativeAttribute `json:"battr,omitempty" msgp:"battr,omitempty"` // Blocked creative attributes + Position AdPosition `json:"pos,omitempty" msgp:"pos,omitempty"` // Ad Position + MIMEs []string `json:"mimes,omitempty" msgp:"mimes,omitempty"` // Whitelist of content MIME types supported + TopFrame int `json:"topframe,omitempty" msgp:"topframe,omitempty"` // Default: 0 ("1": Delivered in top frame, "0": Elsewhere) + ExpDirs []ExpDir `json:"expdir,omitempty" msgp:"expdir,omitempty"` // Specify properties for an expandable ad + APIs []APIFramework `json:"api,omitempty" msgp:"api,omitempty"` // List of supported API frameworks + VCM int `json:"vcm,omitempty" msgp:"vcm,omitempty"` // Represents the relationship with video. 0 = concurrent, 1 = end-card + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } diff --git a/content.go b/content.go index d4b8d0d..d9126da 100644 --- a/content.go +++ b/content.go @@ -1,6 +1,10 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) + +//go:generate .deps/msgp // Content object describes the content in which the impression will appear, which may be syndicated or nonsyndicated // content. This object may be useful when syndicated content contains impressions and does @@ -8,35 +12,35 @@ import "encoding/json" // knowledge of the page where the content is running, as a result of the syndication method. For // example might be a video impression embedded in an iframe on an unknown web property or device. type Content struct { - ID string `json:"id,omitempty"` // ID uniquely identifying the content. - Episode int `json:"episode,omitempty"` // Episode number (typically applies to video content). - Title string `json:"title,omitempty"` // Content title. - Series string `json:"series,omitempty"` // Content series. - Season string `json:"season,omitempty"` // Content season. - Artist string `json:"artist,omitempty"` // Artist credited with the content. - Genre string `json:"genre,omitempty"` // Genre that best describes the content - Album string `json:"album,omitempty"` // Album to which the content belongs; typically for audio. - ISRC string `json:"isrc,omitempty"` // International Standard Recording Code conforming to ISO - 3901. - Producer *Producer `json:"producer,omitempty"` // The producer. - URL string `json:"url,omitempty"` // URL of the content, for buy-side contextualization or review. - CategoryTaxonomy CategoryTaxonomy `json:"cattax,omitempty"` // Defines the taxonomy in use. - Categories []ContentCategory `json:"cat,omitempty"` // Array of IAB content categories that describe the content. - ProductionQuality ProductionQuality `json:"prodq,omitempty"` // Production quality per IAB's classification. - VideoQuality ProductionQuality `json:"videoquality,omitempty"` // DEPRECATED. Video quality per IAB's classification. - Context ContentContext `json:"context,omitempty"` // Type of content (game, video, text, etc.). - ContentRating string `json:"contentrating,omitempty"` // Content rating (e.g., MPAA). - UserRating string `json:"userrating,omitempty"` // User rating of the content (e.g., number of stars, likes, etc.). - MediaRating IQGRating `json:"qagmediarating,omitempty"` // Media rating per QAG guidelines. - Keywords string `json:"keywords,omitempty"` // Comma separated list of keywords describing the content. - LiveStream int `json:"livestream,omitempty"` // 0 = not live, 1 = content is live (e.g., stream, live blog). - SourceRelationship int `json:"sourcerelationship,omitempty"` // 0 = indirect, 1 = direct. - Length int `json:"len,omitempty"` // Length of content in seconds; appropriate for video or audio. - Language string `json:"language,omitempty"` // Content language using ISO-639-1-alpha-2. - LanguageB string `json:"langb,omitempty"` // Content language using IETF BCP 47. Only one of language or langb should be present. - Embeddable int `json:"embeddable,omitempty"` // Indicator of whether or not the content is embeddable (e.g., an embeddable video player), where 0 = no, 1 = yes. - Data []Data `json:"data,omitempty"` // Additional content data. - Network *ChannelEntity `json:"network,omitempty"` // Details about the network the content is on. - Channel *ChannelEntity `json:"channel,omitempty"` // Details about the channel the content is on. - KwArray []string `json:"kwarray,omitempty"` // Array of keywords about the site. Only one of ‘keywords’ or‘kwarray’ may be present. - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` // ID uniquely identifying the content. + Episode int `json:"episode,omitempty" msgp:"episode,omitempty"` // Episode number (typically applies to video content). + Title string `json:"title,omitempty" msgp:"title,omitempty"` // Content title. + Series string `json:"series,omitempty" msgp:"series,omitempty"` // Content series. + Season string `json:"season,omitempty" msgp:"season,omitempty"` // Content season. + Artist string `json:"artist,omitempty" msgp:"artist,omitempty"` // Artist credited with the content. + Genre string `json:"genre,omitempty" msgp:"genre,omitempty"` // Genre that best describes the content + Album string `json:"album,omitempty" msgp:"album,omitempty"` // Album to which the content belongs; typically for audio. + ISRC string `json:"isrc,omitempty" msgp:"isrc,omitempty"` // International Standard Recording Code conforming to ISO - 3901. + Producer *Producer `json:"producer,omitempty" msgp:"producer,omitempty"` // The producer. + URL string `json:"url,omitempty" msgp:"url,omitempty"` // URL of the content, for buy-side contextualization or review. + CategoryTaxonomy CategoryTaxonomy `json:"cattax,omitempty" msgp:"cattax,omitempty"` // Defines the taxonomy in use. + Categories []ContentCategory `json:"cat,omitempty" msgp:"cat,omitempty"` // Array of IAB content categories that describe the content. + ProductionQuality ProductionQuality `json:"prodq,omitempty" msgp:"prodq,omitempty"` // Production quality per IAB's classification. + VideoQuality ProductionQuality `json:"videoquality,omitempty" msgp:"videoquality,omitempty"` // DEPRECATED. Video quality per IAB's classification. + Context ContentContext `json:"context,omitempty" msgp:"context,omitempty"` // Type of content (game, video, text, etc.). + ContentRating string `json:"contentrating,omitempty" msgp:"contentrating,omitempty"` // Content rating (e.g., MPAA). + UserRating string `json:"userrating,omitempty" msgp:"userrating,omitempty"` // User rating of the content (e.g., number of stars, likes, etc.). + MediaRating IQGRating `json:"qagmediarating,omitempty" msgp:"qagmediarating,omitempty"` // Media rating per QAG guidelines. + Keywords string `json:"keywords,omitempty" msgp:"keywords,omitempty"` // Comma separated list of keywords describing the content. + LiveStream int `json:"livestream,omitempty" msgp:"livestream,omitempty"` // 0 = not live, 1 = content is live (e.g., stream, live blog). + SourceRelationship int `json:"sourcerelationship,omitempty" msgp:"sourcerelationship,omitempty"` // 0 = indirect, 1 = direct. + Length int `json:"len,omitempty" msgp:"len,omitempty"` // Length of content in seconds; appropriate for video or audio. + Language string `json:"language,omitempty" msgp:"language,omitempty"` // Content language using ISO-639-1-alpha-2. + LanguageB string `json:"langb,omitempty" msgp:"langb,omitempty"` // Content language using IETF BCP 47. Only one of language or langb should be present. + Embeddable int `json:"embeddable,omitempty" msgp:"embeddable,omitempty"` // Indicator of whether or not the content is embeddable (e.g., an embeddable video player), where 0 = no, 1 = yes. + Data []Data `json:"data,omitempty" msgp:"data,omitempty"` // Additional content data. + Network *ChannelEntity `json:"network,omitempty" msgp:"network,omitempty"` // Details about the network the content is on. + Channel *ChannelEntity `json:"channel,omitempty" msgp:"channel,omitempty"` // Details about the channel the content is on. + KwArray []string `json:"kwarray,omitempty" msgp:"kwarray,omitempty"` // Array of keywords about the site. Only one of ‘keywords’ or‘kwarray’ may be present. + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } diff --git a/device.go b/device.go index 485925a..13b043e 100644 --- a/device.go +++ b/device.go @@ -1,42 +1,47 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) // Device object provides information pertaining to the device including its hardware, // platform, location, and carrier. This device can refer to a mobile handset, a desktop computer, // set top box or other digital device. + +//go:generate .deps/msgp + type Device struct { - UA string `json:"ua,omitempty"` // User agent - Sua *UserAgent `json:"sua,omitempty"` // Structured User agent. It's more accurate than UA - Geo *Geo `json:"geo,omitempty"` // Location of the device assumed to be the user’s current location - DNT int `json:"dnt,omitempty"` // "1": Do not track - LMT int `json:"lmt,omitempty"` // "1": Limit Ad Tracking - IP string `json:"ip,omitempty"` // IPv4 - IPv6 string `json:"ipv6,omitempty"` // IPv6 - DeviceType DeviceType `json:"devicetype,omitempty"` // The general type of device. - Make string `json:"make,omitempty"` // Device make - Model string `json:"model,omitempty"` // Device model - OS string `json:"os,omitempty"` // Device OS - OSVersion string `json:"osv,omitempty"` // Device OS version - HWVersion string `json:"hwv,omitempty"` // Hardware version of the device (e.g., "5S" for iPhone 5S). - Height int `json:"h,omitempty"` // Physical height of the screen in pixels. - Width int `json:"w,omitempty"` // Physical width of the screen in pixels. - PPI int `json:"ppi,omitempty"` // Screen size as pixels per linear inch. - PixelRatio float64 `json:"pxratio,omitempty"` // The ratio of physical pixels to device independent pixels. - JS int `json:"js,omitempty"` // Javascript status ("0": Disabled, "1": Enabled) - GeoFetch int `json:"geofetch,omitempty"` // Indicates if the geolocation API will be available to JavaScript code running in the banner, - FlashVersion string `json:"flashver,omitempty"` // Flash version - Language string `json:"language,omitempty"` // Browser language using ISO-639-1-alpha-2. Only one of language or langb should be present. - LanguageB string `json:"langb,omitempty"` // Browser language using IETF BCP 47. Only one of language or langb should be present. - Carrier string `json:"carrier,omitempty"` // Carrier or ISP derived from the IP address - MCCMNC string `json:"mccmnc,omitempty"` // Mobile carrier as the concatenated MCC-MNC code (e.g., "310-005" identifies Verizon Wireless CDMA in the USA). - ConnType ConnType `json:"connectiontype,omitempty"` // Network connection type. - IFA string `json:"ifa,omitempty"` // Native identifier for advertisers - IDSHA1 string `json:"didsha1,omitempty"` // SHA1 hashed device ID - IDMD5 string `json:"didmd5,omitempty"` // MD5 hashed device ID - PIDSHA1 string `json:"dpidsha1,omitempty"` // SHA1 hashed platform device ID - PIDMD5 string `json:"dpidmd5,omitempty"` // MD5 hashed platform device ID - MacSHA1 string `json:"macsha1,omitempty"` // SHA1 hashed device ID; IMEI when available, else MEID or ESN - MacMD5 string `json:"macmd5,omitempty"` // MD5 hashed device ID; IMEI when available, else MEID or ESN - Ext json.RawMessage `json:"ext,omitempty"` + UA string `json:"ua,omitempty" msgp:"ua,omitempty"` // User agent + Sua *UserAgent `json:"sua,omitempty" msgp:"sua,omitempty"` // Structured User agent. It's more accurate than UA + Geo *Geo `json:"geo,omitempty" msgp:"geo,omitempty"` // Location of the device assumed to be the user’s current location + DNT int `json:"dnt,omitempty" msgp:"dnt,omitempty"` // "1": Do not track + LMT int `json:"lmt,omitempty" msgp:"lmt,omitempty"` // "1": Limit Ad Tracking + IP string `json:"ip,omitempty" msgp:"ip,omitempty"` // IPv4 + IPv6 string `json:"ipv6,omitempty" msgp:"ipv6,omitempty"` // IPv6 + DeviceType DeviceType `json:"devicetype,omitempty" msgp:"devicetype,omitempty"` // The general type of device. + Make string `json:"make,omitempty" msgp:"make,omitempty"` // Device make + Model string `json:"model,omitempty" msgp:"model,omitempty"` // Device model + OS string `json:"os,omitempty" msgp:"os,omitempty"` // Device OS + OSVersion string `json:"osv,omitempty" msgp:"osv,omitempty"` // Device OS version + HWVersion string `json:"hwv,omitempty" msgp:"hwv,omitempty"` // Hardware version of the device (e.g., "5S" for iPhone 5S). + Height int `json:"h,omitempty" msgp:"h,omitempty"` // Physical height of the screen in pixels. + Width int `json:"w,omitempty" msgp:"w,omitempty"` // Physical width of the screen in pixels. + PPI int `json:"ppi,omitempty" msgp:"ppi,omitempty"` // Screen size as pixels per linear inch. + PixelRatio float64 `json:"pxratio,omitempty" msgp:"pxratio,omitempty"` // The ratio of physical pixels to device independent pixels. + JS int `json:"js,omitempty" msgp:"js,omitempty"` // Javascript status ("0": Disabled, "1": Enabled) + GeoFetch int `json:"geofetch,omitempty" msgp:"geofetch,omitempty"` // Indicates if the geolocation API will be available to JavaScript code running in the banner, + FlashVersion string `json:"flashver,omitempty" msgp:"flashver,omitempty"` // Flash version + Language string `json:"language,omitempty" msgp:"language,omitempty"` // Browser language using ISO-639-1-alpha-2. Only one of language or langb should be present. + LanguageB string `json:"langb,omitempty" msgp:"langb,omitempty"` // Browser language using IETF BCP 47. Only one of language or langb should be present. + Carrier string `json:"carrier,omitempty" msgp:"carrier,omitempty"` // Carrier or ISP derived from the IP address + MCCMNC string `json:"mccmnc,omitempty" msgp:"mccmnc,omitempty"` // Mobile carrier as the concatenated MCC-MNC code (e.g., "310-005" identifies Verizon Wireless CDMA in the USA). + ConnType ConnType `json:"connectiontype,omitempty" msgp:"connectiontype,omitempty"` // Network connection type. + IFA string `json:"ifa,omitempty" msgp:"ifa,omitempty"` // Native identifier for advertisers + IDSHA1 string `json:"didsha1,omitempty" msgp:"didsha1,omitempty"` // SHA1 hashed device ID + IDMD5 string `json:"didmd5,omitempty" msgp:"didmd5,omitempty"` // MD5 hashed device ID + PIDSHA1 string `json:"dpidsha1,omitempty" msgp:"dpidsha1,omitempty"` // SHA1 hashed platform device ID + PIDMD5 string `json:"dpidmd5,omitempty" msgp:"dpidmd5,omitempty"` // MD5 hashed platform device ID + MacSHA1 string `json:"macsha1,omitempty" msgp:"macsha1,omitempty"` // SHA1 hashed device ID; IMEI when available, else MEID or ESN + MacMD5 string `json:"macmd5,omitempty" msgp:"macmd5,omitempty"` // MD5 hashed device ID; IMEI when available, else MEID or ESN + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } diff --git a/go.mod b/go.mod index 9b4ae80..cf6211d 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/bsm/openrtb/v3 go 1.13 -require github.com/bytedance/sonic v1.12.3 +require ( + github.com/bytedance/sonic v1.12.3 + github.com/tinylib/msgp v1.3.0 +) diff --git a/go.sum b/go.sum index 45ac0b7..937e58b 100644 --- a/go.sum +++ b/go.sum @@ -10,9 +10,12 @@ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY= +github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -23,10 +26,78 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww= +github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= +golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/impression.go b/impression.go index 93e6be8..1489fdb 100644 --- a/impression.go +++ b/impression.go @@ -1,10 +1,12 @@ package openrtb import ( - "encoding/json" "errors" + "github.com/tinylib/msgp/msgp" ) +//go:generate .deps/msgp + // Validation errors var ( ErrInvalidImpNoID = errors.New("openrtb: impression ID missing") @@ -19,25 +21,25 @@ var ( // The presence of Banner, Video, and/or Native objects // subordinate to the Imp object indicates the type of impression being offered. type Impression struct { - ID string `json:"id"` // A unique identifier for this impression - Banner *Banner `json:"banner,omitempty"` - Video *Video `json:"video,omitempty"` - Audio *Audio `json:"audio,omitempty"` - Native *Native `json:"native,omitempty"` - PMP *PMP `json:"pmp,omitempty"` // A reference to the PMP object containing any Deals eligible for the impression object. - DisplayManager string `json:"displaymanager,omitempty"` // Name of ad mediation partner, SDK technology, etc - DisplayManagerVersion string `json:"displaymanagerver,omitempty"` // Version of the above - Interstitial int `json:"instl,omitempty"` // Interstitial, Default: 0 ("1": Interstitial, "0": Something else) - TagID string `json:"tagid,omitempty"` // IDentifier for specific ad placement or ad tag - BidFloor float64 `json:"bidfloor,omitempty"` // Bid floor for this impression in CPM - BidFloorCurrency string `json:"bidfloorcur,omitempty"` // Currency of bid floor - Secure NumberOrString `json:"secure,omitempty"` // Flag to indicate whether the impression requires secure HTTPS URL creative assets and markup. - Quantity *Quantity `json:"qty,omitempty"` // Includes the impression multiplier, and describes its source. - Exp int `json:"exp,omitempty"` // Advisory as to the number of seconds that may elapse between the auction and the actual impression. - IFrameBusters []string `json:"iframebuster,omitempty"` // Array of names for supportediframe busters. - Rewarded int `json:"rwdd,omitempty"` // Impression is rewarded, Default: 0 ("1": yes, "0": no) - Metric []Metric `json:"metric,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id" msgp:"id"` // A unique identifier for this impression + Banner *Banner `json:"banner,omitempty" msgp:"banner,omitempty"` + Video *Video `json:"video,omitempty" msgp:"video,omitempty"` + Audio *Audio `json:"audio,omitempty" msgp:"audio,omitempty"` + Native *Native `json:"native,omitempty" msgp:"native,omitempty"` + PMP *PMP `json:"pmp,omitempty" msgp:"pmp,omitempty"` // A reference to the PMP object containing any Deals eligible for the impression object. + DisplayManager string `json:"displaymanager,omitempty" msgp:"displaymanager,omitempty"` // Name of ad mediation partner, SDK technology, etc + DisplayManagerVersion string `json:"displaymanagerver,omitempty" msgp:"displaymanagerver,omitempty"` // Version of the above + Interstitial int `json:"instl,omitempty" msgp:"instl,omitempty"` // Interstitial, Default: 0 ("1": Interstitial, "0": Something else) + TagID string `json:"tagid,omitempty" msgp:"tagid,omitempty"` // IDentifier for specific ad placement or ad tag + BidFloor float64 `json:"bidfloor,omitempty" msgp:"bidfloor,omitempty"` // Bid floor for this impression in CPM + BidFloorCurrency string `json:"bidfloorcur,omitempty" msgp:"bidfloorcur,omitempty"` // Currency of bid floor + Secure NumberOrString `json:"secure,omitempty" msgp:"secure,omitempty"` // Flag to indicate whether the impression requires secure HTTPS URL creative assets and markup. + Quantity *Quantity `json:"qty,omitempty" msgp:"qty,omitempty"` // Includes the impression multiplier, and describes its source. + Exp int `json:"exp,omitempty" msgp:"exp,omitempty"` // Advisory as to the number of seconds that may elapse between the auction and the actual impression. + IFrameBusters []string `json:"iframebuster,omitempty" msgp:"iframebuster,omitempty"` // Array of names for supportediframe busters. + Rewarded int `json:"rwdd,omitempty" msgp:"rwdd,omitempty"` // Impression is rewarded, Default: 0 ("1": yes, "0": no) + Metric []Metric `json:"metric,omitempty" msgp:"metric,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } func (imp *Impression) assetCount() int { diff --git a/inventory.go b/inventory.go index 29b33f9..1b38fba 100644 --- a/inventory.go +++ b/inventory.go @@ -1,20 +1,25 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) + +//go:generate .deps/msgp +//msgp:ignore Site // Inventory contains inventory specific attributes type Inventory struct { - ID string `json:"id,omitempty"` // ID on the exchange - Name string `json:"name,omitempty"` - Domain string `json:"domain,omitempty"` - Categories []ContentCategory `json:"cat,omitempty"` // Array of IAB content categories - SectionCategories []ContentCategory `json:"sectioncat,omitempty"` // Array of IAB content categories for subsection - PageCategories []ContentCategory `json:"pagecat,omitempty"` // Array of IAB content categories for page - PrivacyPolicy *int `json:"privacypolicy,omitempty"` // Default: 1 ("1": has a privacy policy) - Publisher *Publisher `json:"publisher,omitempty"` // Details about the Publisher - Content *Content `json:"content,omitempty"` // Details about the Content - Keywords string `json:"keywords,omitempty"` // Comma separated list of keywords about the site. - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` // ID on the exchange + Name string `json:"name,omitempty" msgp:"name,omitempty"` + Domain string `json:"domain,omitempty" msgp:"domain,omitempty"` + Categories []ContentCategory `json:"cat,omitempty" msgp:"cat,omitempty"` // Array of IAB content categories + SectionCategories []ContentCategory `json:"sectioncat,omitempty" msgp:"sectioncat,omitempty"` // Array of IAB content categories for subsection + PageCategories []ContentCategory `json:"pagecat,omitempty" msgp:"pagecat,omitempty"` // Array of IAB content categories for page + PrivacyPolicy *int `json:"privacypolicy,omitempty" msgp:"privacypolicy,omitempty"` // Default: 1 ("1": has a privacy policy) + Publisher *Publisher `json:"publisher,omitempty" msgp:"publisher,omitempty"` // Details about the Publisher + Content *Content `json:"content,omitempty" msgp:"content,omitempty"` // Details about the Content + Keywords string `json:"keywords,omitempty" msgp:"keywords,omitempty"` // Comma separated list of keywords about the site. + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // GetPrivacyPolicy returns the privacy policy value @@ -30,10 +35,10 @@ func (a *Inventory) GetPrivacyPolicy() int { // "site" object. type App struct { Inventory - Bundle string `json:"bundle,omitempty"` // App bundle or package name - StoreURL string `json:"storeurl,omitempty"` // App store URL for an installed app - Version string `json:"ver,omitempty"` // App version - Paid int `json:"paid,omitempty"` // "1": Paid, "2": Free + Bundle string `json:"bundle,omitempty" msgp:"bundle,omitempty"` // App bundle or package name + StoreURL string `json:"storeurl,omitempty" msgp:"storeurl,omitempty"` // App store URL for an installed app + Version string `json:"ver,omitempty" msgp:"ver,omitempty"` // App version + Paid int `json:"paid,omitempty" msgp:"paid,omitempty"` // "1": Paid, "2": Free } // Site object should be included if the ad supported content is part of a website (as opposed to diff --git a/metric.go b/metric.go index f6171c8..1edc1d5 100644 --- a/metric.go +++ b/metric.go @@ -1,6 +1,10 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) + +//go:generate .deps/msgp // 3.2.5 Object: Metric // @@ -16,7 +20,7 @@ type Metric struct { // Description: // Type of metric being presented using exchange curated string // names which should be published to bidders a priori. - Type string `json:"type"` + Type string `json:"type" msgp:"type"` // Attribute: // value @@ -25,7 +29,7 @@ type Metric struct { // Description: // Number representing the value of the metric. Probabilities // must be in the range 0.0 – 1.0. - Value float64 `json:"value,omitempty"` + Value float64 `json:"value,omitempty" msgp:"value,omitempty"` // Attribute: // vendor @@ -36,7 +40,7 @@ type Metric struct { // which should be published to bidders a priori. If the exchange // itself is the source versus a third party, “EXCHANGE” is // recommended. - Vendor string `json:"vendor,omitempty"` + Vendor string `json:"vendor,omitempty" msgp:"vendor,omitempty"` // Attribute: // ext @@ -44,5 +48,5 @@ type Metric struct { // object // Description: // Placeholder for exchange-specific extensions to OpenRTB. - Ext json.RawMessage `json:"ext,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } diff --git a/native.go b/native.go index 5192ea7..2cda1ac 100644 --- a/native.go +++ b/native.go @@ -1,6 +1,8 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) // Native object represents a native type impression. Native ad units are intended to blend seamlessly into // the surrounding content (e.g., a sponsored Twitter or Facebook post). As such, the response must be @@ -9,10 +11,12 @@ import "encoding/json" // a native type impression. At the publisher’s discretion, that same impression may also be offered as // banner and/or video by also including as Imp subordinates the Banner and/or Video objects, // respectively. However, any given bid for the impression must conform to one of the offered types. + +//go:generate .deps/msgp type Native struct { - Request json.RawMessage `json:"request"` // Request payload complying with the Native Ad Specification. - Version string `json:"ver,omitempty"` // Version of the Native Ad Specification to which request complies; highly recommended for efficient parsing. - APIs []APIFramework `json:"api,omitempty"` // List of supported API frameworks for this impression. - BlockedAttrs []CreativeAttribute `json:"battr,omitempty"` // Blocked creative attributes - Ext json.RawMessage `json:"ext,omitempty"` + Request msgp.Raw `json:"request" msgp:"request"` // Request payload complying with the Native Ad Specification. + Version string `json:"ver,omitempty" msgp:"ver,omitempty"` // Version of the Native Ad Specification to which request complies; highly recommended for efficient parsing. + APIs []APIFramework `json:"api,omitempty" msgp:"api,omitempty"` // List of supported API frameworks for this impression. + BlockedAttrs []CreativeAttribute `json:"battr,omitempty" msgp:"battr,omitempty"` // Blocked creative attributes + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } diff --git a/native_test.go b/native_test.go index 4ff6315..3fee6e4 100644 --- a/native_test.go +++ b/native_test.go @@ -1,7 +1,7 @@ package openrtb_test import ( - "encoding/json" + "github.com/tinylib/msgp/msgp" "reflect" "testing" @@ -15,7 +15,7 @@ func TestNative(t *testing.T) { } exp := &Native{ - Request: json.RawMessage(`"PAYLOAD"`), + Request: msgp.Raw(`"PAYLOAD"`), Version: "2", } if got := subject; !reflect.DeepEqual(exp, got) { diff --git a/numbers.go b/numbers.go index 61fbed3..30cbc94 100644 --- a/numbers.go +++ b/numbers.go @@ -6,6 +6,8 @@ import ( "github.com/bytedance/sonic" ) +//go:generate .deps/msgp + // NumberOrString attempts to fix OpenRTB incompatibilities // of exchanges. On decoding, it can handle numbers and strings. // On encoding, it will generate a number, as intended by the diff --git a/openrtb.go b/openrtb.go index 8601c25..3d46f3c 100644 --- a/openrtb.go +++ b/openrtb.go @@ -1,11 +1,13 @@ package openrtb import ( - "encoding/json" + "github.com/tinylib/msgp/msgp" "github.com/bytedance/sonic" ) +//go:generate .deps/msgp + // ContentCategory as defined in section 5.1 type ContentCategory string @@ -755,11 +757,11 @@ const ( // ThirdParty abstract attributes. type ThirdParty struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Categories []ContentCategory `json:"cat,omitempty"` // Array of IAB content categories - Domain string `json:"domain,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` + Name string `json:"name,omitempty" msgp:"name,omitempty"` + Categories []ContentCategory `json:"cat,omitempty" msgp:"cat,omitempty"` // Array of IAB content categories + Domain string `json:"domain,omitempty" msgp:"domain,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // Publisher object itself and all of its parameters are optional, so default values are not @@ -777,20 +779,20 @@ type Producer ThirdParty // (such as IP geo lookup), or by user registration information (for example provided to a publisher // through a user registration). type Geo struct { - Latitude float64 `json:"lat,omitempty"` // Latitude from -90 to 90 - Longitude float64 `json:"lon,omitempty"` // Longitude from -180 to 180 - Type LocationType `json:"type,omitempty"` // Indicate the source of the geo data - Accuracy int `json:"accuracy,omitempty"` // Estimated location accuracy in meters; recommended when lat/lon are specified and derived from a device’s location services - LastFix int `json:"lastfix,omitempty"` // Number of seconds since this geolocation fix was established. - IPService IPLocation `json:"ipservice,omitempty"` // Service or provider used to determine geolocation from IP address if applicable - Country string `json:"country,omitempty"` // Country using ISO 3166-1 Alpha 3 - Region string `json:"region,omitempty"` // Region using ISO 3166-2 - RegionFIPS104 string `json:"regionFIPS104,omitempty"` // Region of a country using FIPS 10-4 - Metro string `json:"metro,omitempty"` - City string `json:"city,omitempty"` - ZIP string `json:"zip,omitempty"` - UTCOffset int `json:"utcoffset,omitempty"` // Local time as the number +/- of minutes from UTC - Ext json.RawMessage `json:"ext,omitempty"` + Latitude float64 `json:"lat,omitempty" msgp:"lat,omitempty"` // Latitude from -90 to 90 + Longitude float64 `json:"lon,omitempty" msgp:"lon,omitempty"` // Longitude from -180 to 180 + Type LocationType `json:"type,omitempty" msgp:"type,omitempty"` // Indicate the source of the geo data + Accuracy int `json:"accuracy,omitempty" msgp:"accuracy,omitempty"` // Estimated location accuracy in meters; recommended when lat/lon are specified and derived from a device’s location services + LastFix int `json:"lastfix,omitempty" msgp:"lastfix,omitempty"` // Number of seconds since this geolocation fix was established. + IPService IPLocation `json:"ipservice,omitempty" msgp:"ipservice,omitempty"` // Service or provider used to determine geolocation from IP address if applicable + Country string `json:"country,omitempty" msgp:"country,omitempty"` // Country using ISO 3166-1 Alpha 3 + Region string `json:"region,omitempty" msgp:"region,omitempty"` // Region using ISO 3166-2 + RegionFIPS104 string `json:"regionFIPS104,omitempty" msgp:"regionFIPS104,omitempty"` // Region of a country using FIPS 10-4 + Metro string `json:"metro,omitempty" msgp:"metro,omitempty"` + City string `json:"city,omitempty" msgp:"city,omitempty"` + ZIP string `json:"zip,omitempty" msgp:"zip,omitempty"` + UTCOffset int `json:"utcoffset,omitempty" msgp:"utcoffset,omitempty"` // Local time as the number +/- of minutes from UTC + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // User object contains information known or derived about the human user of the device (i.e., the @@ -798,16 +800,16 @@ type Geo struct { // privacy policies. However, this user ID must be stable long enough to serve reasonably as the basis for // frequency capping and retargeting. type User struct { - ID string `json:"id,omitempty"` // Unique consumer ID of this user on the exchange - BuyerID string `json:"buyerid,omitempty"` // Buyer-specific ID for the user as mapped by the exchange for the buyer. At least one of buyeruid/buyerid or id is recommended. Valid for OpenRTB 2.3. - BuyerUID string `json:"buyeruid,omitempty"` // Buyer-specific ID for the user as mapped by the exchange for the buyer. Same as BuyerID but valid for OpenRTB 2.2. - YearOfBirth int `json:"yob,omitempty"` // Year of birth as a 4-digit integer. - Gender string `json:"gender,omitempty"` // Gender ("M": male, "F" female, "O" Other) - Keywords string `json:"keywords,omitempty"` // Comma separated list of keywords, interests, or intent - CustomData string `json:"customdata,omitempty"` // Optional feature to pass bidder data that was set in the exchange's cookie. The string must be in base85 cookie safe characters and be in any format. Proper JSON encoding must be used to include "escaped" quotation marks. - Geo *Geo `json:"geo,omitempty"` - Data []Data `json:"data,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` // Unique consumer ID of this user on the exchange + BuyerID string `json:"buyerid,omitempty" msgp:"buyerid,omitempty"` // Buyer-specific ID for the user as mapped by the exchange for the buyer. At least one of buyeruid/buyerid or id is recommended. Valid for OpenRTB 2.3. + BuyerUID string `json:"buyeruid,omitempty" msgp:"buyeruid,omitempty"` // Buyer-specific ID for the user as mapped by the exchange for the buyer. Same as BuyerID but valid for OpenRTB 2.2. + YearOfBirth int `json:"yob,omitempty" msgp:"yob,omitempty"` // Year of birth as a 4-digit integer. + Gender string `json:"gender,omitempty" msgp:"gender,omitempty"` // Gender ("M": male, "F" female, "O" Other) + Keywords string `json:"keywords,omitempty" msgp:"keywords,omitempty"` // Comma separated list of keywords, interests, or intent + CustomData string `json:"customdata,omitempty" msgp:"customdata,omitempty"` // Optional feature to pass bidder data that was set in the exchange's cookie. The string must be in base85 cookie safe characters and be in any format. Proper JSON encoding must be used to include "escaped" quotation marks. + Geo *Geo `json:"geo,omitempty" msgp:"geo,omitempty"` + Data []Data `json:"data,omitempty" msgp:"data,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // Data and segment objects together allow additional data about the user to be specified. This data @@ -815,42 +817,42 @@ type User struct { // the id field. A bid request can mix data objects from multiple providers. The specific data providers in // use should be published by the exchange a priori to its bidders. type Data struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Segment []Segment `json:"segment,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` + Name string `json:"name,omitempty" msgp:"name,omitempty"` + Segment []Segment `json:"segment,omitempty" msgp:"segment,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // Segment objects are essentially key-value pairs that convey specific units of data about the user. The // parent Data object is a collection of such values from a given data provider. The specific segment // names and value options must be published by the exchange a priori to its bidders. type Segment struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` + Name string `json:"name,omitempty" msgp:"name,omitempty"` + Value string `json:"value,omitempty" msgp:"value,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // Regulations object contains any legal, governmental, or industry regulations that apply to the request. The // coppa flag signals whether or not the request falls under the United States Federal Trade Commission's // regulations for the United States Children's Online Privacy Protection Act ("COPPA"). type Regulations struct { - COPPA int `json:"coppa,omitempty"` // Flag indicating if this request is subject to the COPPA regulations established by the USA FTC, where 0 = no, 1 = yes. - GDPR int `json:"gdpr,omitempty"` // Flag that indicates whether or not the request is subject to GDPR regulations 0 = No, 1 = Yes, omission indicates Unknown. - USPrivacy string `json:"us_privacy,omitempty"` // Communicates signals regarding consumer privacy under US privacy regulation. - Ext json.RawMessage `json:"ext,omitempty"` + COPPA int `json:"coppa,omitempty" msgp:"coppa,omitempty"` // Flag indicating if this request is subject to the COPPA regulations established by the USA FTC, where 0 = no, 1 = yes. + GDPR int `json:"gdpr,omitempty" msgp:"gdpr,omitempty"` // Flag that indicates whether or not the request is subject to GDPR regulations 0 = No, 1 = Yes, omission indicates Unknown. + USPrivacy string `json:"us_privacy,omitempty" msgp:"us_privacy,omitempty"` // Communicates signals regarding consumer privacy under US privacy regulation. + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // Format object represents an allowed size (i.e., height and width combination) for a banner impression. // These are typically used in an array for an impression 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 { - Width int `json:"w,omitempty"` // Width in device independent pixels (DIPS). - Height int `json:"h,omitempty"` // Height in device independent pixels (DIPS). - WidthRatio int `json:"wratio,omitempty"` // Relative width when expressing size as a ratio. - HeightRatio int `json:"hration,omitempty"` // Relative height when expressing size as a ratio. - WidthMin int `json:"wmin,omitempty"` // The minimum width in device independent pixels (DIPS) at which the ad will be displayed the size is expressed as a ratio. - Ext json.RawMessage `json:"ext,omitempty"` + Width int `json:"w,omitempty" msgp:"w,omitempty"` // Width in device independent pixels (DIPS). + Height int `json:"h,omitempty" msgp:"h,omitempty"` // Height in device independent pixels (DIPS). + WidthRatio int `json:"wratio,omitempty" msgp:"wratio,omitempty"` // Relative width when expressing size as a ratio. + HeightRatio int `json:"hration,omitempty" msgp:"hration,omitempty"` // Relative height when expressing size as a ratio. + WidthMin int `json:"wmin,omitempty" msgp:"wmin,omitempty"` // The minimum width in device independent pixels (DIPS) at which the ad will be displayed the size is expressed as a ratio. + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // PodSequence identifies the pod sequence field, for use in video content streams with one or more ad pods as defined in Adcom1.0 @@ -912,8 +914,8 @@ const ( // ChannelEntity describes the network or channel an ad will be displayed on. (Reffer Section 3.2.23 and 3.2.24 OpenRTB_2.6) type ChannelEntity struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Domain string `json:"domain,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` + Name string `json:"name,omitempty" msgp:"name,omitempty"` + Domain string `json:"domain,omitempty" msgp:"domain,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } diff --git a/pmp.go b/pmp.go index a10d8ab..d082f16 100644 --- a/pmp.go +++ b/pmp.go @@ -1,27 +1,29 @@ package openrtb import ( - "encoding/json" + "github.com/tinylib/msgp/msgp" "github.com/bytedance/sonic" ) +//go:generate .deps/msgp + // PMP is the Private Marketplace Object type PMP struct { - Private int `json:"private_auction,omitempty"` - Deals []Deal `json:"deals,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + Private int `json:"private_auction,omitempty" msgp:"private_auction,omitempty"` + Deals []Deal `json:"deals,omitempty" msgp:"deals,omitempty"` + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } // Deal contains PMP deal information. type Deal struct { - ID string `json:"id,omitempty"` // Unique deal ID - BidFloor float64 `json:"bidfloor,omitempty"` - BidFloorCurrency string `json:"bidfloorcur,omitempty"` // Currency of bid floor - Seats []string `json:"wseat,omitempty"` // Array of buyer seats allowed to bid on this Direct Deal. - AdvDomains []string `json:"wadomain,omitempty"` // Array of advertiser domains allowed to bid on this Direct Deal - AuctionType int `json:"at,omitempty"` // Optional override of the overall auction type of the bid request, where 1 = First Price, 2 = Second Price Plus, 3 = the value passed in bidfloor is the agreed upon deal price. Additional auction types can be defined by the exchange. - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id,omitempty" msgp:"id,omitempty"` // Unique deal ID + BidFloor float64 `json:"bidfloor,omitempty" msgp:"bidfloor,omitempty"` + BidFloorCurrency string `json:"bidfloorcur,omitempty" msgp:"bidfloorcur,omitempty"` // Currency of bid floor + Seats []string `json:"wseat,omitempty" msgp:"wseat,omitempty"` // Array of buyer seats allowed to bid on this Direct Deal. + AdvDomains []string `json:"wadomain,omitempty" msgp:"wadomain,omitempty"` // Array of advertiser domains allowed to bid on this Direct Deal + AuctionType int `json:"at,omitempty" msgp:"at,omitempty"` // Optional override of the overall auction type of the bid request, where 1 = First Price, 2 = Second Price Plus, 3 = the value passed in bidfloor is the agreed upon deal price. Additional auction types can be defined by the exchange. + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } type jsonDeal Deal diff --git a/quantity.go b/quantity.go index 9ec3fee..bb74198 100644 --- a/quantity.go +++ b/quantity.go @@ -1,10 +1,12 @@ package openrtb import ( - "encoding/json" "errors" + "github.com/tinylib/msgp/msgp" ) +//go:generate .deps/msgp + var ( ErrMissingMultiplier = errors.New("openrtb: qty.multiplier is required") ErrMissingMeasurementVendor = errors.New("openrtb: qty.vendor is required when qty.sourcetype is 1 (Measurement Vendor)") @@ -20,10 +22,10 @@ const ( ) type Quantity struct { - Multiplier float64 `json:"multiplier"` - SourceType MeasurementSourceType `json:"sourcetype,omitempty"` - Vendor string `json:"vendor,omitempty"` - Ext *json.RawMessage `json:"ext,omitempty"` + Multiplier float64 `json:"multiplier" msgp:"multiplier"` + SourceType MeasurementSourceType `json:"sourcetype,omitempty" msgp:"sourcetype,omitempty"` + Vendor string `json:"vendor,omitempty" msgp:"vendor,omitempty"` + Ext *msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } func (qty *Quantity) Validate() error { diff --git a/source.go b/source.go index c72acf3..d0d047b 100644 --- a/source.go +++ b/source.go @@ -1,11 +1,15 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) // Source object describes the nature and behavior of the entity that is the source of the bid request upstream from the exchange. + +//go:generate .deps/msgp type Source struct { - FinalSaleDecision int `json:"fd,omitempty"` // Entity responsible for the final impression sale decision, where 0 = exchange, 1 = upstream source. - TransactionID string `json:"tid,omitempty"` // Transaction ID that must be common across all participants in this bid request (e.g., potentially multiple exchanges). - PaymentChain string `json:"pchain,omitempty"` // Payment ID chain string containing embedded syntax described in the TAG Payment ID Protocol v1.0. - Ext json.RawMessage `json:"ext,omitempty"` // Placeholder for exchange-specific extensions to OpenRTB. + FinalSaleDecision int `json:"fd,omitempty" msgp:"fd,omitempty"` // Entity responsible for the final impression sale decision, where 0 = exchange, 1 = upstream source. + TransactionID string `json:"tid,omitempty" msgp:"tid,omitempty"` // Transaction ID that must be common across all participants in this bid request (e.g., potentially multiple exchanges). + PaymentChain string `json:"pchain,omitempty" msgp:"pchain,omitempty"` // Payment ID chain string containing embedded syntax described in the TAG Payment ID Protocol v1.0. + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` // Placeholder for exchange-specific extensions to OpenRTB. } diff --git a/source_test.go b/source_test.go index 82401ea..0379822 100644 --- a/source_test.go +++ b/source_test.go @@ -1,7 +1,7 @@ package openrtb_test import ( - "encoding/json" + "github.com/tinylib/msgp/msgp" "reflect" "testing" @@ -18,7 +18,7 @@ func TestSource(t *testing.T) { FinalSaleDecision: 1, TransactionID: "transaction-id", PaymentChain: "payment-chain", - Ext: json.RawMessage("{}"), + Ext: msgp.Raw("{}"), } if got := subject; !reflect.DeepEqual(exp, got) { t.Errorf("expected %+v, got %+v", exp, got) diff --git a/sua.go b/sua.go index e310d6b..8c88d59 100644 --- a/sua.go +++ b/sua.go @@ -1,20 +1,23 @@ package openrtb -import "encoding/json" +import ( + "github.com/tinylib/msgp/msgp" +) +//go:generate .deps/msgp type UserAgent struct { - Browsers []BrandVersion `json:"browsers,omitempty"` // A browser or similar software component - Platform BrandVersion `json:"platform,omitempty"` // The user agent’s execution platform / OS - Mobile int `json:"mobile,omitempty"` // 1 if the agent prefers a "mobile" version of the content, if available, i.e. optimized for small screens or touch input. 0 if the agent prefers the "desktop". Taken from Sec-CH-UAMobile header - Architecture string `json:"architecture,omitempty"` // Device’s major binary architecture, e.g. "x86" or "arm". Taken from the Sec-CH-UA-Arch header - Bitness string `json:"bitness,omitempty"` // Device’s bitness, e.g. "64" for 64-bit architecture. Taken from the Sec-CH-UA-Bitness header - Model string `json:"model,omitempty"` // Device model. Taken from the Sec-CH-UAModel header - Source int `json:"source,omitempty"` // The source of data used to create this object, List: User-Agent Source in AdCOM 1.0 - Ext json.RawMessage `json:"ext,omitempty"` + Browsers []BrandVersion `json:"browsers,omitempty" msgp:"browsers,omitempty"` // A browser or similar software component + Platform BrandVersion `json:"platform,omitempty" msgp:"platform,omitempty"` // The user agent’s execution platform / OS + Mobile int `json:"mobile,omitempty" msgp:"mobile,omitempty"` // 1 if the agent prefers a "mobile" version of the content, if available, i.e. optimized for small screens or touch input. 0 if the agent prefers the "desktop". Taken from Sec-CH-UAMobile header + Architecture string `json:"architecture,omitempty" msgp:"architecture,omitempty"` // Device’s major binary architecture, e.g. "x86" or "arm". Taken from the Sec-CH-UA-Arch header + Bitness string `json:"bitness,omitempty" msgp:"bitness,omitempty"` // Device’s bitness, e.g. "64" for 64-bit architecture. Taken from the Sec-CH-UA-Bitness header + Model string `json:"model,omitempty" msgp:"model,omitempty"` // Device model. Taken from the Sec-CH-UAModel header + Source int `json:"source,omitempty" msgp:"source,omitempty"` // The source of data used to create this object, List: User-Agent Source in AdCOM 1.0 + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } type BrandVersion struct { - Brand string `json:"brand,omitempty"` // A brand identifier, for example, "Chrome" or "Windows". Taken from the Sec-CH-UA-Full-Version or Sec-CH-UA-Platform header - Version []string `json:"version,omitempty"` // A sequence of version components, in descending hierarchical order (major, minor, patch) - Ext json.RawMessage `json:"ext,omitempty"` + Brand string `json:"brand,omitempty" msgp:"brand,omitempty"` // A brand identifier, for example, "Chrome" or "Windows". Taken from the Sec-CH-UA-Full-Version or Sec-CH-UA-Platform header + Version []string `json:"version,omitempty" msgp:"version,omitempty"` // A sequence of version components, in descending hierarchical order (major, minor, patch) + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } diff --git a/video.go b/video.go index f583f53..7e1c9a1 100644 --- a/video.go +++ b/video.go @@ -1,8 +1,8 @@ package openrtb import ( - "encoding/json" "errors" + "github.com/tinylib/msgp/msgp" "github.com/bytedance/sonic" ) @@ -14,42 +14,44 @@ var ( ErrInvalidVideoNoProtocols = errors.New("openrtb: video protocols missing") ) +//go:generate .deps/msgp + // Video object must be included directly in the impression object if the impression offered // for auction is an in-stream video ad opportunity. type Video struct { - MIMEs []string `json:"mimes,omitempty"` // Content MIME types supported. - MinDuration int `json:"minduration,omitempty"` // Minimum video ad duration in seconds - MaxDuration int `json:"maxduration,omitempty"` // Maximum video ad duration in seconds - Protocols []Protocol `json:"protocols,omitempty"` // Video bid response protocols - Protocol Protocol `json:"protocol,omitempty"` // Video bid response protocols DEPRECATED - Width int `json:"w"` // Width of the player in pixels - Height int `json:"h"` // Height of the player in pixels - StartDelay StartDelay `json:"startdelay,omitempty"` // Indicates the start delay in seconds - Linearity VideoLinearity `json:"linearity,omitempty"` // Indicates whether the ad impression is linear or non-linear - Skip *int `json:"skip,omitempty"` // Indicates if the player will allow the video to be skipped, where 0 = no, 1 = yes. - SkipMin int `json:"skipmin,omitempty"` // Videos of total duration greater than this number of seconds can be skippable - SkipAfter int `json:"skipafter,omitempty"` // Number of seconds a video must play before skipping is enabled - Sequence int `json:"sequence,omitempty"` // Default: 1 - BlockedAttrs []CreativeAttribute `json:"battr,omitempty"` // Blocked creative attributes - MaxExtended int `json:"maxextended,omitempty"` // Maximum extended video ad duration - MinBitrate int `json:"minbitrate,omitempty"` // Minimum bit rate in Kbps - MaxBitrate int `json:"maxbitrate,omitempty"` // Maximum bit rate in Kbps - BoxingAllowed *int `json:"boxingallowed,omitempty"` // If exchange publisher has rules preventing letter boxing - PodID string `json:"podid,omitempty"` // Pod id unique identifier for video ad pod - PodDuration int `json:"poddur,omitempty"` // Pod Duration total amount of time in seconds that advertisers may fill for a video ad pod - PodSequence PodSequence `json:"podseq,omitempty"` // Pod Sequence position of the video ad pod - SlotInPod SlotPositionInPod `json:"slotinpod,omitempty"` // Slot Position in ad - RqdDurs []int64 `json:"rqddurs,omitempty"` // Precise acceptable durations for video creatives inseconds. - MinCPMPerSecond float64 `json:"mincpmpersec,omitempty"` // Minimum CPM per second. This is a price floor for the portion of a video ad pod - PlaybackMethods []VideoPlayback `json:"playbackmethod,omitempty"` // List of allowed playback methods - Delivery []ContentDelivery `json:"delivery,omitempty"` // List of supported delivery methods - Position AdPosition `json:"pos,omitempty"` // Ad Position - CompanionAds []Banner `json:"companionad,omitempty"` - APIs []APIFramework `json:"api,omitempty"` // List of supported API frameworks - CompanionTypes []CompanionType `json:"companiontype,omitempty"` - Placement VideoPlacement `json:"placement,omitempty"` // Video placement type, DEPRECATED - Plcmt VideoPlcmt `json:"plcmt,omitempty"` // Video Plcmt type ad defined in ADCOM1.0 - Ext json.RawMessage `json:"ext,omitempty"` + MIMEs []string `json:"mimes,omitempty" msgp:"mimes,omitempty"` // Content MIME types supported. + MinDuration int `json:"minduration,omitempty" msgp:"minduration,omitempty"` // Minimum video ad duration in seconds + MaxDuration int `json:"maxduration,omitempty" msgp:"maxduration,omitempty"` // Maximum video ad duration in seconds + Protocols []Protocol `json:"protocols,omitempty" msgp:"protocols,omitempty"` // Video bid response protocols + Protocol Protocol `json:"protocol,omitempty" msgp:"protocol,omitempty"` // Video bid response protocols DEPRECATED + Width int `json:"w" msgp:"w"` // Width of the player in pixels + Height int `json:"h" msgp:"h"` // Height of the player in pixels + StartDelay StartDelay `json:"startdelay,omitempty" msgp:"startdelay,omitempty"` // Indicates the start delay in seconds + Linearity VideoLinearity `json:"linearity,omitempty" msgp:"linearity,omitempty"` // Indicates whether the ad impression is linear or non-linear + Skip *int `json:"skip,omitempty" msgp:"skip,omitempty"` // Indicates if the player will allow the video to be skipped, where 0 = no, 1 = yes. + SkipMin int `json:"skipmin,omitempty" msgp:"skipmin,omitempty"` // Videos of total duration greater than this number of seconds can be skippable + SkipAfter int `json:"skipafter,omitempty" msgp:"skipafter,omitempty"` // Number of seconds a video must play before skipping is enabled + Sequence int `json:"sequence,omitempty" msgp:"sequence,omitempty"` // Default: 1 + BlockedAttrs []CreativeAttribute `json:"battr,omitempty" msgp:"battr,omitempty"` // Blocked creative attributes + MaxExtended int `json:"maxextended,omitempty" msgp:"maxextended,omitempty"` // Maximum extended video ad duration + MinBitrate int `json:"minbitrate,omitempty" msgp:"minbitrate,omitempty"` // Minimum bit rate in Kbps + MaxBitrate int `json:"maxbitrate,omitempty" msgp:"maxbitrate,omitempty"` // Maximum bit rate in Kbps + BoxingAllowed *int `json:"boxingallowed,omitempty" msgp:"boxingallowed,omitempty"` // If exchange publisher has rules preventing letter boxing + PodID string `json:"podid,omitempty" msgp:"podid,omitempty"` // Pod id unique identifier for video ad pod + PodDuration int `json:"poddur,omitempty" msgp:"poddur,omitempty"` // Pod Duration total amount of time in seconds that advertisers may fill for a video ad pod + PodSequence PodSequence `json:"podseq,omitempty" msgp:"podseq,omitempty"` // Pod Sequence position of the video ad pod + SlotInPod SlotPositionInPod `json:"slotinpod,omitempty" msgp:"slotinpod,omitempty"` // Slot Position in ad + RqdDurs []int64 `json:"rqddurs,omitempty" msgp:"rqddurs,omitempty"` // Precise acceptable durations for video creatives inseconds. + MinCPMPerSecond float64 `json:"mincpmpersec,omitempty" msgp:"mincpmpersec,omitempty"` // Minimum CPM per second. This is a price floor for the portion of a video ad pod + PlaybackMethods []VideoPlayback `json:"playbackmethod,omitempty" msgp:"playbackmethod,omitempty"` // List of allowed playback methods + Delivery []ContentDelivery `json:"delivery,omitempty" msgp:"delivery,omitempty"` // List of supported delivery methods + Position AdPosition `json:"pos,omitempty" msgp:"pos,omitempty"` // Ad Position + CompanionAds []Banner `json:"companionad,omitempty" msgp:"companionad,omitempty"` + APIs []APIFramework `json:"api,omitempty" msgp:"api,omitempty"` // List of supported API frameworks + CompanionTypes []CompanionType `json:"companiontype,omitempty" msgp:"companiontype,omitempty"` + Placement VideoPlacement `json:"placement,omitempty" msgp:"placement,omitempty"` // Video placement type, DEPRECATED + Plcmt VideoPlcmt `json:"plcmt,omitempty" msgp:"plcmt,omitempty"` // Video Plcmt type ad defined in ADCOM1.0 + Ext msgp.Raw `json:"ext,omitempty" msgp:"ext,omitempty"` } type jsonVideo Video