wpint: Allow user to specify shipment_nature and customer_reference

This commit is contained in:
Harald Welte 2021-03-07 11:25:43 +01:00
parent 06d990510c
commit dd8b8d7320
1 changed files with 7 additions and 2 deletions

View File

@ -215,7 +215,7 @@ class WarenpostInt(object):
return ret
def build_item(self, product, sender, recipient, weight_grams, amount=0, currency='EUR',
contents=None):
shipment_nature='SALE_GOODS', customer_reference=None, contents=None):
"""Build an 'item' in the language of the WaPoInt API. Represents one shipment."""
weight_grams = int(weight_grams)
if weight_grams > 2000:
@ -228,13 +228,18 @@ class WarenpostInt(object):
'shipmentAmount': int(amount),
'shipmentCurrency': currency,
'shipmentGrossWeight': weight_grams,
'shipmentNaturetype': 'SALE_GOODS',
'shipmentNaturetype': shipment_nature,
}
# merge in the sender and recipient fields
ret.update(sender.as_sender())
ret.update(recipient.as_recipient())
if contents:
ret['contents'] = contents
if customer_reference:
customer_reference = str(customer_reference)
if len(customer_reference) > 20:
raise ValueError('Maximum length of customer reference is 20 chars')
ret['custRef'] = customer_reference
return ret
def build_order(self, items, contact_name, order_status='FINALIZE'):