Skip to content

Commit 1a48cb0

Browse files
authored
Merge pull request #26 from mxmCherry/master
Use custom Extension type instead of json.RawMessage for "ext" fields
2 parents 4b2843e + 6cd3548 commit 1a48cb0

28 files changed

+331
-308
lines changed

banner.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
package openrtb
22

3-
import "encoding/json"
4-
53
// The "banner" object must be included directly in the impression object if the impression offered
64
// for auction is display or rich media, or it may be optionally embedded in the video object to
75
// describe the companion banners available for the linear or non-linear video ad. The banner
86
// object may include a unique identifier; this can be useful if these IDs can be leveraged in the
97
// VAST response to dictate placement of the companion creatives when multiple companion ad
108
// opportunities of the same size are available on a page.
119
type Banner struct {
12-
W int `json:"w,omitempty"` // Width
13-
H int `json:"h,omitempty"` // Height
14-
WMax int `json:"wmax,omitempty"` // Width maximum
15-
HMax int `json:"hmax,omitempty"` // Height maximum
16-
WMin int `json:"wmin,omitempty"` // Width minimum
17-
HMin int `json:"hmin,omitempty"` // Height minimum
18-
ID string `json:"id,omitempty"` // A unique identifier
19-
Pos int `json:"pos,omitempty"` // Ad Position
20-
BType []int `json:"btype,omitempty"` // Blocked creative types
21-
BAttr []int `json:"battr,omitempty"` // Blocked creative attributes
22-
Mimes []string `json:"mimes,omitempty"` // Whitelist of content MIME types supported
23-
TopFrame int `json:"topframe,omitempty"` // Default: 0 ("1": Delivered in top frame, "0": Elsewhere)
24-
ExpDir []int `json:"expdir,omitempty"` // Specify properties for an expandable ad
25-
Api []int `json:"api,omitempty"` // List of supported API frameworks
26-
Ext json.RawMessage `json:"ext,omitempty"`
10+
W int `json:"w,omitempty"` // Width
11+
H int `json:"h,omitempty"` // Height
12+
WMax int `json:"wmax,omitempty"` // Width maximum
13+
HMax int `json:"hmax,omitempty"` // Height maximum
14+
WMin int `json:"wmin,omitempty"` // Width minimum
15+
HMin int `json:"hmin,omitempty"` // Height minimum
16+
ID string `json:"id,omitempty"` // A unique identifier
17+
Pos int `json:"pos,omitempty"` // Ad Position
18+
BType []int `json:"btype,omitempty"` // Blocked creative types
19+
BAttr []int `json:"battr,omitempty"` // Blocked creative attributes
20+
Mimes []string `json:"mimes,omitempty"` // Whitelist of content MIME types supported
21+
TopFrame int `json:"topframe,omitempty"` // Default: 0 ("1": Delivered in top frame, "0": Elsewhere)
22+
ExpDir []int `json:"expdir,omitempty"` // Specify properties for an expandable ad
23+
Api []int `json:"api,omitempty"` // List of supported API frameworks
24+
Ext Extension `json:"ext,omitempty"`
2725
}

bid.go

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package openrtb
22

3-
import (
4-
"encoding/json"
5-
"errors"
6-
)
3+
import "errors"
74

85
// Validation errors
96
var (
@@ -19,22 +16,22 @@ var (
1916
// Cid can be used to block ads that were previously identified as inappropriate.
2017
// Substitution macros may allow a bidder to use a static notice URL for all of its bids.
2118
type Bid struct {
22-
ID string `json:"id"`
23-
ImpID string `json:"impid"` // Required string ID of the impression object to which this bid applies.
24-
Price float64 `json:"price"` // Bid price in CPM. Suggests using integer math for accounting to avoid rounding errors.
25-
AdID string `json:"adid,omitempty"` // References the ad to be served if the bid wins.
26-
NURL string `json:"nurl,omitempty"` // Win notice URL.
27-
AdMarkup string `json:"adm,omitempty"` // Actual ad markup. XHTML if a response to a banner object, or VAST XML if a response to a video object.
28-
AdvDomain []string `json:"adomain,omitempty"` // Advertiser’s primary or top-level domain for advertiser checking; or multiple if imp rotating.
29-
IURL string `json:"iurl,omitempty"` // Sample image URL.
30-
CampaignID string `json:"cid,omitempty"` // Campaign ID that appears with the Ad markup.
31-
CreativeID string `json:"crid,omitempty"` // Creative ID for reporting content issues or defects. This could also be used as a reference to a creative ID that is posted with an exchange.
32-
Cat []string `json:"cat,omitempty"` // IAB content categories of the creative. Refer to List 5.1
33-
Attr []int `json:"attr,omitempty"` // Array of creative attributes.
34-
DealID string `json:"dealid,omitempty"` // DealID extension of private marketplace deals
35-
H int `json:"h,omitempty"` // Height of the ad in pixels.
36-
W int `json:"w,omitempty"` // Width of the ad in pixels.
37-
Ext json.RawMessage `json:"ext,omitempty"`
19+
ID string `json:"id"`
20+
ImpID string `json:"impid"` // Required string ID of the impression object to which this bid applies.
21+
Price float64 `json:"price"` // Bid price in CPM. Suggests using integer math for accounting to avoid rounding errors.
22+
AdID string `json:"adid,omitempty"` // References the ad to be served if the bid wins.
23+
NURL string `json:"nurl,omitempty"` // Win notice URL.
24+
AdMarkup string `json:"adm,omitempty"` // Actual ad markup. XHTML if a response to a banner object, or VAST XML if a response to a video object.
25+
AdvDomain []string `json:"adomain,omitempty"` // Advertiser’s primary or top-level domain for advertiser checking; or multiple if imp rotating.
26+
IURL string `json:"iurl,omitempty"` // Sample image URL.
27+
CampaignID string `json:"cid,omitempty"` // Campaign ID that appears with the Ad markup.
28+
CreativeID string `json:"crid,omitempty"` // Creative ID for reporting content issues or defects. This could also be used as a reference to a creative ID that is posted with an exchange.
29+
Cat []string `json:"cat,omitempty"` // IAB content categories of the creative. Refer to List 5.1
30+
Attr []int `json:"attr,omitempty"` // Array of creative attributes.
31+
DealID string `json:"dealid,omitempty"` // DealID extension of private marketplace deals
32+
H int `json:"h,omitempty"` // Height of the ad in pixels.
33+
W int `json:"w,omitempty"` // Width of the ad in pixels.
34+
Ext Extension `json:"ext,omitempty"`
3835
}
3936

4037
// Validate required attributes

bidrequest.go

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package openrtb
22

3-
import (
4-
"encoding/json"
5-
"errors"
6-
)
3+
import "errors"
74

85
// Validation errors
96
var (
@@ -16,22 +13,22 @@ var (
1613
// attribute is required as is at least one "imp" (i.e., impression) object. Other attributes are
1714
// optional since an exchange may establish default values.
1815
type BidRequest struct {
19-
ID string `json:"id"` // Unique ID of the bid request
20-
Imp []Impression `json:"imp,omitempty"`
21-
Site *Site `json:"site,omitempty"`
22-
App *App `json:"app,omitempty"`
23-
Device *Device `json:"device,omitempty"`
24-
User *User `json:"user,omitempty"`
25-
Test int `json:"test,omitempty"` // Indicator of test mode in which auctions are not billable, where 0 = live mode, 1 = test mode
26-
AuctionType int `json:"at"` // Auction type, where 1 = First Price, 2 = Second Price Plus. Exchange-specific auction types can be defined using values greater than 500.
27-
TMax int `json:"tmax,omitempty"` // Maximum amount of time in milliseconds to submit a bid
28-
WSeat []string `json:"wseat,omitempty"` // Array of buyer seats allowed to bid on this auction
29-
AllImps int `json:"allimps,omitempty"` // Flag to indicate whether exchange can verify that all impressions offered represent all of the impressions available in context, Default: 0
30-
Cur []string `json:"cur,omitempty"` // Array of allowed currencies
31-
Bcat []string `json:"bcat,omitempty"` // Blocked Advertiser Categories.
32-
BAdv []string `json:"badv,omitempty"` // Array of strings of blocked toplevel domains of advertisers
33-
Regs *Regulations `json:"regs,omitempty"`
34-
Ext json.RawMessage `json:"ext,omitempty"`
16+
ID string `json:"id"` // Unique ID of the bid request
17+
Imp []Impression `json:"imp,omitempty"`
18+
Site *Site `json:"site,omitempty"`
19+
App *App `json:"app,omitempty"`
20+
Device *Device `json:"device,omitempty"`
21+
User *User `json:"user,omitempty"`
22+
Test int `json:"test,omitempty"` // Indicator of test mode in which auctions are not billable, where 0 = live mode, 1 = test mode
23+
AuctionType int `json:"at"` // Auction type, where 1 = First Price, 2 = Second Price Plus. Exchange-specific auction types can be defined using values greater than 500.
24+
TMax int `json:"tmax,omitempty"` // Maximum amount of time in milliseconds to submit a bid
25+
WSeat []string `json:"wseat,omitempty"` // Array of buyer seats allowed to bid on this auction
26+
AllImps int `json:"allimps,omitempty"` // Flag to indicate whether exchange can verify that all impressions offered represent all of the impressions available in context, Default: 0
27+
Cur []string `json:"cur,omitempty"` // Array of allowed currencies
28+
Bcat []string `json:"bcat,omitempty"` // Blocked Advertiser Categories.
29+
BAdv []string `json:"badv,omitempty"` // Array of strings of blocked toplevel domains of advertisers
30+
Regs *Regulations `json:"regs,omitempty"`
31+
Ext Extension `json:"ext,omitempty"`
3532

3633
Pmp *Pmp `json:"pmp,omitempty"` // DEPRECATED: kept for backwards compatibility
3734
}

bidresponse.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package openrtb
22

3-
import (
4-
"encoding/json"
5-
"errors"
6-
)
3+
import "errors"
74

85
// Validation errors
96
var (
@@ -16,13 +13,13 @@ var (
1613
// No-Bids on all impressions should be indicated as a HTTP 204 response.
1714
// For no-bids on specific impressions, the bidder should omit these from the bid response.
1815
type BidResponse struct {
19-
ID string `json:"id"` // Reflection of the bid request ID for logging purposes
20-
SeatBid []SeatBid `json:"seatbid"` // Array of seatbid objects
21-
BidID string `json:"bidid,omitempty"` // Optional response tracking ID for bidders
22-
Currency string `json:"cur,omitempty"` // Bid currency
23-
CustomData string `json:"customdata,omitempty"` // Encoded user features
24-
NBR int `json:"nbr,omitempty"` // Reason for not bidding, where 0 = unknown error, 1 = technical error, 2 = invalid request, 3 = known web spider, 4 = suspected Non-Human Traffic, 5 = cloud, data center, or proxy IP, 6 = unsupported device, 7 = blocked publisher or site, 8 = unmatched user
25-
Ext json.RawMessage `json:"ext,omitempty"` // Custom specifications in JSon
16+
ID string `json:"id"` // Reflection of the bid request ID for logging purposes
17+
SeatBid []SeatBid `json:"seatbid"` // Array of seatbid objects
18+
BidID string `json:"bidid,omitempty"` // Optional response tracking ID for bidders
19+
Currency string `json:"cur,omitempty"` // Bid currency
20+
CustomData string `json:"customdata,omitempty"` // Encoded user features
21+
NBR int `json:"nbr,omitempty"` // Reason for not bidding, where 0 = unknown error, 1 = technical error, 2 = invalid request, 3 = known web spider, 4 = suspected Non-Human Traffic, 5 = cloud, data center, or proxy IP, 6 = unsupported device, 7 = blocked publisher or site, 8 = unmatched user
22+
Ext Extension `json:"ext,omitempty"` // Custom specifications in JSon
2623
}
2724

2825
// Validate required attributes

content.go

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
package openrtb
22

3-
import "encoding/json"
4-
53
// This object describes the content in which the impression will appear, which may be syndicated or nonsyndicated
64
// content. This object may be useful when syndicated content contains impressions and does
75
// not necessarily match the publisher's general content. The exchange might or might not have
86
// knowledge of the page where the content is running, as a result of the syndication method. For
97
// example might be a video impression embedded in an iframe on an unknown web property or device.
108
type Content struct {
11-
ID string `json:"id,omitempty"` // ID uniquely identifying the content.
12-
Episode int `json:"episode,omitempty"` // Episode number (typically applies to video content).
13-
Title string `json:"title,omitempty"` // Content title.
14-
Series string `json:"series,omitempty"` // Content series.
15-
Season string `json:"season,omitempty"` // Content season.
16-
Producer *Producer `json:"producer,omitempty"` // The producer.
17-
URL string `json:"url,omitempty"` // URL of the content, for buy-side contextualization or review.
18-
Cat []string `json:"cat,omitempty"` // Array of IAB content categories that describe the content.
19-
VideoQuality int `json:"videoquality,omitempty"` // Video quality per IAB's classification.
20-
Context int `json:"context,omitempty"` // Type of content (game, video, text, etc.).
21-
ContentRating string `json:"contentrating,omitempty"` // Content rating (e.g., MPAA).
22-
UserRating string `json:"userrating,omitempty"` // User rating of the content (e.g., number of stars, likes, etc.).
23-
QAGMediaRating int `json:"qagmediarating,omitempty"` // Media rating per QAG guidelines.
24-
Keywords string `json:"keywords,omitempty"` // Comma separated list of keywords describing the content.
25-
LiveStream int `json:"livestream,omitempty"` // 0 = not live, 1 = content is live (e.g., stream, live blog).
26-
SourceRelationship int `json:"sourcerelationship,omitempty"` // 0 = indirect, 1 = direct.
27-
Len int `json:"len,omitempty"` // Length of content in seconds; appropriate for video or audio.
28-
Language string `json:"language,omitempty"` // Content language using ISO-639-1-alpha-2.
29-
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.
30-
Ext json.RawMessage `json:"ext,omitempty"`
9+
ID string `json:"id,omitempty"` // ID uniquely identifying the content.
10+
Episode int `json:"episode,omitempty"` // Episode number (typically applies to video content).
11+
Title string `json:"title,omitempty"` // Content title.
12+
Series string `json:"series,omitempty"` // Content series.
13+
Season string `json:"season,omitempty"` // Content season.
14+
Producer *Producer `json:"producer,omitempty"` // The producer.
15+
URL string `json:"url,omitempty"` // URL of the content, for buy-side contextualization or review.
16+
Cat []string `json:"cat,omitempty"` // Array of IAB content categories that describe the content.
17+
VideoQuality int `json:"videoquality,omitempty"` // Video quality per IAB's classification.
18+
Context int `json:"context,omitempty"` // Type of content (game, video, text, etc.).
19+
ContentRating string `json:"contentrating,omitempty"` // Content rating (e.g., MPAA).
20+
UserRating string `json:"userrating,omitempty"` // User rating of the content (e.g., number of stars, likes, etc.).
21+
QAGMediaRating int `json:"qagmediarating,omitempty"` // Media rating per QAG guidelines.
22+
Keywords string `json:"keywords,omitempty"` // Comma separated list of keywords describing the content.
23+
LiveStream int `json:"livestream,omitempty"` // 0 = not live, 1 = content is live (e.g., stream, live blog).
24+
SourceRelationship int `json:"sourcerelationship,omitempty"` // 0 = indirect, 1 = direct.
25+
Len int `json:"len,omitempty"` // Length of content in seconds; appropriate for video or audio.
26+
Language string `json:"language,omitempty"` // Content language using ISO-639-1-alpha-2.
27+
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.
28+
Ext Extension `json:"ext,omitempty"`
3129
}

0 commit comments

Comments
 (0)