Fix company addresses with contact person
When using the build_comp_addr() method 'person' argument, we need to pass in a PersonName object, and not a string name of the contact. Add a public build_pers_name() method to produce that PersonName object, and use it from the example code.
This commit is contained in:
parent
04cdf054c4
commit
e464545a89
|
@ -18,8 +18,9 @@ logging.basicConfig(level=logging.INFO)
|
|||
im = Internetmarke(PARTNER_ID, KEY, KEY_PHASE)
|
||||
im.authenticate(USER, PASS)
|
||||
|
||||
pn = im.build_pers_name(first='Harald', last='Welte')
|
||||
sysmo_addr = im.build_addr('Alt-Moabit','93','10559','Berlin','DEU')
|
||||
sysmo_naddr = im.build_comp_addr('sysmocom - s.f.m.c. GmbH', sysmo_addr)
|
||||
sysmo_naddr = im.build_comp_addr('sysmocom - s.f.m.c. GmbH', sysmo_addr, person=pn)
|
||||
|
||||
dest_addr = im.build_addr('Glanzstrasse','11','12437','Berlin','DEU')
|
||||
dest_naddr = im.build_pers_addr('Harald', 'Welte', dest_addr)
|
||||
|
|
|
@ -171,6 +171,13 @@ class Internetmarke(object):
|
|||
houseNo = house, zip = zipcode, city = city,
|
||||
country= country)
|
||||
|
||||
def build_pers_name(self, first, last, salutation=None, title=None):
|
||||
zclient = self.client
|
||||
pntype = zclient.get_type('{http://oneclickforapp.dpag.de/V3}PersonName')
|
||||
pn = pntype(firstname = first, lastname = last,
|
||||
salutation = salutation, title = title)
|
||||
return pn
|
||||
|
||||
def build_comp_addr(self, company, address, person = None):
|
||||
zclient = self.client
|
||||
cntype = zclient.get_type('{http://oneclickforapp.dpag.de/V3}CompanyName')
|
||||
|
@ -182,9 +189,7 @@ class Internetmarke(object):
|
|||
|
||||
def build_pers_addr(self, first, last, address, salutation = None, title = None):
|
||||
zclient = self.client
|
||||
pntype = zclient.get_type('{http://oneclickforapp.dpag.de/V3}PersonName')
|
||||
pn = pntype(firstname = first, lastname = last,
|
||||
salutation = salutation, title = title)
|
||||
pn = self.build_pers_name(first, last, salutation, title)
|
||||
ntype = zclient.get_type('{http://oneclickforapp.dpag.de/V3}Name')
|
||||
name = ntype(personName = pn)
|
||||
atype = zclient.get_type('{http://oneclickforapp.dpag.de/V3}NamedAddress')
|
||||
|
|
Loading…
Reference in New Issue