def get_transactions(self, start_date, end_date): # return empty result set before Nov 30th 2017 as ShopStylers is used if start_date <= date(2017, 11, 30): return pandas.DataFrame() data = self.request(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['ia:conversion_id'], order_value=data['ia:sale_amount'], commision=data['ia:payout'], status=data['ia:conversion_status'], cc=data.apply(lambda x: self.detect_cc(x['ia:offer_name']), axis=1), timestamp=data.apply(lambda x: parse.parse_datetime( x['ia:datetime_conversion'], "%Y-%m-%d %H:%M:%S"), axis=1), advertiser_info=data['ia:offer_name'], order_id='', currency=data['ia:currency'], device='', ip='', user_agent='', source=data['ia:aff_sub1'], affiliate_network=self.affiliate, deal_type='CPS', exit_url='', merchant_name=data['ia:offer_name'], merchant_id='') return data
def get_transactions(self, start_date, end_date): data = self.request(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['atv:id'], order_value=data['atv:transaction_value'], commision=data['atv:commission'], status=data.apply( lambda x: self.detect_status(x['atv:status']), axis=1), cc='VN', timestamp=data.apply(lambda x: parse.parse_datetime( x['atv:transaction_time'], "%Y-%m-%dT%H:%M:%S"), axis=1), advertiser_info='', order_id=data['atv:transaction_id'], currency='VND', device=data.apply(lambda x: self.detect_device( x['atv:os'], x['atv:browser']), axis=1), ip='', user_agent=data.apply( lambda x: x['atv:os'] + ', ' + x['atv:browser'], axis=1), source=data['atv:utm_source'], affiliate_network=self.affiliate, deal_type='CPS', exit_url=data['atv:click_url'], merchant_name=data['atv:merchant'], merchant_id='', ) return data
def get_transactions(self, start_date, end_date): data = self.request(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['ph:conversion_item_id'], order_value=data['ph:item_value'], commision=data['ph:item_publisher_commission'], status=data['ph:item_status'], cc=data.apply( lambda x: x['ph:country'] if x['ph:country'] in ['ID', 'HK', 'MY', 'PH', 'SG', 'TH', 'VN'] else '', axis=1), timestamp=data.apply(lambda x: parse.parse_datetime(x['ph:conversion_time'], "%Y-%m-%d %H:%M:%S"), axis=1), advertiser_info=data['ph:advertiser_reference'], order_id=data['ph:conversion_id'], currency=data['ph:currency'], device=data.apply(lambda x: self.parse_device(x['ph:ref_device']), axis=1), ip=data['ph:referer_ip'], user_agent=data['ph:ref_device'], source=data['ph:publisher_reference'], affiliate_network=self.affiliate, deal_type='CPS', exit_url='', #TODO: use source_referer merchant_name=self.merchant_name, merchant_id=data.apply(lambda x: self.merchant_id + x['ph:country'], axis=1) ) return data
def get_transactions(self, start_date, end_date): data = self.request(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['ag:TransactionId'], order_value=data['ag:OrderAmount'], commision=data['ag:AffiliateCommissionAmount'], status=data.apply(lambda x: self.detect_status(x['ag:ApprovalStatus']), axis=1), cc=data.apply( lambda x: self.detect_cc(x['ag:OriginURL'], x['ag:ProgramName'], x['ag:AffiliateSiteId']), axis=1), timestamp=data.apply( lambda x: parse.parse_datetime(x['ag:TransactionDateTime'], "%d/%m/%Y %H:%M:%S"), axis=1), advertiser_info=data['ag:MerchantName'], order_id=data['ag:TransactionId'], currency='USD', device='', ip='', user_agent='', source=data['ag:AffiliateSubId'], affiliate_network=self.affiliate, deal_type='CPS', exit_url=data['ag:OriginURL'], merchant_name=data['ag:MerchantName'], merchant_id=data.apply(lambda x: self.affiliate + str(x['ag:MerchantId']), axis=1) ) return data
def parse_cpc(self, data): if len(data) > 0: data = mapper.map_to_ipg( data, id='', order_value='', commision=data['ho:Stat.payout'], status="approved", cc=data.apply(lambda x: self.detect_cc( "", x['ho:Offer.name'], x['ho:Country.name'], x[ 'ho:Stat.affiliate_info1'], x['ho:Stat.currency']), axis=1), timestamp=data.apply(lambda x: parse.parse_datetime( x['ho:Stat.date'], "%Y-%m-%d"), axis=1), advertiser_info='', order_id='', currency=data['ho:Stat.currency'], device=data.apply(lambda x: self.detect_device( x['ho:Browser.display_name'], None, x['ho:Offer.name']), axis=1), ip='', user_agent='', source=data['ho:Stat.source'], affiliate_network=self.affiliate, deal_type='CPC', exit_url='', merchant_name=data['ho:Offer.name'], merchant_id='', ) return data
def get_transactions(self, start_date, end_date): data = self.request(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['cf:Id'], order_value=data['cf:SaleValue'], commision=data['cf:Commission'], status=data.apply(lambda x: self.detect_status(x['cf:Status']), axis=1), cc=data.apply(lambda x: self.detect_cc(x['cf:TrafficSource']), axis=1), timestamp=data.apply(lambda x: parse.parse_datetime( self.detect_date_time(x['cf:DateCreated'].split('.')[0]), "%Y-%m-%dT%H:%M:%S"), axis=1), advertiser_info='', order_id=data['cf:OrderId'], currency='AUD', device='', ip=data['cf:CustomerIpAddress'], user_agent='', source=data['cf:UniqueId'], affiliate_network=self.affiliate, deal_type='CPS', exit_url=data['cf:TrafficSource'], merchant_name=data['cf:MerchantName'], merchant_id=data['cf:MerchantId']) return data
def get_transactions(self, start_date, end_date): data = pandas.DataFrame( data=self.request(start_date, end_date, 'statistics/actions')) data = data.rename(columns=lambda x: 'aa:' + x) data = mapper.map_to_ipg( data, id=data['aa:action_id'], order_value=data['aa:cart'], commision=data['aa:payment'], status=data.apply(lambda x: self.detect_status(x['aa:status']), axis=1), cc=data.apply(lambda x: self.detect_cc(x['aa:click_user_referer'], x['aa:website_name']), axis=1), timestamp=data.apply(lambda x: parse.parse_datetime( x['aa:action_date'], "%Y-%m-%d %H:%M:%S"), axis=1), advertiser_info='', order_id=data['aa:order_id'], currency=data['aa:currency'], device='', ip=data['aa:click_user_ip'], user_agent='', source=data['aa:subid'], affiliate_network=self.affiliate, deal_type='CPS', exit_url=data['aa:click_user_referer'], merchant_name=data['aa:advcampaign_name'], merchant_id=data['aa:advcampaign_id']) return data
def get_transactions(self, start_date, end_date): data = self.request(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['at:seqNo'], order_value=data['at:Total Price'], commision=data['at:Reward Amount'], status=data.apply(lambda x: self.parse_status(x['at:Status']), axis=1), cc='TH', timestamp=data.apply(lambda x: parse.parse_datetime( x['at:Occur Date'], "%Y/%m/%d %H:%M:%S"), axis=1), advertiser_info=data['at:Campaign Name'], order_id=data['at:Creative Id'], currency='THB', device='', ip='', user_agent=data['at:click_user_agent'] if 'at:click_user_agent' in data.columns else '', source=data['at:subid'] if 'at:subid' in data.columns else '', affiliate_network=self.affiliate, deal_type='CPS', exit_url='', merchant_name=data['at:Campaign Name'], merchant_id='') return data
def get_transactions(self, start_date, end_date): data = self.request(start_date, end_date) if len(data) > 0: country = data.apply(lambda x: self.detect_cc( str(x['cj:website-id']), x['cj:advertiser-name']), axis=1) data = mapper.map_to_ipg( data, id=data['cj:commission-id'], order_value=data['cj:sale-amount'], commision=data['cj:commission-amount'], status=data.apply(lambda x: self.detect_status( x['cj:action-status'], x['cj:sale-amount']), axis=1), cc=country, timestamp=data.apply(lambda x: parse.parse_datetime( x['cj:event-date'], "%Y-%m-%dT%H:%M:%S-%f"), axis=1), advertiser_info=data['cj:aid'], order_id=country + data.apply(lambda x: filter(str.isdigit, str(x['cj:order-id'])) or str(x['cj:order-id']), axis=1), currency='USD', device='', ip='', user_agent='', source=data['cj:sid'], affiliate_network=self.affiliate, deal_type='CPS', exit_url='', merchant_name=data['cj:advertiser-name'], merchant_id=data.apply( lambda x: self.affiliate + str(x['cj:cid']), axis=1)) data = self.convert_transactions(data) return data
def get_transactions(self, start_date, end_date): data = self.download(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['cs:Transaction ID'], order_value=data['cs:Order Value'], commision=data.apply( lambda x: self.detect_commission(x['cs:Commission']), axis=1), status=data.apply(lambda x: self.detect_status( x['cs:Status'], x['cs:Order Value']), axis=1), cc=data.apply(lambda x: self.detect_cc(x['cs:Website']), axis=1), timestamp=data.apply(lambda x: parse.parse_datetime( x['cs:Date (Time)'], "%Y-%m-%d (%H:%M:%S)"), axis=1), advertiser_info=data['cs:Program'], order_id=data['cs:Creative ID'], currency=data.apply( lambda x: self.detect_currency(x['cs:Commission']), axis=1), device='', ip=data['cs:IP Address'], user_agent='', source=data['cs:Member Id'], affiliate_network=self.affiliate, deal_type='CPS', exit_url=data['cs:URL'], merchant_name=data['cs:Program'], merchant_id=data.apply( lambda x: self.affiliate + str(x['cs:Program ID']), axis=1)) return data
def parse_cps(self, data): if len(data) > 0: country = data.apply(lambda x: self.detect_cc( x['ho:Stat.refer'], x['ho:Offer.name'], x['ho:Country.name'], x['ho:Stat.affiliate_info1'], x['ho:Stat.currency']), axis=1) data = mapper.map_to_ipg( data, id=data['ho:Stat.id'], order_value=data['ho:Stat.sale_amount'], commision=data['ho:Stat.payout'], status=data['ho:Stat.status'], cc=country, timestamp=data.apply( lambda x: parse.parse_datetime(x['ho:Stat.datetime']), axis=1), advertiser_info=data['ho:Stat.advertiser_info'], order_id=data['ho:Stat.advertiser_info'], currency=data['ho:Stat.currency'], device=data.apply(lambda x: self.detect_device( x['ho:Browser.display_name'], x[ 'ho:ConversionsMobile.device_os'], x['ho:Offer.name']), axis=1), ip=data['ho:Stat.ip'], user_agent=data['ho:Stat.user_agent'], source=data['ho:Stat.source'], affiliate_network=self.affiliate, deal_type='CPS', exit_url=data['ho:Stat.refer'], merchant_name=data['ho:Offer.name'] if self.merchant_name is None else self.merchant_name, merchant_id='' if self.merchant_id is None else self.merchant_id + country) return data
def get_transactions(self, start_date, end_date): data = self.request(start_date, end_date) if len(data) > 0: data = mapper.map_to_ipg( data, id=data['omg:TransactionID'], order_value=data.apply( lambda x: x['omg:TransactionValue'] if pandas.notnull(x['omg:TransactionValue']) else 0, axis=1), commision=data['omg:SR'], status=data.apply( lambda x: self.detect_status(x['omg:Status']), axis=1), cc=data.apply(lambda x: self.detect_cc(x['omg:Referrer'], x[ 'omg:Merchant'], x['omg:Product'], x['omg:UID2']), axis=1), timestamp=data.apply(lambda x: parse.parse_datetime( x['omg:TransactionTime'], '%d/%m/%Y %H:%M:%S'), axis=1), advertiser_info=data['omg:Merchant'], order_id=data['omg:MerchantRef'], currency=data.apply(lambda x: x['omg:Currency'].strip(), axis=1), device='', ip='', user_agent='', source=data['omg:UID'], affiliate_network=self.affiliate, deal_type='CPS', exit_url=data['omg:Referrer'], merchant_name=data['omg:Merchant'], merchant_id=data.apply(lambda x: "OM" + str(x['omg:MID']), axis=1)) return data