forked from salesforce-marketingcloud/FuelSDK-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuds_patch.py
59 lines (52 loc) · 1.55 KB
/
suds_patch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from suds.mx.appender import Appender,Content
class _PropertyAppender(Appender):
"""
A L{Property} appender.
Patched for FuelSDK
"""
def append(self, parent, content):
p = content.value
child = self.node(content)
child_value = p.get()
if(child_value is None):
pass
else:
child.setText(child_value)
parent.append(child)
for item in p.items():
cont = Content(tag=item[0], value=item[1])
Appender.append(self, child, cont)
def _bodycontent(self, method, args, kwargs):
"""
# The I{wrapped} vs I{bare} style is detected in 2 ways.
# If there is 2+ parts in the message then it is I{bare}.
# If there is only (1) part and that part resolves to a builtin then
# it is I{bare}. Otherwise, it is I{wrapped}.
#
Patched for FuelSDK
"""
if not len(method.soap.input.body.parts):
return ()
wrapped = method.soap.input.body.wrapped
if wrapped:
pts = self.bodypart_types(method)
root = self.document(pts[0])
else:
root = []
n = 0
for pd in self.param_defs(method):
if n < len(args):
value = args[n]
else:
value = kwargs.get(pd[0])
n += 1
if value is None:
continue
p = self.mkparam(method, pd, value)
if p is None:
continue
if not wrapped:
ns = pd[1].namespace('ns0')
p.setPrefix(ns[0], ns[1])
root.append(p)
return root