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

Commit

Permalink
Merge pull request #49 from SyntaxNode/openrtb26_ptr
Browse files Browse the repository at this point in the history
v16: Pointer Fixes
  • Loading branch information
mxmCherry authored Jun 24, 2022
2 parents 10106af + 3871bcb commit 0784d79
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
14 changes: 14 additions & 0 deletions adcom1/connection_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type ConnectionType int8

// Options for the type of device connectivity.
const (
ConnectionUnknown ConnectionType = 0 // 0 Unknown
ConnectionEthernet ConnectionType = 1 // 1 Ethernet; Wired Connection
ConnectionWIFI ConnectionType = 2 // 2 WIFI
ConnectionCellular ConnectionType = 3 // 3 Cellular Network - Unknown Generation
Expand All @@ -13,3 +14,16 @@ const (
Connection4G ConnectionType = 6 // 6 Cellular Network - 4G
Connection5G ConnectionType = 7 // 7 Cellular Network - 5G
)

// Ptr returns pointer to own value.
func (c ConnectionType) Ptr() *ConnectionType {
return &c
}

// Val safely dereferences pointer, returning default value (ConnectionUnknown) for nil.
func (c *ConnectionType) Val() ConnectionType {
if c == nil {
return ConnectionUnknown
}
return *c
}
2 changes: 1 addition & 1 deletion adcom1/placement_position.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (p PlacementPosition) Ptr() *PlacementPosition {
return &p
}

// Val safely dereferences pointer, returning default value (AdPositionUnknown) for nil.
// Val safely dereferences pointer, returning default value (PositionUnknown) for nil.
func (p *PlacementPosition) Val() PlacementPosition {
if p == nil {
return PositionUnknown
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ type Device struct {
// AdCOM 1.0.
// Note:
// OpenRTB <=2.5 defined only connection types 1..6.
ConnectionType adcom1.ConnectionType `json:"connectiontype,omitempty"`
ConnectionType *adcom1.ConnectionType `json:"connectiontype,omitempty"`

// Attribute:
// ifa
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ type Video struct {
// Description:
// Ad position on screen. Refer to List: Placement Positions in
// AdCOM 1.0.
Pos adcom1.PlacementPosition `json:"pos,omitempty"`
Pos *adcom1.PlacementPosition `json:"pos,omitempty"`

// Attribute:
// companionad
Expand Down
13 changes: 13 additions & 0 deletions openrtb3/no_bid_reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ const (
NoBidIncompleteSupplyChain NoBidReason = 16 // Incomplete SupplyChain
NoBidBlockedSupplyChainNode NoBidReason = 17 // Blocked SupplyChain Node
)

// Ptr returns pointer to own value.
func (n NoBidReason) Ptr() *NoBidReason {
return &n
}

// Val safely dereferences pointer, returning default value (NoBidUnknownError) for nil.
func (n *NoBidReason) Val() NoBidReason {
if n == nil {
return NoBidUnknownError
}
return *n
}

0 comments on commit 0784d79

Please sign in to comment.