Skip to content

3. Config

iamankit1995 edited this page May 2, 2019 · 1 revision

Configs are for controlling different conversion settings at request or response level. Some use-cases covered include option to set the native request/response format, switching validations on or off or setting the ad type for each impression.

Sample Config

{
  "nativeRequestAsString" : true,
  "nativeResponseAsString" : true,
  "adTypeMapping" : {
  		"imp1" : "BANNER",
		"imp2" : "NATIVE"
  },
  "validate" : false,
  "disableCloning" : false,
  "openrtb2_XVersion" : "TWO_DOT_FOUR"
}
S.no Config Fields Purpose Data type Default value
1 nativeRequestAsString True- Native request field will be converted to string. False - Native request field will be converted to object boolean TRUE
2 nativeResponseAsString True - Native response adm will be converted to string. False - Native response will be converted to object boolean TRUE
3 adTypeMapping To identify AdType while converting response. This stores the mapping to impressionId/itemId to adType. AdType (enum) (following values of adType are supported - BANNER, VIDEO, NATIVE, AUDIO) BANNER
4 disableCloning True - Shallow copy of objects will be saved during conversion. False - Deep copy of objects will be saved during conversion. boolean FALSE
5 validate True - Source object will be validated against the constraints specified by IAB. False - Source object will not be validated. boolean FALSE
6 openrtb2_XVersion OpenRtb 2_X version used during the conversion OpenRtbVersion(enum) (values supported are - TWO_DOT_FIVE, TWO_DOT_FOUR,TWO_DOT_THREE) TWO_DOT_FIVE

Creating Config

Create Via setters

Config config = new Config();
config.setNativeRequestAsString(true);
config.setAdTypeMapping(adTypeMapping);

Create via Constructor through existing config

Config oldConfig = …;
Config config = new Config(oldConfig);

Create Config from Json

**From String** 
String stringContent = …;
Config config = Config.fromJson(stringContent);

**Create config from input stream Json -**
InputStream inpStr = …;
Config config = Config.fromJson(inpStr);

**Read config object stored in JSON format from file - **
File file = …;
ClassLoader classLoader = …;
Config config = Config.fromJson(file, classLoader);
Config config = Config.fromJson(file);

**Read config object stored in Json format from a reader -**
Reader reader = …;
Config config = Config.fromJson(reader);

Create config from YAML

**From String-** 
String yamlString = …;
Config config = Config.fromYaml(yamlString);

**YAML inputstream -**
InputStream inputStream = …;
Config config = Config.fromYaml(inputStream);

**YAML from file -**
File file = …;
ClassLoader classLoader = …;
Config config = Config.fromYaml(file);
Config config = Config.fromYaml(file, classLoader);

**YAML from Url -**
URL url = …;
Config config = Config.fromYaml(url);

**YAML from reader -**
Reader reader = …;
Config config = Config.fromYaml(reader);