<s> try : <EOL> import json <EOL> except ImportError : <EOL> import simplejson as json <EOL> from createsend import CreateSendBase <EOL> from utils import json_to_py <EOL> class Campaign ( CreateSendBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , auth = None , campaign_id = None ) : <EOL> self . campaign_id = campaign_id <EOL> super ( Campaign , self ) . __init__ ( auth ) <EOL> def create ( self , client_id , subject , name , from_name , from_email , reply_to , html_url , <EOL> text_url , list_ids , segment_ids ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : subject , <EOL> "<STR_LIT:Name>" : name , <EOL> "<STR_LIT>" : from_name , <EOL> "<STR_LIT>" : from_email , <EOL> "<STR_LIT>" : reply_to , <EOL> "<STR_LIT>" : html_url , <EOL> "<STR_LIT>" : text_url , <EOL> "<STR_LIT>" : list_ids , <EOL> "<STR_LIT>" : segment_ids } <EOL> response = self . _post ( "<STR_LIT>" % client_id , json . dumps ( body ) ) <EOL> self . campaign_id = json_to_py ( response ) <EOL> return self . campaign_id <EOL> def create_from_template ( self , client_id , subject , name , from_name , <EOL> from_email , reply_to , list_ids , segment_ids , template_id , template_content ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : subject , <EOL> "<STR_LIT:Name>" : name , <EOL> "<STR_LIT>" : from_name , <EOL> "<STR_LIT>" : from_email , <EOL> "<STR_LIT>" : reply_to , <EOL> "<STR_LIT>" : list_ids , <EOL> "<STR_LIT>" : segment_ids , <EOL> "<STR_LIT>" : template_id , <EOL> "<STR_LIT>" : template_content } <EOL> response = self . _post ( "<STR_LIT>" % client_id , json . dumps ( body ) ) <EOL> self . campaign_id = json_to_py ( response ) <EOL> return self . campaign_id <EOL> def send_preview ( self , recipients , personalize = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : [ recipients ] if isinstance ( recipients , str ) else recipients , <EOL> "<STR_LIT>" : personalize } <EOL> response = self . _post ( self . uri_for ( "<STR_LIT>" ) , json . dumps ( body ) ) <EOL> def send ( self , confirmation_email , send_date = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : confirmation_email , <EOL> "<STR_LIT>" : send_date } <EOL> response = self . _post ( self . uri_for ( "<STR_LIT>" ) , json . dumps ( body ) ) <EOL> def unschedule ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _post ( self . uri_for ( "<STR_LIT>" ) , json . dumps ( { } ) ) <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _delete ( "<STR_LIT>" % self . campaign_id ) <EOL> def summary ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def email_client_usage ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def lists_and_segments ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def recipients ( self , page = <NUM_LIT:1> , page_size = <NUM_LIT:1000> , order_field = "<STR_LIT:email>" , order_direction = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> "<STR_LIT>" : page , <EOL> "<STR_LIT>" : page_size , <EOL> "<STR_LIT>" : order_field , <EOL> "<STR_LIT>" : order_direction } <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def opens ( self , date = "<STR_LIT>" , page = <NUM_LIT:1> , page_size = <NUM_LIT:1000> , order_field = "<STR_LIT:date>" , order_direction = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> "<STR_LIT:date>" : date , <EOL> "<STR_LIT>" : page , <EOL> "<STR_LIT>" : page_size , <EOL> "<STR_LIT>" : order_field , <EOL> "<STR_LIT>" : order_direction } <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def clicks ( self , date = "<STR_LIT>" , page = <NUM_LIT:1> , page_size = <NUM_LIT:1000> , order_field = "<STR_LIT:date>" , order_direction = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> "<STR_LIT:date>" : date , <EOL> "<STR_LIT>" : page , <EOL> "<STR_LIT>" : page_size , <EOL> "<STR_LIT>" : order_field , <EOL> "<STR_LIT>" : order_direction } <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def unsubscribes ( self , date = "<STR_LIT>" , page = <NUM_LIT:1> , page_size = <NUM_LIT:1000> , order_field = "<STR_LIT:date>" , order_direction = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> "<STR_LIT:date>" : date , <EOL> "<STR_LIT>" : page , <EOL> "<STR_LIT>" : page_size , <EOL> "<STR_LIT>" : order_field , <EOL> "<STR_LIT>" : order_direction } <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def spam ( self , date = "<STR_LIT>" , page = <NUM_LIT:1> , page_size = <NUM_LIT:1000> , order_field = "<STR_LIT:date>" , order_direction = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> "<STR_LIT:date>" : date , <EOL> "<STR_LIT>" : page , <EOL> "<STR_LIT>" : page_size , <EOL> "<STR_LIT>" : order_field , <EOL> "<STR_LIT>" : order_direction } <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def bounces ( self , date = "<STR_LIT>" , page = <NUM_LIT:1> , page_size = <NUM_LIT:1000> , order_field = "<STR_LIT:date>" , order_direction = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> "<STR_LIT:date>" : date , <EOL> "<STR_LIT>" : page , <EOL> "<STR_LIT>" : page_size , <EOL> "<STR_LIT>" : order_field , <EOL> "<STR_LIT>" : order_direction } <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def uri_for ( self , action ) : <EOL> return "<STR_LIT>" % ( self . campaign_id , action ) </s>
