From dd8b8d7320a29ffd4ae8de552269215ba67afc37 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 7 Mar 2021 11:25:43 +0100 Subject: [PATCH] wpint: Allow user to specify shipment_nature and customer_reference --- inema/wpint.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inema/wpint.py b/inema/wpint.py index 70d5040..cd8788b 100644 --- a/inema/wpint.py +++ b/inema/wpint.py @@ -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'):