Skip to content

Commit 6721674

Browse files
authored
* bumping version no to 1.0.0 to support Python 3.3 + * removed print messages * has_key removed in python 3 'key in dict' has existed for a long time and is much more pythonic; accordingly, this change is backwards compatible. * Remove arbitrary call to print() * Add method to get profile attributes of Subcriber * Changed iteritems() to items() for Python3 support Updated version * py3 support (salesforce-marketingcloud#82) Support for Python 3.3.3 * V1.0.1 changes. Readme, wsdl file updated. Py3 support added. (salesforce-marketingcloud#83) * py3 support * updated wsdl file * updated readme * readme * readme * readme change * Create ExactTargetWSDL.xml * v1.0.1 updates. * Update README.md
1 parent 693acb3 commit 6721674

27 files changed

+19027
-9341
lines changed

FuelSDK/ExactTargetWSDL.xml

Lines changed: 9151 additions & 4341 deletions
Large diffs are not rendered by default.

FuelSDK/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
__version__ = '0.9.4'
1+
__version__ = '1.0.1'
22

33
# Runtime patch the suds library
4-
from suds_patch import _PropertyAppender
4+
from FuelSDK.suds_patch import _PropertyAppender
55
from suds.mx import appender as _appender
66
_appender.PropertyAppender = _PropertyAppender
77

8-
from suds_patch import _bodycontent
8+
from FuelSDK.suds_patch import _bodycontent
99
from suds.bindings import document as _document
1010
_document.Document.bodycontent = _bodycontent
1111
# end runtime patching of suds
1212

13-
from client import ET_Client
13+
from FuelSDK.client import ET_Client
1414

1515
# Import all the wrapper objects
16-
from objects import *
16+
from FuelSDK.objects import *

FuelSDK/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import logging
3-
import ConfigParser
3+
import configparser
44
import time
55
import json
66

@@ -10,7 +10,8 @@
1010
import suds.wsse
1111
from suds.sax.element import Element
1212

13-
from objects import ET_DataExtension,ET_Subscriber
13+
14+
from FuelSDK.objects import ET_DataExtension,ET_Subscriber
1415

1516

1617
class ET_Client(object):
@@ -33,7 +34,7 @@ class ET_Client(object):
3334
auth_url = None
3435

3536
## get_server_wsdl - if True and a newer WSDL is on the server than the local filesystem retrieve it
36-
def __init__(self, get_server_wsdl = False, debug = False, params = None):
37+
def __init__(self, get_server_wsdl = False, debug = False, params = None, tokenResponse=None):
3738
self.debug = debug
3839
if debug:
3940
logging.basicConfig(level=logging.INFO)
@@ -45,7 +46,7 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):
4546
logging.getLogger('suds').setLevel(logging.INFO)
4647

4748
## Read the config information out of config.python
48-
config = ConfigParser.RawConfigParser()
49+
config = configparser.RawConfigParser()
4950
if os.path.exists(os.path.expanduser('~/.fuelsdk/config.python')):
5051
config.read(os.path.expanduser('~/.fuelsdk/config.python'))
5152
else:

FuelSDK/objects.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from rest import ET_CUDSupport,ET_CUDSupportRest,ET_GetSupport,ET_Get,ET_Patch,ET_Post,ET_Delete,ET_Configure
1+
from FuelSDK.rest import ET_CUDSupport,ET_CUDSupportRest,ET_GetSupport,ET_Get,ET_Patch,ET_Post,ET_Delete,ET_Configure,ET_Describe
22

33
########
44
##
@@ -37,6 +37,9 @@ def post(self):
3737
self.last_request_id = obj.request_id
3838
return obj
3939

40+
def get(self):
41+
return ET_Describe(self.auth_stub, 'Subscriber')
42+
4043
########
4144
##
4245
## wrap an Exact Target Bounce Event
@@ -145,7 +148,7 @@ def __init__(self):
145148
self.obj_type = 'TriggeredSendDefinition'
146149

147150
def send(self):
148-
tscall = {"TriggeredSendDefinition" : self.props, "Subscribers" : self.subscribers, "Attributes": self.attributes }
151+
tscall = {"TriggeredSendDefinition":self.props, "Subscribers" : self.subscribers, "Attributes": self.attributes }
149152
self.obj = ET_Post(self.auth_stub, "TriggeredSend", tscall)
150153
return self.obj
151154

@@ -279,7 +282,7 @@ def post(self):
279282
currentFields = []
280283
currentProp = {}
281284

282-
for key, value in rec.iteritems():
285+
for key, value in rec.items():
283286
currentFields.append({"Name" : key, "Value" : value})
284287

285288
currentProp['CustomerKey'] = self.CustomerKey
@@ -294,7 +297,7 @@ def post(self):
294297
currentFields = []
295298
currentProp = {}
296299

297-
for key, value in self.props.iteritems():
300+
for key, value in self.props.items():
298301
currentFields.append({"Name" : key, "Value" : value})
299302

300303
currentProp['CustomerKey'] = self.CustomerKey
@@ -314,7 +317,7 @@ def patch(self):
314317
currentFields = []
315318
currentProp = {}
316319

317-
for key, value in rec.iteritems():
320+
for key, value in rec.items():
318321
currentFields.append({"Name" : key, "Value" : value})
319322

320323
currentProp['CustomerKey'] = self.CustomerKey
@@ -328,7 +331,7 @@ def patch(self):
328331
currentFields = []
329332
currentProp = {}
330333

331-
for key, value in self.props.iteritems():
334+
for key, value in self.props.items():
332335
currentFields.append({"Name" : key, "Value" : value})
333336

334337
currentProp['CustomerKey'] = self.CustomerKey
@@ -347,7 +350,7 @@ def delete(self):
347350
currentFields = []
348351
currentProp = {}
349352

350-
for key, value in rec.iteritems():
353+
for key, value in rec.items():
351354
currentFields.append({"Name" : key, "Value" : value})
352355

353356
currentProp['CustomerKey'] = self.CustomerKey
@@ -361,7 +364,7 @@ def delete(self):
361364
currentFields = []
362365
currentProp = {}
363366

364-
for key, value in self.props.iteritems():
367+
for key, value in self.props.items():
365368
currentFields.append({"Name" : key, "Value" : value})
366369

367370
currentProp['CustomerKey'] = self.CustomerKey

FuelSDK/rest.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@ def __init__(self, response = None, rest = False):
6464
self.status = False
6565

6666
def parse_props_dict_into_ws_object(self, obj_type, ws_object, props_dict):
67-
for k, v in props_dict.iteritems():
67+
for k, v in list(props_dict.items()):
6868
if k in ws_object:
6969
ws_object[k] = v
7070
else:
7171
message = k + ' is not a property of ' + obj_type
72-
print message
7372
raise Exception(message)
7473
return ws_object
7574

@@ -90,7 +89,6 @@ def parse_props_into_ws_object(self, auth_stub, obj_type, props):
9089
return ws_create_list
9190
else:
9291
message = 'Can not post properties to ' + obj_type + ' without a dict or list of properties'
93-
print message
9492
raise Exception(message)
9593

9694
########
@@ -157,12 +155,12 @@ def __init__(self, auth_stub, obj_type, props = None, search_filter = None, opti
157155

158156
if props is not None:
159157
if type(props) is dict: # If the properties is a hash, then we just want to use the keys
160-
ws_retrieveRequest.Properties = props.keys()
158+
ws_retrieveRequest.Properties = list(props.keys())
161159
else:
162160
ws_retrieveRequest.Properties = props
163161

164162
if search_filter is not None:
165-
if search_filter.has_key('LogicalOperator'):
163+
if 'LogicalOperator' in search_filter:
166164
ws_simpleFilterPartLeft = auth_stub.soap_client.factory.create('SimpleFilterPart')
167165
for prop in ws_simpleFilterPartLeft:
168166
#print prop[0]
@@ -180,7 +178,7 @@ def __init__(self, auth_stub, obj_type, props = None, search_filter = None, opti
180178
ws_complexFilterPart.LogicalOperator = search_filter['LogicalOperator']
181179
for additional_operand in search_filter.get('AdditionalOperands', []):
182180
ws_simpleFilterPart = auth_stub.soap_client.factory.create('SimpleFilterPart')
183-
for k, v in additional_operand.items():
181+
for k, v in list(additional_operand.items()):
184182
ws_simpleFilterPart[k] = v
185183
ws_complexFilterPart.AdditionalOperands.Operand.append(ws_simpleFilterPart)
186184

@@ -193,9 +191,9 @@ def __init__(self, auth_stub, obj_type, props = None, search_filter = None, opti
193191
ws_retrieveRequest.Filter = ws_simpleFilterPart
194192

195193
if options is not None:
196-
for key, value in options.iteritems():
194+
for key, value in options.items():
197195
if isinstance(value, dict):
198-
for k, v in value.iteritems():
196+
for k, v in value.items():
199197
ws_retrieveRequest.Options[key][k] = v
200198
else:
201199
ws_retrieveRequest.Options[key] = value
@@ -215,7 +213,6 @@ def __init__(self, auth_stub, obj_type, props = None, search_filter = None, opti
215213
class ET_Post(ET_Constructor):
216214
def __init__(self, auth_stub, obj_type, props = None):
217215
auth_stub.refresh_token()
218-
219216
response = auth_stub.soap_client.service.Create(None, self.parse_props_into_ws_object(auth_stub, obj_type, props))
220217
if(response is not None):
221218
super(ET_Post, self).__init__(response)
@@ -295,7 +292,7 @@ def get(self, m_props = None, m_filter = None, m_options = None):
295292
if m_props is not None and type(m_props) is list:
296293
props = m_props
297294
elif self.props is not None and type(self.props) is dict:
298-
props = self.props.keys()
295+
props = list(self.props.keys())
299296

300297
if m_filter is not None and type(m_filter) is dict:
301298
search_filter = m_filter
@@ -396,7 +393,7 @@ def __init__(self):
396393

397394
def post(self):
398395
if self.extProps is not None:
399-
for k, v in self.extProps.iteritems():
396+
for k, v in self.extProps.items():
400397
self.props[k.capitalize] = v
401398

402399
obj = ET_Post(self.auth_stub, self.obj_type, self.props)
@@ -437,7 +434,7 @@ def get(self, props = None):
437434
additionalQS = {}
438435

439436
if self.props is not None and type(self.props) is dict:
440-
for k, v in self.props.iteritems():
437+
for k, v in self.props.items():
441438
if k in self.urlProps:
442439
completeURL = completeURL.replace('{{{0}}}'.format(k), v)
443440
else:
@@ -511,7 +508,7 @@ def post(self):
511508
completeURL = self.endpoint
512509

513510
if self.props is not None and type(self.props) is dict:
514-
for k, v in self.props.iteritems():
511+
for k, v in self.props.items():
515512
if k in self.urlProps:
516513
completeURL = completeURL.replace('{{{0}}}'.format(k), v)
517514

@@ -534,7 +531,7 @@ def patch(self):
534531
raise "Unable to process request due to missing required prop: #{value}"
535532

536533
if self.props is not None and type(self.props) is dict:
537-
for k, v in self.props.iteritems():
534+
for k, v in self.props.items():
538535
if k in self.urlProps:
539536
completeURL = completeURL.replace('{{{0}}}'.format(k), v)
540537

@@ -549,7 +546,7 @@ def delete(self):
549546
raise "Unable to process request due to missing required prop: #{value}"
550547

551548
if self.props is not None and type(self.props) is dict:
552-
for k, v in self.props.iteritems():
549+
for k, v in self.props.items():
553550
if k in self.urlProps:
554551
completeURL = completeURL.replace('{{{0}}}'.format(k), v)
555552

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2013 ExactTarget
1+
Copyright (c) 2017 Salesforce
22

33
Licensed under the MIT License (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the COPYING file.
44

0 commit comments

Comments
 (0)