inema.wpint module¶
- class inema.wpint.WarenpostInt(partner_id, key, ekp, pk_email, pk_passwd, key_phase='1', sandbox=False)[source]¶
Bases:
objectRepresents the Warenpost Internatoinal REST interface.
- Parameters:
key (str) – same as SCHLUESSEL_DPWN_PARTNER?
ekp (str) – ‘Einheitliche Kunden- und Produktnummer’ aka Geschäftskundennummer aka business customer number
- class Address(name, addr_lines, city, country_code, postal_code='', state=None, phone=None, fax=None, email=None)[source]¶
Bases:
objectCommon Representation of a postal address. In their infinite cluelessness, the developes of the Warenpost International API decided it’s a good idea to use a flat, non-hierarchical structure with different names of fields for sender and recipient.
- api_create_order(items, contact_name, order_status='FINALIZE')[source]¶
Issue an API request to create an order consisting of items.
- api_get_item_label(item_id, accept='application/pdf')[source]¶
Download the label for a given item. Returns PDF as ‘bytes’
- api_get_item_labels(awb, accept='application/pdf')[source]¶
Download the labels for all items in a given AWB. Returns PDF as ‘bytes’
- build_content_item(line_weight_g, line_value, qty, hs_code=None, origin_cc=None, desc=None)[source]¶
Build an ‘content item’ in the language of the WaPoInt API. Represents one line on the customs form.
- build_item(product, sender, recipient, weight_grams, amount=0, currency='EUR', shipment_nature='SALE_GOODS', customer_reference=None, contents=None)[source]¶
Build an ‘item’ in the language of the WaPoInt API. Represents one shipment.
- build_order(items, contact_name, order_status='FINALIZE')[source]¶
Build an ‘order’ in the language of the WaPoInt API. Consists of multiple shipments.
- request(method, suffix, json=None, headers=None)[source]¶
Wrapper for issuing HTTP requests against the API. This internally generates all required headers, including Authorization.
- shrink_contents_if_needed(contents)[source]¶
Attempt to shrink the number of content lines below the permitted 5. We intentionally ignore the country of origin and group all lines by the HTS code. All lines sharing the same HTS code are merged to one, hopefully this is sufficient to get the count below 5.