github.com/prebid/prebid-server/v2@v2.18.0/openrtb_ext/imp.go (about)

     1  package openrtb_ext
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/prebid/openrtb/v20/openrtb2"
     7  )
     8  
     9  // AuctionEnvironmentType is a Google Privacy Sandbox flag indicating where the auction may take place
    10  type AuctionEnvironmentType int8
    11  
    12  const (
    13  	// 0 Standard server-side auction
    14  	ServerSideAuction AuctionEnvironmentType = 0
    15  	// 1 On-device interest group auction (FLEDGE)
    16  	OnDeviceIGAuctionFledge AuctionEnvironmentType = 1
    17  	// 2 Server-side with interest group simulation
    18  	ServerSideWithIGSimulation AuctionEnvironmentType = 2
    19  )
    20  
    21  // IsRewardedInventoryKey is the json key for ExtImpPrebid.IsRewardedInventory
    22  const IsRewardedInventoryKey = "is_rewarded_inventory"
    23  
    24  // OptionsKey is the json key for ExtImpPrebid.Options
    25  const OptionsKey = "options"
    26  
    27  // ExtImpPrebid defines the contract for bidrequest.imp[i].ext.prebid
    28  type ExtImpPrebid struct {
    29  	// StoredRequest specifies which stored impression to use, if any.
    30  	StoredRequest *ExtStoredRequest `json:"storedrequest,omitempty"`
    31  
    32  	// StoredResponse specifies which stored impression to use, if any.
    33  	StoredAuctionResponse *ExtStoredAuctionResponse `json:"storedauctionresponse,omitempty"`
    34  
    35  	// Stored bid response determines if imp has stored bid response for bidder
    36  	StoredBidResponse []ExtStoredBidResponse `json:"storedbidresponse,omitempty"`
    37  
    38  	// IsRewardedInventory is a signal intended for video impressions. Must be 0 or 1.
    39  	IsRewardedInventory *int8 `json:"is_rewarded_inventory,omitempty"`
    40  
    41  	// Bidder is the preferred approach for providing parameters to be interpreted by the bidder's adapter.
    42  	Bidder map[string]json.RawMessage `json:"bidder,omitempty"`
    43  
    44  	Options *Options `json:"options,omitempty"`
    45  
    46  	Passthrough json.RawMessage `json:"passthrough,omitempty"`
    47  
    48  	Floors *ExtImpPrebidFloors `json:"floors,omitempty"`
    49  }
    50  
    51  type ExtImpDataAdServer struct {
    52  	Name   string `json:"name"`
    53  	AdSlot string `json:"adslot"`
    54  }
    55  
    56  type ExtImpData struct {
    57  	PbAdslot string              `json:"pbadslot,omitempty"`
    58  	AdServer *ExtImpDataAdServer `json:"adserver,omitempty"`
    59  }
    60  
    61  type ExtImpPrebidFloors struct {
    62  	FloorRule      string  `json:"floorrule,omitempty"`
    63  	FloorRuleValue float64 `json:"floorrulevalue,omitempty"`
    64  	FloorValue     float64 `json:"floorvalue,omitempty"`
    65  	FloorMin       float64 `json:"floormin,omitempty"`
    66  	FloorMinCur    string  `json:"floorminCur,omitempty"`
    67  }
    68  
    69  // ExtStoredRequest defines the contract for bidrequest.imp[i].ext.prebid.storedrequest
    70  type ExtStoredRequest struct {
    71  	ID string `json:"id"`
    72  }
    73  
    74  // ExtStoredAuctionResponse defines the contract for bidrequest.imp[i].ext.prebid.storedauctionresponse
    75  type ExtStoredAuctionResponse struct {
    76  	ID string `json:"id"`
    77  }
    78  
    79  // ExtStoredBidResponse defines the contract for bidrequest.imp[i].ext.prebid.storedbidresponse
    80  type ExtStoredBidResponse struct {
    81  	ID           string `json:"id"`
    82  	Bidder       string `json:"bidder"`
    83  	ReplaceImpId *bool  `json:"replaceimpid"`
    84  }
    85  
    86  type Options struct {
    87  	EchoVideoAttrs bool `json:"echovideoattrs"`
    88  }
    89  
    90  // GetImpIDs returns slice of all impression Ids from impList
    91  func GetImpIDs(imps []openrtb2.Imp) []string {
    92  	impIDs := make([]string, len(imps))
    93  	for i := range imps {
    94  		impIDs[i] = imps[i].ID
    95  	}
    96  	return impIDs
    97  }