Skip to content

Instantly share code, notes, and snippets.

@sharoonthomas
Created June 26, 2013 15:13
Show Gist options
  • Save sharoonthomas/5868273 to your computer and use it in GitHub Desktop.
Save sharoonthomas/5868273 to your computer and use it in GitHub Desktop.
PyUPS setting the transaction refernce
from ups import ShipmentConfirm
from lxml.builder import E
shipment_confirm_api = ShipmentConfirm('a', 'b', 'c', 'd')
# Print the value of the TransactionReference
print etree.tostring(shipment_confirm_api.TransactionReference, pretty_print=True)
"""
Output:
<TransactionReference>
<CustomerContext>unspecified</CustomerContext>
</TransactionReference>
"""
# Set a value for transaction reference
shipment_confirm_api.TransactionReference = E.TransactionReference(
E.CustomerContext('1234')
)
# Print the value of the TransactionReference again
print etree.tostring(shipment_confirm_api.TransactionReference, pretty_print=True)
"""
Output:
<TransactionReference>
<CustomerContext>1234</CustomerContext>
</TransactionReference>
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment