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

     1  package openrtb_ext
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/prebid/openrtb/v20/adcom1"
     7  	"github.com/prebid/openrtb/v20/openrtb2"
     8  )
     9  
    10  // ExtBidResponse defines the contract for bidresponse.ext
    11  type ExtBidResponse struct {
    12  	Debug *ExtResponseDebug `json:"debug,omitempty"`
    13  	// Errors defines the contract for bidresponse.ext.errors
    14  	Errors   map[BidderName][]ExtBidderMessage `json:"errors,omitempty"`
    15  	Warnings map[BidderName][]ExtBidderMessage `json:"warnings,omitempty"`
    16  	// ResponseTimeMillis defines the contract for bidresponse.ext.responsetimemillis
    17  	ResponseTimeMillis map[BidderName]int `json:"responsetimemillis,omitempty"`
    18  	// RequestTimeoutMillis returns the timeout used in the auction.
    19  	// This is useful if the timeout is saved in the Stored Request on the server.
    20  	// Clients can run one auction, and then use this to set better connection timeouts on future auction requests.
    21  	RequestTimeoutMillis int64 `json:"tmaxrequest,omitempty"`
    22  	// ResponseUserSync defines the contract for bidresponse.ext.usersync
    23  	Usersync map[BidderName]*ExtResponseSyncData `json:"usersync,omitempty"`
    24  	// Prebid defines the contract for bidresponse.ext.prebid
    25  	Prebid *ExtResponsePrebid `json:"prebid,omitempty"`
    26  }
    27  
    28  // ExtResponseDebug defines the contract for bidresponse.ext.debug
    29  type ExtResponseDebug struct {
    30  	// HttpCalls defines the contract for bidresponse.ext.debug.httpcalls
    31  	HttpCalls map[BidderName][]*ExtHttpCall `json:"httpcalls,omitempty"`
    32  	// Request after resolution of stored requests and debug overrides
    33  	ResolvedRequest json.RawMessage `json:"resolvedrequest,omitempty"`
    34  }
    35  
    36  // ExtResponseSyncData defines the contract for bidresponse.ext.usersync.{bidder}
    37  type ExtResponseSyncData struct {
    38  	Status CookieStatus `json:"status"`
    39  	// Syncs must have length > 0
    40  	Syncs []*ExtUserSync `json:"syncs"`
    41  }
    42  
    43  // ExtResponsePrebid defines the contract for bidresponse.ext.prebid
    44  type ExtResponsePrebid struct {
    45  	AuctionTimestamp int64             `json:"auctiontimestamp,omitempty"`
    46  	Passthrough      json.RawMessage   `json:"passthrough,omitempty"`
    47  	Modules          json.RawMessage   `json:"modules,omitempty"`
    48  	Fledge           *Fledge           `json:"fledge,omitempty"`
    49  	Targeting        map[string]string `json:"targeting,omitempty"`
    50  	// SeatNonBid holds the array of Bids which are either rejected, no bids inside bidresponse.ext.prebid.seatnonbid
    51  	SeatNonBid []SeatNonBid `json:"seatnonbid,omitempty"`
    52  }
    53  
    54  // FledgeResponse defines the contract for bidresponse.ext.fledge
    55  type Fledge struct {
    56  	AuctionConfigs []*FledgeAuctionConfig `json:"auctionconfigs,omitempty"`
    57  }
    58  
    59  // FledgeAuctionConfig defines the container for bidresponse.ext.fledge.auctionconfigs[]
    60  type FledgeAuctionConfig struct {
    61  	ImpId   string          `json:"impid"`
    62  	Bidder  string          `json:"bidder,omitempty"`
    63  	Adapter string          `json:"adapter,omitempty"`
    64  	Config  json.RawMessage `json:"config"`
    65  }
    66  
    67  // ExtUserSync defines the contract for bidresponse.ext.usersync.{bidder}.syncs[i]
    68  type ExtUserSync struct {
    69  	Url  string       `json:"url"`
    70  	Type UserSyncType `json:"type"`
    71  }
    72  
    73  // ExtBidderMessage defines an error object to be returned, consiting of a machine readable error code, and a human readable error message string.
    74  type ExtBidderMessage struct {
    75  	Code    int    `json:"code"`
    76  	Message string `json:"message"`
    77  }
    78  
    79  // ExtHttpCall defines the contract for a bidresponse.ext.debug.httpcalls.{bidder}[i]
    80  type ExtHttpCall struct {
    81  	Uri            string              `json:"uri"`
    82  	RequestBody    string              `json:"requestbody"`
    83  	RequestHeaders map[string][]string `json:"requestheaders"`
    84  	ResponseBody   string              `json:"responsebody"`
    85  	Status         int                 `json:"status"`
    86  }
    87  
    88  // CookieStatus describes the allowed values for bidresponse.ext.usersync.{bidder}.status
    89  type CookieStatus string
    90  
    91  const (
    92  	CookieNone      CookieStatus = "none"
    93  	CookieExpired   CookieStatus = "expired"
    94  	CookieAvailable CookieStatus = "available"
    95  )
    96  
    97  // UserSyncType describes the allowed values for bidresponse.ext.usersync.{bidder}.syncs[i].type
    98  type UserSyncType string
    99  
   100  const (
   101  	UserSyncIframe UserSyncType = "iframe"
   102  	UserSyncPixel  UserSyncType = "pixel"
   103  )
   104  
   105  // NonBidObject is subset of Bid object with exact json signature
   106  // It also contains the custom fields
   107  type NonBidObject struct {
   108  	// SubSet
   109  	Price   float64                 `json:"price,omitempty"`
   110  	ADomain []string                `json:"adomain,omitempty"`
   111  	CatTax  adcom1.CategoryTaxonomy `json:"cattax,omitempty"`
   112  	Cat     []string                `json:"cat,omitempty"`
   113  	DealID  string                  `json:"dealid,omitempty"`
   114  	W       int64                   `json:"w,omitempty"`
   115  	H       int64                   `json:"h,omitempty"`
   116  	Dur     int64                   `json:"dur,omitempty"`
   117  	MType   openrtb2.MarkupType     `json:"mtype,omitempty"`
   118  
   119  	// Custom Fields
   120  	OriginalBidCPM float64 `json:"origbidcpm,omitempty"`
   121  	OriginalBidCur string  `json:"origbidcur,omitempty"`
   122  }
   123  
   124  // ExtResponseNonBidPrebid represents bidresponse.ext.prebid.seatnonbid[].nonbid[].ext
   125  type ExtResponseNonBidPrebid struct {
   126  	Bid NonBidObject `json:"bid"`
   127  }
   128  
   129  type NonBidExt struct {
   130  	Prebid ExtResponseNonBidPrebid `json:"prebid"`
   131  }
   132  
   133  // NonBid represnts the Non Bid Reason (statusCode) for given impression ID
   134  type NonBid struct {
   135  	ImpId      string    `json:"impid"`
   136  	StatusCode int       `json:"statuscode"`
   137  	Ext        NonBidExt `json:"ext"`
   138  }
   139  
   140  // SeatNonBid is collection of NonBid objects with seat information
   141  type SeatNonBid struct {
   142  	NonBid []NonBid        `json:"nonbid"`
   143  	Seat   string          `json:"seat"`
   144  	Ext    json.RawMessage `json:"ext"`
   145  }