@@ -23,8 +23,9 @@ use crate::integrations::{
2323 IntegrationRegistration ,
2424} ;
2525use crate :: openrtb:: {
26- Banner , Device , Format , Geo , Imp , ImpExt , OpenRtbRequest , PrebidExt , PrebidImpExt , Regs ,
27- RegsExt , RequestExt , Site , TrustedServerExt , User , UserExt ,
26+ build_banner, build_device, build_format, build_geo, build_imp, build_openrtb_request,
27+ build_regs, build_site, build_user, maybe_object_from_serializable, ImpExt , OpenRtbRequest ,
28+ PrebidExt , PrebidImpExt , RegsExt , RequestExt , TrustedServerExt , UserExt ,
2829} ;
2930use crate :: request_signing:: { RequestSigner , SigningParams , SIGNING_VERSION } ;
3031use crate :: settings:: { IntegrationConfig , Settings } ;
@@ -488,18 +489,15 @@ impl PrebidAuctionProvider {
488489 context : & AuctionContext < ' _ > ,
489490 signer : Option < ( & RequestSigner , String , & SigningParams ) > ,
490491 ) -> OpenRtbRequest {
491- let imps: Vec < Imp > = request
492+ let imps = request
492493 . slots
493494 . iter ( )
494495 . map ( |slot| {
495- let formats: Vec < Format > = slot
496+ let formats = slot
496497 . formats
497498 . iter ( )
498499 . filter ( |f| f. media_type == MediaType :: Banner )
499- . map ( |f| Format {
500- w : f. width ,
501- h : f. height ,
502- } )
500+ . map ( |f| build_format ( f. width , f. height ) )
503501 . collect ( ) ;
504502
505503 // Extract zone from trustedServer params (sent by the JS
@@ -552,13 +550,13 @@ impl PrebidAuctionProvider {
552550 }
553551 }
554552
555- Imp {
556- id : slot. id . clone ( ) ,
557- banner : Some ( Banner { format : formats } ) ,
558- ext : Some ( ImpExt {
553+ build_imp (
554+ slot. id . clone ( ) ,
555+ Some ( build_banner ( formats) ) ,
556+ maybe_object_from_serializable ( & ImpExt {
559557 prebid : PrebidImpExt { bidder } ,
560558 } ) ,
561- }
559+ )
562560 } )
563561 . collect ( ) ;
564562
@@ -572,35 +570,36 @@ impl PrebidAuctionProvider {
572570 } ) ;
573571
574572 // Build user object
575- let user = Some ( User {
576- id : Some ( request. user . id . clone ( ) ) ,
577- ext : Some ( UserExt {
573+ let user = Some ( build_user (
574+ Some ( request. user . id . clone ( ) ) ,
575+ maybe_object_from_serializable ( & UserExt {
578576 synthetic_fresh : Some ( request. user . fresh_id . clone ( ) ) ,
579577 } ) ,
580- } ) ;
578+ ) ) ;
581579
582580 // Build device object with user-agent, client IP, and geo if available.
583581 // Forwarding the real client IP is critical: without it PBS infers the
584582 // IP from the incoming connection (a data-center / edge IP), causing
585583 // bidders like PubMatic to filter the traffic as non-human.
586- let device = request. device . as_ref ( ) . map ( |d| Device {
587- ua : d. user_agent . clone ( ) ,
588- ip : d. ip . clone ( ) ,
589- geo : d. geo . as_ref ( ) . map ( |geo| Geo {
590- geo_type : 2 , // IP address per OpenRTB spec
591- country : Some ( geo. country . clone ( ) ) ,
592- city : Some ( geo. city . clone ( ) ) ,
593- region : geo. region . clone ( ) ,
594- } ) ,
584+ let device = request. device . as_ref ( ) . map ( |d| {
585+ build_device (
586+ d. user_agent . clone ( ) ,
587+ d. ip . clone ( ) ,
588+ d. geo . as_ref ( ) . map ( |geo| {
589+ build_geo (
590+ Some ( geo. country . clone ( ) ) ,
591+ Some ( geo. city . clone ( ) ) ,
592+ geo. region . clone ( ) ,
593+ )
594+ } ) ,
595+ )
595596 } ) ;
596597
597598 // Build regs object if Sec-GPC header is present
598599 let regs = if context. request . get_header ( "Sec-GPC" ) . is_some ( ) {
599- Some ( Regs {
600- ext : Some ( RegsExt {
601- us_privacy : Some ( "1YYN" . to_string ( ) ) ,
602- } ) ,
603- } )
600+ Some ( build_regs ( maybe_object_from_serializable ( & RegsExt {
601+ us_privacy : Some ( "1YYN" . to_string ( ) ) ,
602+ } ) ) )
604603 } else {
605604 None
606605 } ;
@@ -620,7 +619,7 @@ impl PrebidAuctionProvider {
620619
621620 let debug_enabled = self . config . debug ;
622621
623- let ext = Some ( RequestExt {
622+ let ext = maybe_object_from_serializable ( & RequestExt {
624623 prebid : Some ( PrebidExt {
625624 debug : debug_enabled. then_some ( true ) ,
626625 returnallbidstatus : debug_enabled. then_some ( true ) ,
@@ -635,19 +634,16 @@ impl PrebidAuctionProvider {
635634 } ) ,
636635 } ) ;
637636
638- OpenRtbRequest {
639- id : request. id . clone ( ) ,
640- imp : imps,
641- site : Some ( Site {
642- domain : Some ( request. publisher . domain . clone ( ) ) ,
643- page : page_url,
644- } ) ,
637+ build_openrtb_request (
638+ request. id . clone ( ) ,
639+ imps,
640+ Some ( build_site ( Some ( request. publisher . domain . clone ( ) ) , page_url) ) ,
645641 user,
646642 device,
647643 regs,
648- test : self . config . test_mode . then_some ( 1 ) ,
644+ self . config . test_mode . then_some ( 1 ) ,
649645 ext,
650- }
646+ )
651647 }
652648
653649 /// Parse `OpenRTB` response into auction response.
0 commit comments