def test_postal_inquiry(self):
        inquiry = FedexValidatePostalRequest(CONFIG_OBJ)
        inquiry.Address.PostalCode = '29631'
        inquiry.Address.CountryCode = 'US'

        inquiry.send_request()

        assert inquiry.response
        assert inquiry.response.HighestSeverity == 'SUCCESS'
    def validate_postal_address(self, recipient_address):
        recipient_details = frappe.db.get_value("Address",
                                                recipient_address,
                                                "*",
                                                as_dict=True)

        inquiry = FedexValidatePostalRequest(self.config_obj)
        inquiry.Address.PostalCode = recipient_details.get("pincode")
        inquiry.Address.CountryCode = recipient_details.get("country_code")
        inquiry.Address.StreetLines = [recipient_details.get("address_line2"),\
                recipient_details.get("address_line1")]
        inquiry.Address.City = recipient_details.get("city")
        inquiry.Address.StateOrProvinceCode = recipient_details.get(
            "state_code")
        inquiry.send_request()
        if inquiry.response.HighestSeverity not in [
                "SUCCESS", "NOTE", "WARNING"
        ]:
            self.show_notification(inquiry)
            frappe.throw(_('Recipient Address verification failed.'))
Пример #3
0
#!/usr/bin/env python
"""
ValidatePostalRequest classes are used to validate and receive additional
information about postal codes.
"""
import logging
from example_config import CONFIG_OBJ
from fedex.services.country_service import FedexValidatePostalRequest

# Set this to the INFO level to see the response from Fedex printed in stdout.
logging.basicConfig(level=logging.INFO)

# We're using the FedexConfig object from example_config.py in this dir.
customer_transaction_id = "*** ValidatePostal Request v4 using Python ***"  # Optional transaction_id
inquiry = FedexValidatePostalRequest(CONFIG_OBJ, customer_transaction_id=customer_transaction_id)
inquiry.Address.PostalCode = '29631'
inquiry.Address.CountryCode = 'US'
inquiry.Address.StreetLines = ['104 Knox Road']
inquiry.Address.City = 'Clemson'
inquiry.Address.StateOrProvinceCode = 'SC'

# If you'd like to see some documentation on the country service WSDL, un-comment
# this line. (Spammy).
# print(inquiry.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
# print(inquiry.CarrierCode)
# print(inquiry.Address)
# print(inquiry.ShipDateTime)
Пример #4
0
#!/usr/bin/env python
"""
ValidatePostalRequest classes are used to validate and receive additional
information about postal codes.
"""
import logging
from example_config import CONFIG_OBJ
from fedex.services.country_service import FedexValidatePostalRequest

# Set this to the INFO level to see the response from Fedex printed in stdout.
logging.basicConfig(level=logging.INFO)

# We're using the FedexConfig object from example_config.py in this dir.
customer_transaction_id = "*** ValidatePostal Request v4 using Python ***"  # Optional transaction_id
inquiry = FedexValidatePostalRequest(
    CONFIG_OBJ, customer_transaction_id=customer_transaction_id)
inquiry.Address.PostalCode = '29631'
inquiry.Address.CountryCode = 'US'
inquiry.Address.StreetLines = ['104 Knox Road']
inquiry.Address.City = 'Clemson'
inquiry.Address.StateOrProvinceCode = 'SC'

# If you'd like to see some documentation on the country service WSDL, un-comment
# this line. (Spammy).
# print(inquiry.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
# print(inquiry.CarrierCode)
# print(inquiry.Address)