Skip to content

Commit 77d9d16

Browse files
committed
Merge pull request salesforce-marketingcloud#27 from CommandIQ/master
Specify specific local file location for wsdl file
2 parents c6e23e1 + fbaa281 commit 77d9d16

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*.py[cod]
2-
2+
*.swp
33
# C extensions
44
*.so
55

FuelSDK/client.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):
4141
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
4242
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
4343
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
44+
else:
45+
logging.getLogger('suds').setLevel(logging.INFO)
4446

4547
## Read the config information out of config.python
4648
config = ConfigParser.RawConfigParser()
@@ -81,15 +83,24 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):
8183

8284
if params is not None and 'authenticationurl' in params:
8385
self.auth_url = params['authenticationurl']
84-
if config.has_option('Web Services', 'authenticationurl'):
86+
elif config.has_option('Web Services', 'authenticationurl'):
8587
self.auth_url = config.get('Web Services', 'authenticationurl')
8688
elif 'FUELSDK_AUTH_URL' in os.environ:
8789
self.auth_url = os.environ['FUELSDK_AUTH_URL']
8890
else:
8991
self.auth_url = 'https://auth.exacttargetapis.com/v1/requestToken?legacy=1'
9092

91-
self.wsdl_file_url = self.load_wsdl(wsdl_server_url, get_server_wsdl)
92-
93+
if params is not None and "wsdl_file_local_loc" in params:
94+
wsdl_file_local_location = params["wsdl_file_local_loc"]
95+
elif config.has_option("Web Services", "wsdl_file_local_loc"):
96+
wsdl_file_local_location = config.get("Web Services", "wsdl_file_local_loc")
97+
elif "FUELSDK_WSDL_FILE_LOCAL_LOC" in os.environ:
98+
wsdl_file_local_location = os.environ["FUELSDK_WSDL_FILE_LOCAL_LOC"]
99+
else:
100+
wsdl_file_local_location = None
101+
102+
self.wsdl_file_url = self.load_wsdl(wsdl_server_url, wsdl_file_local_location, get_server_wsdl)
103+
93104
## get the JWT from the params if passed in...or go to the server to get it
94105
if(params is not None and 'jwt' in params):
95106
decodedJWT = jwt.decode(params['jwt'], self.appsignature)
@@ -104,17 +115,20 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):
104115
self.refresh_token()
105116

106117

107-
def load_wsdl(self, wsdl_url, get_server_wsdl = False):
118+
def load_wsdl(self, wsdl_url, wsdl_file_local_location, get_server_wsdl = False):
108119
"""
109120
retrieve the url of the ExactTarget wsdl...either file: or http:
110121
depending on if it already exists locally or server flag is set and
111122
server has a newer copy
112123
"""
113-
path = os.path.dirname(os.path.abspath(__file__))
114-
file_location = os.path.join(path, 'ExactTargetWSDL.xml')
124+
if wsdl_file_local_location is not None:
125+
file_location = wsdl_file_local_location
126+
else:
127+
path = os.path.dirname(os.path.abspath(__file__))
128+
file_location = os.path.join(path, 'ExactTargetWSDL.xml')
115129
file_url = 'file:///' + file_location
116130

117-
if not os.path.exists(file_location): #if there is no local copy then go get it...
131+
if not os.path.exists(file_location) or os.path.getsize(file_location) == 0: #if there is no local copy or local copy is empty then go get it...
118132
self.retrieve_server_wsdl(wsdl_url, file_location)
119133
elif get_server_wsdl:
120134
r = requests.head(wsdl_url)

FuelSDK/objects.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ def __init__(self):
2828
class ET_ProfileAttribute():
2929
def __init__(self):
3030
self.obj_type = 'PropertyDefinition'
31+
self.update = False
3132

3233
def post(self):
33-
obj = ET_Configure(self.auth_stub, self.obj_type, self.props)
34+
obj = ET_Configure(self.auth_stub, self.obj_type, self.props, self.update)
3435
if obj is not None:
3536
self.last_request_id = obj.request_id
3637
return obj
@@ -123,7 +124,7 @@ def __init__(self):
123124
self.obj_type = 'TriggeredSendDefinition'
124125

125126
def send(self):
126-
tscall = {"TriggeredSendDefinition" : self.props, "Subscribers" : self.subscribers}
127+
tscall = {"TriggeredSendDefinition" : self.props, "Subscribers" : self.subscribers, "Attributes": self.attributes }
127128
self.obj = ET_Post(self.auth_stub, "TriggeredSend", tscall)
128129
return self.obj
129130

FuelSDK/rest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ def __init__(self, auth_stub, obj_type):
119119
##
120120
########
121121
class ET_Configure(ET_Constructor):
122-
def __init__(self, auth_stub, obj_type, props = None):
122+
def __init__(self, auth_stub, obj_type, props = None, update = False):
123123
auth_stub.refresh_token()
124124

125125
ws_configureRequest = auth_stub.soap_client.factory.create('ConfigureRequestMsg')
126-
ws_configureRequest.Action = 'create'
126+
ws_configureRequest.Action = 'create' if update is False else 'update'
127127
ws_configureRequest.Configurations = {'Configuration': self.parse_props_into_ws_object(auth_stub, obj_type, props)}
128128

129129
response = auth_stub.soap_client.service.Configure(None, ws_configureRequest)

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ You must configure your access tokens and details for the Fuel SDK in one of the
2727
* `FUELSDK_APP_SIGNATURE`
2828
* `FUELSDK_DEFAULT_WSDL`
2929
* `FUELSDK_AUTH_URL`
30+
* `FUELSDK_WSDL_FILE_LOCAL_LOC`
3031

3132
Edit `config.python` or declare environment variables so you can input the ClientID and Client Secret values provided when you registered your application. If you are building a HubExchange application for the Interactive Marketing Hub then, you must also provide the Application Signature (`appsignature` / `FUELSDK_APP_SIGNATURE`).
3233
The `defaultwsdl` / `FUELSDK_DEFAULT_WSDL` configuration must be [changed depending on the ExactTarget service](https://code.exacttarget.com/question/there-any-cetificrate-install-our-server-access-et-api "ExactTarget Forum").
3334
The `authenticationurl` / `FUELSDK_AUTH_URL` must also be [changed depending on service](https://code.exacttarget.com/question/not-able-create-accesstoken-when-clientidsecret-associated-preproduction-account "ExactTarget Forum").
35+
The `wsdl_file_local_loc` / `FUELSDK_WSDL_FILE_LOCAL_LOC` allows you to specify the full path/filename where the WSDL file will be located on disk, if for instance you are connecting to different endpoints from the same server.
3436

3537
If you have not registered your application or you need to lookup your Application Key or Application Signature values, please go to App Center at [Code@: ExactTarget's Developer Community](http://code.exacttarget.com/appcenter "Code@ App Center").
3638

config.python.template

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ appsignature: none
33
clientid: XXXXXXXXXXXXXXXXXXXXXXXX
44
clientsecret: XXXXXXXXXXXXXXXXXXXXXXXX
55
defaultwsdl: https://webservice.exacttarget.com/etframework.wsdl
6-
authenticationurl: https://auth.exacttargetapis.com/v1/requestToken?legacy=1
6+
authenticationurl: https://auth.exacttargetapis.com/v1/requestToken?legacy=1
7+
wsdl_file_local_loc: /tmp/ExactTargetWSDL.s6.xml

0 commit comments

Comments
 (0)