-
Notifications
You must be signed in to change notification settings - Fork 9
Home
CoderOnAHigh edited this page May 8, 2019
·
27 revisions
The below snippet shows how to get started with using the library.
Config config = new Config(); // create config object & fill in the necessary fields
OpenRtbConverter openRtbConverter = new OpenRtbConverter(config); // construct the openrtbConverter object
try {
// converting openrtb wrapper containing openRtb 3.0 object into 2.5* bidRequest object
BidRequest2_X bidRequest = openRtbConverter.convert(openRtbWrapper, OpenRTBWrapper3_X.class, BidRequest2_X.class);
// converting BidRequest 2.5* object into openRtb wrapper containing openRtb 3.0 object
OpenRTBWrapper3_X openRtbWrapper = openRtbConverter.convert(bidRequest, BidRequest2_X.class, OpenRTBWrapper3_X.class);
// converting stringified json form of BidRequest 2.5* object into openRtb wrapper containing openRtb 3.0 object
String openRtbWrapper = openRtbConverter.convert(bidRequestString, BidRequest2_X.class, OpenRTBWrapper3_X.class);
// converting openrtb wrapper containing OpenRtb 3.0 object into BidResponse 2.5* object
BidResponse2_X bidResponse = openRtbConverter.convert(openRtb, OpenRTBWrapper3_X.class, BidResponse2_X.class);
// converting 2.5* BidResponse.class object to Openrtb wrapper containing OpenRtb 3.0 object
OpenRTBWrapper3_X openRtb = openRtbConverter.convert(bidResponse, BidResponse2_X.class, OpenRTBWrapper3_X.class);
}
catch (OpenRtbException e) {
// do logging or failure fallback stuff
}
Note*: For conversion to/from version 2.3/2.4, please see section: link
For quick bootstrapping, one can deploy the converter-example jar and use it to convert json requests and responses. For more details please visit this link
Sample 3.0 Request - link
Converted 2.5 Request - link
Sample 3.0 Response - link
Converted 2.5 Response - link