4242RadiusCriterion = _CAMPAIGN_OBJECT_FACTORY_V12 .create ('RadiusCriterion' )
4343TargetSetting_Type = type (_CAMPAIGN_OBJECT_FACTORY_V12 .create ('TargetSetting' ))
4444CoOpSetting_Type = type (_CAMPAIGN_OBJECT_FACTORY_V12 .create ('CoOpSetting' ))
45+ TextAsset_Type = type (_CAMPAIGN_OBJECT_FACTORY_V12 .create ('TextAsset' ))
46+ ImageAsset_Type = type (_CAMPAIGN_OBJECT_FACTORY_V12 .create ('ImageAsset' ))
4547
4648def bulk_str (value ):
4749 if value is None or (hasattr (value , 'value' ) and value .value is None ):
@@ -402,31 +404,32 @@ def csv_to_field_Rsa_TextAssetLinks(assetLinks, value):
402404
403405 for assetLinkContract in assetLinkContracts :
404406 asset_link = _CAMPAIGN_OBJECT_FACTORY_V12 .create ('AssetLink' )
407+ asset_link .Asset = _CAMPAIGN_OBJECT_FACTORY_V12 .create ('TextAsset' )
405408 asset_link .Asset .Type = 'TextAsset'
406- asset_link .Asset .Id = assetLinkContract ['id' ]
407- asset_link .Asset .Text = assetLinkContract ['text' ]
408- asset_link .Asset .Name = assetLinkContract ['name' ]
409- asset_link .AssetPerformanceLabel = assetLinkContract ['assetPerformanceLabel' ]
410- asset_link .PinnedField = assetLinkContract ['pinnedField' ]
411- asset_link .EditorialStatus = assetLinkContract ['editorialStatus' ]
409+ asset_link .Asset .Id = assetLinkContract ['id' ] if 'id' in assetLinkContract else None
410+ asset_link .Asset .Text = assetLinkContract ['text' ] if 'text' in assetLinkContract else None
411+ asset_link .Asset .Name = assetLinkContract ['name' ] if 'name' in assetLinkContract else None
412+ asset_link .AssetPerformanceLabel = assetLinkContract ['assetPerformanceLabel' ] if 'assetPerformanceLabel' in assetLinkContract else None
413+ asset_link .PinnedField = assetLinkContract ['pinnedField' ] if 'pinnedField' in assetLinkContract else None
414+ asset_link .EditorialStatus = assetLinkContract ['editorialStatus' ] if 'editorialStatus' in assetLinkContract else None
412415 assetLinks .AssetLink .append (asset_link )
413416
414417def field_to_csv_ImageAssetLinks (entity ):
415418 if entity is None or entity .AssetLink is None :
416419 return None
417420 assetLinkContracts = []
418421 for assetLink in entity .AssetLink :
419- if assetLink .Asset is not None and assetLink .Asset . Type == 'ImageAsset' :
422+ if assetLink .Asset is not None and isinstance ( assetLink .Asset , ImageAsset_Type ) :
420423 contract = {}
421- contract ['cropHeight' ] = assetLink .Asset .CropHeight
422- contract ['cropWidth' ] = assetLink .Asset .CropWidth
423- contract ['cropX' ] = assetLink .Asset .CropX
424- contract ['cropY' ] = assetLink .Asset .CropY
425- contract ['id' ] = assetLink .Asset .Id
426- contract ['name' ] = assetLink .Asset .Name
427- contract ['assetPerformanceLabel' ] = assetLink .AssetPerformanceLabel
428- contract ['editorialStatus' ] = assetLink .EditorialStatus
429- contract ['pinnedField' ] = assetLink .PinnedField
424+ contract ['cropHeight' ] = assetLink .Asset .CropHeight if hasattr ( assetLink . Asset , 'CropHeight' ) else None
425+ contract ['cropWidth' ] = assetLink .Asset .CropWidth if hasattr ( assetLink . Asset , 'CropWidth' ) else None
426+ contract ['cropX' ] = assetLink .Asset .CropX if hasattr ( assetLink . Asset , 'CropX' ) else None
427+ contract ['cropY' ] = assetLink .Asset .CropY if hasattr ( assetLink . Asset , 'CropY' ) else None
428+ contract ['id' ] = assetLink .Asset .Id if hasattr ( assetLink . Asset , 'Id' ) else None
429+ contract ['name' ] = assetLink .Asset .Name if hasattr ( assetLink . Asset , 'Name' ) else None
430+ contract ['assetPerformanceLabel' ] = assetLink .AssetPerformanceLabel if hasattr ( assetLink , 'AssetPerformanceLabel' ) else None
431+ contract ['editorialStatus' ] = assetLink .EditorialStatus if hasattr ( assetLink , 'EditorialStatus' ) else None
432+ contract ['pinnedField' ] = assetLink .PinnedField if hasattr ( assetLink , 'PinnedField' ) else None
430433 assetLinkContracts .append (contract )
431434 if len (assetLinkContracts ) > 0 :
432435 return json .dumps (assetLinkContracts )
@@ -439,31 +442,32 @@ def csv_to_field_ImageAssetLinks(assetLinks, value):
439442
440443 for assetLinkContract in assetLinkContracts :
441444 asset_link = _CAMPAIGN_OBJECT_FACTORY_V12 .create ('AssetLink' )
445+ asset_link .Asset = _CAMPAIGN_OBJECT_FACTORY_V12 .create ('ImageAsset' )
442446 asset_link .Asset .Type = 'ImageAsset'
443- asset_link .Asset .CropHeight = assetLinkContract ['cropHeight' ]
444- asset_link .Asset .CropWidth = assetLinkContract ['cropWidth' ]
445- asset_link .Asset .CropX = assetLinkContract ['cropX' ]
446- asset_link .Asset .CropY = assetLinkContract ['cropY' ]
447- asset_link .Asset .Id = assetLinkContract ['id' ]
448- asset_link .Asset .Name = assetLinkContract ['name' ]
449- asset_link .AssetPerformanceLabel = assetLinkContract ['assetPerformanceLabel' ]
450- asset_link .PinnedField = assetLinkContract ['pinnedField' ]
451- asset_link .EditorialStatus = assetLinkContract ['editorialStatus' ]
447+ asset_link .Asset .CropHeight = assetLinkContract ['cropHeight' ] if 'cropHeight' in assetLinkContract else None
448+ asset_link .Asset .CropWidth = assetLinkContract ['cropWidth' ] if 'cropWidth' in assetLinkContract else None
449+ asset_link .Asset .CropX = assetLinkContract ['cropX' ] if 'cropX' in assetLinkContract else None
450+ asset_link .Asset .CropY = assetLinkContract ['cropY' ] if 'cropY' in assetLinkContract else None
451+ asset_link .Asset .Id = assetLinkContract ['id' ] if 'id' in assetLinkContract else None
452+ asset_link .Asset .Name = assetLinkContract ['name' ] if 'name' in assetLinkContract else None
453+ asset_link .AssetPerformanceLabel = assetLinkContract ['assetPerformanceLabel' ] if 'assetPerformanceLabel' in assetLinkContract else None
454+ asset_link .PinnedField = assetLinkContract ['pinnedField' ] if 'pinnedField' in assetLinkContract else None
455+ asset_link .EditorialStatus = assetLinkContract ['editorialStatus' ] if 'editorialStatus' in assetLinkContract else None
452456 assetLinks .AssetLink .append (asset_link )
453457
454458def field_to_csv_Rsa_TextAssetLinks (entity ):
455459 if entity is None or entity .AssetLink is None :
456460 return None
457461 assetLinkContracts = []
458462 for assetLink in entity .AssetLink :
459- if assetLink .Asset is not None and assetLink .Asset . Type == 'TextAsset' :
463+ if assetLink .Asset is not None and isinstance ( assetLink .Asset , TextAsset_Type ) :
460464 contract = {}
461- contract ['id' ] = assetLink .Asset .Id
462- contract ['name' ] = assetLink .Asset .Name
463- contract ['text' ] = assetLink .Asset .Text
464- contract ['assetPerformanceLabel' ] = assetLink .AssetPerformanceLabel
465- contract ['editorialStatus' ] = assetLink .EditorialStatus
466- contract ['pinnedField' ] = assetLink .PinnedField
465+ contract ['id' ] = assetLink .Asset .Id if hasattr ( assetLink . Asset , 'Id' ) else None
466+ contract ['name' ] = assetLink .Asset .Name if hasattr ( assetLink . Asset , 'Name' ) else None
467+ contract ['text' ] = assetLink .Asset .Text if hasattr ( assetLink . Asset , 'Text' ) else None
468+ contract ['assetPerformanceLabel' ] = assetLink .AssetPerformanceLabel if hasattr ( assetLink , 'AssetPerformanceLabel' ) else None
469+ contract ['editorialStatus' ] = assetLink .EditorialStatus if hasattr ( assetLink , 'EditorialStatus' ) else None
470+ contract ['pinnedField' ] = assetLink .PinnedField if hasattr ( assetLink , 'PinnedField' ) else None
467471 assetLinkContracts .append (contract )
468472 if len (assetLinkContracts ) > 0 :
469473 return json .dumps (assetLinkContracts )
0 commit comments