fromsoapimportSoap# some SOAP service related methods are defined in soap.pyclassAdvertiser:''' classdocs '''def__init__(self,pid,name,vertical,useConv):''' Constructor '''self.id=pidself.name=nameself.vertical=verticalself.useConv=useConvdef__repr__(self):return"id: %s|name: %s|use conv: %s"%(self.id,self.name,self.useConv)def__str__(self):return"id: %s|name: %s|use conv: %s"%(self.id,self.name,self.useConv)@staticmethoddefGetItemRes(wurl,auth,pageIndex,pageSize,showExtInfo=True):client=Soap.SetupClient(wurl,auth,toAddToken=True,toImportMsgSrc=True,toImportArrSrc=False)# update paging infopaging=client.factory.create('ns1:ListPaging')paging['PageIndex']=pageIndexpaging['PageSize']=pageSize# update filter array - emptyfilterArrary=client.factory.create('ns0:ArrayOfAdvertiserServiceFilter')# get responseresponse=client.service.GetAdvertisers(filterArrary,paging,showExtInfo)returnresponse@staticmethoddefGetItem(response):objList=[]forrinresponse[1]['Advertisers']['AdvertiserInfo']:obj=Advertiser(r['ID'],r['AdvertiserName'],r['Vertical'],r['AdvertiserExtendedInfo']['UsesConversionTags'])objList.append(obj)returnobjList@staticmethoddefGetItemPgn(wurl,auth,pageIndex,pageSize,showExtInfo=True):objList=[]cond=Truewhilecond:response=Advertiser.GetItemRes(wurl,auth,pageIndex,pageSize,showExtInfo)objList=objList+Advertiser.GetItem(response)Soap.ShowProgress(response[1]['TotalCount'],len(objList),pageIndex,pageSize)iflen(objList)<response[1]['TotalCount']:pageIndex+=1else:cond=FalsereturnobjList@staticmethoddefGetFilter(objList):return[[obj.id]forobjinobjListifobj.userConv==True]
fromhelperimportHelper# some helper methods are defined in helper.pyfromuthenticationimportAuth# authentication object is defined in authentication.pyfromadvertiserimportAdvertiser# advertiser object/methods are defined in advertiser.pyimportlogging# python standard librarylogging.basicConfig(level=logging.INFO)logging.getLogger('suds.client').setLevel(logging.DEBUG)authWSDL='https://platform.mediamind.com/Eyeblaster.MediaMind.API/AuthenticationService.svc?wsdl'username='user name'password='password'appkey='application key'advertiserWSDL='https://platform.mediamind.com/Eyeblaster.MediaMind.API/AdvertiserService.svc?wsdl'## authenticate - authentication token is obtained in the constructorauth=Auth(username,password,appkey,authWSDL)## get advertisers - defined methods are executedadvRes=Advertiser.GetItemRes(advertiserWSDL,auth,pageIndex=0,pageSize=50,showExtInfo=True)advList=Advertiser.GetItem(advRes)Helper.PrintObjects(advList)