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

     1  package openrtb_ext
     2  
     3  import (
     4  	"github.com/prebid/prebid-server/v2/util/sliceutil"
     5  )
     6  
     7  // ExtRegs defines the contract for bidrequest.regs.ext
     8  type ExtRegs struct {
     9  	// DSA is an object containing DSA transparency information, see https://github.com/InteractiveAdvertisingBureau/openrtb/blob/main/extensions/community_extensions/dsa_transparency.md
    10  	DSA *ExtRegsDSA `json:"dsa,omitempty"`
    11  
    12  	// GDPR should be "1" if the caller believes the user is subject to GDPR laws, "0" if not, and undefined
    13  	// if it's unknown. For more info on this parameter, see: https://iabtechlab.com/wp-content/uploads/2018/02/OpenRTB_Advisory_GDPR_2018-02.pdf
    14  	GDPR *int8 `json:"gdpr,omitempty"`
    15  
    16  	// USPrivacy should be a four character string, see: https://iabtechlab.com/wp-content/uploads/2019/11/OpenRTB-Extension-U.S.-Privacy-IAB-Tech-Lab.pdf
    17  	USPrivacy string `json:"us_privacy,omitempty"`
    18  }
    19  
    20  // ExtRegsDSA defines the contract for bidrequest.regs.ext.dsa
    21  type ExtRegsDSA struct {
    22  	Required     *int8                   `json:"dsarequired,omitempty"`
    23  	PubRender    *int8                   `json:"pubrender,omitempty"`
    24  	DataToPub    *int8                   `json:"datatopub,omitempty"`
    25  	Transparency []ExtBidDSATransparency `json:"transparency,omitempty"`
    26  }
    27  
    28  // Clone creates a deep copy of ExtRegsDSA
    29  func (erd *ExtRegsDSA) Clone() *ExtRegsDSA {
    30  	if erd == nil {
    31  		return nil
    32  	}
    33  	clone := *erd
    34  
    35  	if erd.Required != nil {
    36  		clonedRequired := *erd.Required
    37  		clone.Required = &clonedRequired
    38  	}
    39  	if erd.PubRender != nil {
    40  		clonedPubRender := *erd.PubRender
    41  		clone.PubRender = &clonedPubRender
    42  	}
    43  	if erd.DataToPub != nil {
    44  		clonedDataToPub := *erd.DataToPub
    45  		clone.DataToPub = &clonedDataToPub
    46  	}
    47  	if erd.Transparency != nil {
    48  		clonedTransparency := make([]ExtBidDSATransparency, len(erd.Transparency))
    49  		for i, transparency := range erd.Transparency {
    50  			newTransparency := transparency
    51  			newTransparency.Params = sliceutil.Clone(transparency.Params)
    52  			clonedTransparency[i] = newTransparency
    53  		}
    54  		clone.Transparency = clonedTransparency
    55  	}
    56  	return &clone
    57  }
    58  
    59  // ExtBidDSATransparency defines the contract for bidrequest.regs.ext.dsa.transparency
    60  type ExtBidDSATransparency struct {
    61  	Domain string `json:"domain,omitempty"`
    62  	Params []int  `json:"dsaparams,omitempty"`
    63  }