<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 Client ( CreateSendBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , auth = None , client_id = None ) : <EOL> self . client_id = client_id <EOL> super ( Client , self ) . __init__ ( auth ) <EOL> def create ( self , company , timezone , country ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : company , <EOL> "<STR_LIT>" : timezone , <EOL> "<STR_LIT>" : country } <EOL> response = self . _post ( "<STR_LIT>" , json . dumps ( body ) ) <EOL> self . client_id = json_to_py ( response ) <EOL> return self . client_id <EOL> def details ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( "<STR_LIT>" % self . client_id ) <EOL> return json_to_py ( response ) <EOL> def campaigns ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def scheduled ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def drafts ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def lists ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def lists_for_email ( self , email_address ) : <EOL> """<STR_LIT>""" <EOL> params = { "<STR_LIT:email>" : email_address } <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def segments ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def suppressionlist ( 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 suppress ( self , email ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : [ email ] if isinstance ( email , str ) else email } <EOL> response = self . _post ( self . uri_for ( "<STR_LIT>" ) , json . dumps ( body ) ) <EOL> def unsuppress ( self , email ) : <EOL> """<STR_LIT>""" <EOL> params = { "<STR_LIT:email>" : email } <EOL> response = self . _put ( self . uri_for ( "<STR_LIT>" ) , body = "<STR_LIT:U+0020>" , params = params ) <EOL> def templates ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( "<STR_LIT>" ) ) <EOL> return json_to_py ( response ) <EOL> def set_basics ( self , company , timezone , country ) : <EOL> body = { <EOL> "<STR_LIT>" : company , <EOL> "<STR_LIT>" : timezone , <EOL> "<STR_LIT>" : country } <EOL> response = self . _put ( self . uri_for ( '<STR_LIT>' ) , json . dumps ( body ) ) <EOL> def set_payg_billing ( self , currency , can_purchase_credits , client_pays , markup_percentage , <EOL> markup_on_delivery = <NUM_LIT:0> , markup_per_recipient = <NUM_LIT:0> , markup_on_design_spam_test = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : currency , <EOL> "<STR_LIT>" : can_purchase_credits , <EOL> "<STR_LIT>" : client_pays , <EOL> "<STR_LIT>" : markup_percentage , <EOL> "<STR_LIT>" : markup_on_delivery , <EOL> "<STR_LIT>" : markup_per_recipient , <EOL> "<STR_LIT>" : markup_on_design_spam_test } <EOL> response = self . _put ( self . uri_for ( '<STR_LIT>' ) , json . dumps ( body ) ) <EOL> def set_monthly_billing ( self , currency , client_pays , markup_percentage , monthly_scheme = None ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : currency , <EOL> "<STR_LIT>" : client_pays , <EOL> "<STR_LIT>" : markup_percentage } <EOL> if monthly_scheme is not None : <EOL> body [ "<STR_LIT>" ] = monthly_scheme <EOL> response = self . _put ( self . uri_for ( '<STR_LIT>' ) , json . dumps ( body ) ) <EOL> def transfer_credits ( self , credits , can_use_my_credits_when_they_run_out ) : <EOL> """<STR_LIT>""" <EOL> body = { <EOL> "<STR_LIT>" : credits , <EOL> "<STR_LIT>" : can_use_my_credits_when_they_run_out } <EOL> response = self . _post ( self . uri_for ( '<STR_LIT>' ) , json . dumps ( body ) ) <EOL> return json_to_py ( response ) <EOL> def people ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( '<STR_LIT>' ) ) <EOL> return json_to_py ( response ) <EOL> def get_primary_contact ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _get ( self . uri_for ( '<STR_LIT>' ) ) <EOL> return json_to_py ( response ) <EOL> def set_primary_contact ( self , email ) : <EOL> """<STR_LIT>""" <EOL> params = { "<STR_LIT:email>" : email } <EOL> response = self . _put ( self . uri_for ( '<STR_LIT>' ) , params = params ) <EOL> return json_to_py ( response ) <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _delete ( "<STR_LIT>" % self . client_id ) <EOL> def uri_for ( self , action ) : <EOL> return "<STR_LIT>" % ( self . client_id , action ) </s>
