@@ -6,6 +6,8 @@ class Outbound(object):
66
77 def __init__ (self , client ):
88 self .client = client
9+ self .headers = {} ##
10+
911
1012 def deliver (self , fax_number , files , ** kwargs ):
1113 """Submit a fax to a single destination number."""
@@ -16,8 +18,20 @@ def deliver(self, fax_number, files, **kwargs):
1618
1719 kwargs ['fax_number' ] = fax_number
1820
19- result = self .client .post ('/outbound/faxes' , kwargs , valid_keys ,
20- files = self ._generate_files (files ))
21+ data = None
22+ binaryfile = None
23+
24+ for f in files : # checking if the file supplied is an URL or binary data
25+ if f .startswith ('http://' ) or f .startswith ('https://' ):
26+ self .headers ['Content-Location' ] = f
27+ data = self ._generate_files (files )
28+ else :
29+ binaryfile = self ._generate_files (files )
30+
31+
32+ print ('DELIVERING...' )
33+ result = self .client .post ('/outbound/faxes' , kwargs , valid_keys , data = data , files = binaryfile ,
34+ headers = self .headers ) ## PARAMS: 'data' for URI, 'files' for binary data, with either one supllied the other stays empty
2135
2236 return OutboundFax (self .client , {'id' : result .split ('/' )[- 1 ]})
2337
@@ -47,15 +61,13 @@ def completed(self, *args):
4761 (Submitted id's which have not completed are ignored).
4862
4963 """
50- valid_keys = ['ids' ]
51- args_str = ""
52- for idx , arg in enumerate (args ):
53- if idx == len (args ) - 1 :
54- args_str += str (arg )
55- else :
56- args_str += str (arg ) + ", "
57- kwargs = {'ids' : args_str }
58- faxes = self .client .get ('/outbound/faxes/completed' , kwargs , valid_keys )
64+ valid_keys = ['ids' ]
65+
66+ kwargs = {'ids' : args }
67+
68+ faxes = self .client .get ('/outbound/faxes/completed' , kwargs ,
69+ valid_keys )
70+
5971 return [OutboundFax (self .client , fax ) for fax in faxes ]
6072
6173 def find (self , message_id ):
0 commit comments