@@ -52,7 +52,7 @@ class SailthruClient(object):
5252 from sailthru import SailthruClient
5353 api_key = "your-api-key"
5454 api_secret = "api-secret"
55- client = SailthruCLient (api_key, api_secret)
55+ client = SailthruClient (api_key, api_secret)
5656 """
5757
5858 def __init__ (self , api_key , secret , api_url = None ):
@@ -513,7 +513,7 @@ def get_purchase(self, purchase_id, purchase_key='sid'):
513513 'purchase_key' : purchase_key }
514514 return self .api_get ('purchase' , data )
515515
516- def stats_list (self , list = None , date = None ):
516+ def stats_list (self , list = None , date = None , headers = None ):
517517 """
518518 Retrieve information about your subscriber counts on a particular list, on a particular day.
519519 http://docs.sailthru.com/api/stat
@@ -523,7 +523,7 @@ def stats_list(self, list=None, date=None):
523523 data ['list' ] = list
524524 if date is not None :
525525 data ['date' ] = date
526- return self ._stats (data )
526+ return self ._stats (data , headers )
527527
528528 def stats_blast (self , blast_id = None , start_date = None , end_date = None , options = None ):
529529 """
@@ -556,11 +556,11 @@ def stats_send(self, template, start_date, end_date, options=None):
556556 data ['stat' ] = 'send'
557557 return self ._stats (data )
558558
559- def _stats (self , data ):
559+ def _stats (self , data , headers = None ):
560560 """
561561 Make Stats API Request
562562 """
563- return self .api_get ('stats' , data )
563+ return self .api_get ('stats' , data , headers )
564564
565565 def receive_verify_post (self , post_params ):
566566 """
@@ -696,13 +696,14 @@ def check_for_valid_postback_actions(self, required_keys, post_params):
696696 return False
697697 return True
698698
699- def api_get (self , action , data ):
699+ def api_get (self , action , data , headers = None ):
700700 """
701701 Perform an HTTP GET request, using the shared-secret auth hash.
702702 @param action: API action call
703703 @param data: dictionary values
704704 """
705- return self ._api_request (action , data , 'GET' )
705+ #{'action': action, 'data': data, 'request_type': 'GET', 'headers': headers}
706+ return self ._api_request (action , data , 'GET' , headers )
706707
707708 def api_post (self , action , data , binary_data_param = None ):
708709 """
@@ -718,7 +719,7 @@ def api_post(self, action, data, binary_data_param=None):
718719
719720 def api_post_multipart (self , action , data , binary_data_param ):
720721 """
721- Perform an HTTP Multipart POST request, using the shared-secret auth hash.
722+ Perform an HTTP Multipart POST request, using the shared-secret auth hash.
722723 @param action: API action call
723724 @param data: dictionary values
724725 @param: binary_data_params: array of multipart keys
@@ -748,7 +749,7 @@ def api_delete(self, action, data):
748749 """
749750 return self ._api_request (action , data , 'DELETE' )
750751
751- def _api_request (self , action , data , request_type ):
752+ def _api_request (self , action , data , request_type , headers = None ):
752753 """
753754 Make Request to Sailthru API with given data and api key, format and signature hash
754755 """
@@ -757,12 +758,12 @@ def _api_request(self, action, data, request_type):
757758 else :
758759 file_data = None
759760
760- return self ._http_request (action , self ._prepare_json_payload (data ), request_type , file_data )
761+ return self ._http_request (action , self ._prepare_json_payload (data ), request_type , file_data , headers )
761762
762- def _http_request (self , action , data , method , file_data = None ):
763+ def _http_request (self , action , data , method , file_data = None , headers = None ):
763764 url = self .api_url + '/' + action
764765 file_data = file_data or {}
765- response = sailthru_http_request (url , data , method , file_data )
766+ response = sailthru_http_request (url , data , method , file_data , headers )
766767 if (action in self .last_rate_limit_info ):
767768 self .last_rate_limit_info [action ][method ] = response .get_rate_limit_headers ()
768769 else :
0 commit comments