Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Feature/simplify integral types #37

Merged
merged 7 commits into from
Dec 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ Master always contains latest code, so better use some package manager to vendor
- Key types should be chosen according to OpenRTB specification (attribute types)
- Numeric types:
- `int8` - short enums (with values <= 127), boolean-like attributes (like `BidRequest.test`)
- `int64` - time, duration, length, unbound enums (like `BidRequest.at` - exchange-specific auctions types are > 500)
- `uint64` - width, height, bitrate etc. (unbound positive numbers)
- `int64` - every other integral type
- `float64` - coordinates, prices etc.
- Enums:
- all enums, described in section 5, must be typed with section name singularized (e.g., "5.2 Banner Ad Types" -> `type BannerAdType int8`)
- all typed enums must have constants for each element, prefixed with type name (e.g., "5.2 Banner Ad Types - XHTML Text Ad (usually mobile)" -> `const BannerAdTypeXHTMLTextAd BannerAdType = 1`)
- never use `iota` for enum constants
- section "5.1 Content Categories" should remain untyped and have no constants
- OpenRTB (2.x) section "5.1 Content Categories" should remain untyped and have no constants

## Pointers/omitempty
Pointer | Omitempty | When to use | Example
Expand Down
6 changes: 3 additions & 3 deletions adcom1/audio_placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ type AudioPlacement struct {
// integer
// Definition:
// Minimum bit rate of the creative in Kbps.
MinBitR uint64 `json:"minbitr,omitempty"`
MinBitR int64 `json:"minbitr,omitempty"`

// Attribute:
// maxbitr
// Type:
// integer
// Definition:
// Maximum bit rate of the creative in Kbps.
MaxBitR uint64 `json:"maxbitr,omitempty"`
MaxBitR int64 `json:"maxbitr,omitempty"`

// Attribute:
// delivery
Expand All @@ -160,7 +160,7 @@ type AudioPlacement struct {
// integer
// Definition:
// The maximum number of ads that can be played in an ad pod.
MaxSeq int `json:"maxseq,omitempty"`
MaxSeq int64 `json:"maxseq,omitempty"`

// Attribute:
// comp
Expand Down
2 changes: 1 addition & 1 deletion adcom1/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Content struct {
// integer
// Definition:
// Episode number.
Episode uint16 `json:"episode,omitempty"`
Episode int64 `json:"episode,omitempty"`

// Attribute:
// title
Expand Down
2 changes: 1 addition & 1 deletion adcom1/data_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type DataAsset struct {
// Definition:
// The length of the value contents.
// This length should conform to recommendations provided in List: Native Data Asset Types
Len int `json:"len,omitempty"`
Len int64 `json:"len,omitempty"`

// Attribute:
// type
Expand Down
2 changes: 1 addition & 1 deletion adcom1/data_asset_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type DataAssetFormat struct {
// integer
// Definition:
// The maximum allowed length of the data value.
Len int `json:"len,omitempty"`
Len int64 `json:"len,omitempty"`

// Attribute:
// ext
Expand Down
6 changes: 3 additions & 3 deletions adcom1/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ type Device struct {
// integer
// Definition:
// Physical height of the screen in pixels.
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Attribute:
// w
// Type:
// integer
// Definition:
// Physical width of the screen in pixels.
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Attribute:
// ppi
// Type:
// integer
// Definition:
// Screen size as pixels per linear inch.
PPI uint16 `json:"ppi,omitempty"`
PPI int64 `json:"ppi,omitempty"`

// Attribute:
// pxratio
Expand Down
12 changes: 6 additions & 6 deletions adcom1/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Display struct {
// Definition:
// Absolute width of the creative in device independent pixels (DIPS), typically for non-native ads.
// Note that mixing absolute and relative sizes is not recommended.
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Attribute:
// h
Expand All @@ -49,7 +49,7 @@ type Display struct {
// Definition:
// Absolute height of the creative in device independent pixels (DIPS), typically for non-native ads.
// Note that mixing absolute and relative sizes is not recommended.
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Attribute:
// wratio
Expand All @@ -59,8 +59,8 @@ type Display struct {
// Relative width of the creative when expressing size as a ratio, typically for non-native ads.
// Note that mixing absolute and relative sizes is not recommended.
// Dev note:
// This is kept as `uint8` because ratio values are expected to be quite small (like 16:9).
WRatio uint8 `json:"wratio,omitempty"`
// This is kept as `int8` because ratio values are expected to be quite small (like 16:9).
WRatio int8 `json:"wratio,omitempty"`

// Attribute:
// hratio
Expand All @@ -70,8 +70,8 @@ type Display struct {
// Relative height of the creative when expressing size as a ratio, typically for non-native ads.
// Note that mixing absolute and relative sizes is not recommended.
// Dev note:
// This is kept as `uint8` because ratio values are expected to be quite small (like 16:9).
HRatio uint8 `json:"hratio,omitempty"`
// This is kept as `int8` because ratio values are expected to be quite small (like 16:9).
HRatio int8 `json:"hratio,omitempty"`

// Attribute:
// priv
Expand Down
12 changes: 6 additions & 6 deletions adcom1/display_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type DisplayFormat struct {
// Definition:
// Absolute width of the creative in units specified by DisplayPlacement.unit.
// Note that mixing absolute and relative sizes is not recommended.
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Attribute:
// h
Expand All @@ -20,7 +20,7 @@ type DisplayFormat struct {
// Definition:
// Absolute height of the creative in units specified by DisplayPlacement.unit.
// Note that mixing absolute and relative sizes is not recommended.
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Attribute:
// wratio
Expand All @@ -30,8 +30,8 @@ type DisplayFormat struct {
// Relative width of the creative when expressing size as a ratio.
// Note that mixing absolute and relative sizes is not recommended.
// Dev note:
// This is kept as `uint8` because ratio values are expected to be quite small (like 16:9).
WRatio uint8 `json:"wratio,omitempty"`
// This is kept as `int8` because ratio values are expected to be quite small (like 16:9).
WRatio int8 `json:"wratio,omitempty"`

// Attribute:
// hratio
Expand All @@ -41,8 +41,8 @@ type DisplayFormat struct {
// Relative height of the creative when expressing size as a ratio.
// Note that mixing absolute and relative sizes is not recommended.
// Dev note:
// This is kept as `uint8` because ratio values are expected to be quite small (like 16:9).
HRatio uint8 `json:"hratio,omitempty"`
// This is kept as `int8` because ratio values are expected to be quite small (like 16:9).
HRatio int8 `json:"hratio,omitempty"`

// Attribute:
// expdir
Expand Down
4 changes: 2 additions & 2 deletions adcom1/display_placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type DisplayPlacement struct {
// Definition:
// Width of the placement in units specified by unit.
// Note that this size applies to the placement itself; permitted creative sizes are specified elsewhere (e.g., DisplayFormat, ImageAssetFormat, etc.).
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Attribute:
// h
Expand All @@ -119,7 +119,7 @@ type DisplayPlacement struct {
// Definition:
// Width of the placement in units specified by unit.
// Note that this size applies to the placement itself; permitted creative sizes are specified elsewhere (e.g., DisplayFormat, ImageAssetFormat, etc.).
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Attribute:
// unit
Expand Down
2 changes: 1 addition & 1 deletion adcom1/dooh.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type DOOH struct {
// integer
// Definition:
// Minimum DPI for text-based creative elements to display clearly.
DPI uint16 `json:"dpi,omitempty"`
DPI int64 `json:"dpi,omitempty"`

// Attribute:
// ext
Expand Down
4 changes: 1 addition & 3 deletions adcom1/geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ type Geo struct {
// integer
// Definition:
// Local time as the number +/- of minutes from UTC.
// Dev note:
// This field is kept as `int` to follow type choice for timezone offset in std. `time` package.
UTCOffset int `json:"utcoffset,omitempty"`
UTCOffset int64 `json:"utcoffset,omitempty"`

// Attribute:
// ext
Expand Down
4 changes: 2 additions & 2 deletions adcom1/image_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ type ImageAsset struct {
// integer; recommended
// Definition:
// Width of the image asset in device independent pixels (DIPS).
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Attribute:
// h
// Type:
// integer; recommended
// Definition:
// Height of the image asset in device independent pixels (DIPS).
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Attribute:
// type
Expand Down
16 changes: 8 additions & 8 deletions adcom1/image_asset_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ImageAssetFormat struct {
// Definition:
// Absolute width of the image asset in device independent pixels (DIPS).
// Note that mixing absolute and relative sizes is not recommended.
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Attribute:
// h
Expand All @@ -39,7 +39,7 @@ type ImageAssetFormat struct {
// Definition:
// Absolute height of the image asset in device independent pixels (DIPS).
// Note that mixing absolute and relative sizes is not recommended.
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Attribute:
// wmin
Expand All @@ -48,7 +48,7 @@ type ImageAssetFormat struct {
// Definition:
// The minimum requested absolute width of the image in device independent pixels (DIPS).
// This option should be used for any scaling of images by the client.
WMin uint64 `json:"wmin,omitempty"`
WMin int64 `json:"wmin,omitempty"`

// Attribute:
// hmin
Expand All @@ -57,7 +57,7 @@ type ImageAssetFormat struct {
// Definition:
// The minimum requested absolute height of the image in device independent pixels (DIPS).
// This option should be used for any scaling of images by the client.
HMin uint64 `json:"hmin,omitempty"`
HMin int64 `json:"hmin,omitempty"`

// Attribute:
// wratio
Expand All @@ -67,8 +67,8 @@ type ImageAssetFormat struct {
// Relative width of the image asset when expressing size as a ratio.
// Note that mixing absolute and relative sizes is not recommended.
// Dev note:
// This is kept as `uint8` because ratio values are expected to be quite small (like 16:9).
WRatio uint8 `json:"wratio,omitempty"`
// This is kept as `int8` because ratio values are expected to be quite small (like 16:9).
WRatio int8 `json:"wratio,omitempty"`

// Attribute:
// hratio
Expand All @@ -78,8 +78,8 @@ type ImageAssetFormat struct {
// Relative height of the image asset when expressing size as a ratio.
// Note that mixing absolute and relative sizes is not recommended.
// Dev note:
// This is kept as `uint8` because ratio values are expected to be quite small (like 16:9).
HRatio uint8 `json:"hratio,omitempty"`
// This is kept as `int8` because ratio values are expected to be quite small (like 16:9).
HRatio int8 `json:"hratio,omitempty"`

// Attribute:
// ext
Expand Down
2 changes: 1 addition & 1 deletion adcom1/title_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type TitleAsset struct {
// integer
// Definition:
// The length of the contents of the text attribute.
Len int `json:"len,omitempty"`
Len int64 `json:"len,omitempty"`

// Attribute:
// ext
Expand Down
2 changes: 1 addition & 1 deletion adcom1/title_asset_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type TitleAssetFormat struct {
// Definition:
// The maximum allowed length of the title value.
// Recommended lengths are 25, 90, or 140.
Len int `json:"len,omitempty"`
Len int64 `json:"len,omitempty"`

// Attribute:
// ext
Expand Down
2 changes: 1 addition & 1 deletion adcom1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type User struct {
// integer
// Definition:
// Year of birth as a 4-digit integer.
YOB uint16 `json:"yob,omitempty"`
YOB int64 `json:"yob,omitempty"`

// Attribute:
// gender
Expand Down
10 changes: 5 additions & 5 deletions adcom1/video_placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ type VideoPlacement struct {
// integer
// Definition:
// Width of the placement in units specified by unit.
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Attribute:
// h
// Type:
// integer
// Definition:
// Height of the placement in units specified by unit.
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Attribute:
// unit
Expand Down Expand Up @@ -168,15 +168,15 @@ type VideoPlacement struct {
// integer
// Definition:
// Minimum bit rate of the creative in Kbps.
MinBitR uint64 `json:"minbitr,omitempty"`
MinBitR int64 `json:"minbitr,omitempty"`

// Attribute:
// maxbitr
// Type:
// integer
// Definition:
// Maximum bit rate of the creative in Kbps.
MaxBitR uint64 `json:"maxbitr,omitempty"`
MaxBitR int64 `json:"maxbitr,omitempty"`

// Attribute:
// delivery
Expand All @@ -194,7 +194,7 @@ type VideoPlacement struct {
// integer
// Definition:
// The maximum number of ads that can be played in an ad pod.
MaxSeq int `json:"maxseq,omitempty"`
MaxSeq int64 `json:"maxseq,omitempty"`

// Attribute:
// linear
Expand Down
8 changes: 4 additions & 4 deletions native1/request/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Image struct {
// integer
// Description:
// Width of the image in pixels.
W uint64 `json:"w,omitempty"`
W int64 `json:"w,omitempty"`

// Field:
// wmin
Expand All @@ -45,7 +45,7 @@ type Image struct {
// This option should be used for any rescaling of images by the client.
// Either w or wmin should be transmitted.
// If only w is included, it should be considered an exact requirement.
WMin uint64 `json:"wmin,omitempty"`
WMin int64 `json:"wmin,omitempty"`

// Field:
// h
Expand All @@ -55,7 +55,7 @@ type Image struct {
// integer
// Description:
// Height of the image in pixels.
H uint64 `json:"h,omitempty"`
H int64 `json:"h,omitempty"`

// Field:
// hmin
Expand All @@ -68,7 +68,7 @@ type Image struct {
// This option should be used for any rescaling of images by the client.
// Either h or hmin should be transmitted.
// If only h is included, it should be considered an exact requirement.
HMin uint64 `json:"hmin,omitempty"`
HMin int64 `json:"hmin,omitempty"`

// Field:
// mimes
Expand Down
Loading