Skip to main content

NOT official module for use fedex web services with python

Project description

Fedex Python

NOT official FedEx python library to use its web services. This library use zeep library for do WSDL requests.

Installation

Use the package manager pip to install fedex-python.

pip install fedex-python

Usage

import fedex-python as fedex

client = fedex.Client(
    key, password, account_number, meter_number,
    localization=(
        fedex.components.auth.Localization.get(
            fedex.components.auth.Localization.SPANISH_LATINOAMERICAN
        )
    ),
    test_mode=True
)

Make a Rate

from fedex_python.components import enums, common, rate_components

response = client.rate.get_rates(
    rate_components.RequestedShipment(
        dropoff_type=enums.DropoffTypeEnum.REGULAR_PICKUP,
        rate_request_types=enums.RateRequestTypeEnum.PREFERRED,
        preferred_currency=enums.CurrencyCodeEnum.US_DOLLAR,
        shipping_charges_payment=common.ShippingChargesPayment(
            payment_type=enums.PaymentTypeEnum.SENDER,
            payor=common.Payor(
                responsible_party=common.ContactAddress(
                    account_number=client.account_number
                )
            )
        ),
        requested_package_line_items=rate_components.RequestedPackageLineItem(
            weight=common.Weight(units=enums.WeightUnits.KG,value=20),
            dimensions=common.Dimensions(
                length=22, height=22,width=22, units=enums.LinearUnits.CM
            )
        ),
        shipper=common.ContactAddress(
            contact=None,
            address=common.Address(
                postal_code='06040',
                country_code='MX',
            )
        )
        recipient=common.ContactAddress(
            contact=None,
            address=common.Address(
                postal_code='15530',
                country_code='MX',
            )
        )
    ), 'Custom id to send FedEx service')

Make a ship

from fedex_python.components import enums, common, ship_components

response = self.client.ship.process_shipment(
    ship_components.RequestedShipment(
    ship_timestamp='2020-02-15T12:00:00',
    dropoff_type=enums.DropoffTypeEnum.REGULAR_PICKUP,
    service_type=enums.ShipServiceTypeEnum.STANDARD_OVERNIGHT,
    packaging_type=enums.PackagingTypeEnum.YOUR_PACKAGING,
    rate_request_types=enums.RateRequestTypeEnum.PREFERRED,
    shipping_charges_payment=common.ShippingChargesPayment(
        payment_type=enums.PaymentTypeEnum.SENDER,
        payor=common.Payor(
            responsible_party=common.ContactAddress(
                account_number=client.account_number
            )
        )
    ),
    requested_package_line_items=common.RequestedPackageLineItemBase(
        weight=common.Weight(units=enums.WeightUnits.KG,value=20),
        dimensions=common.Dimensions(
            length=22, height=22,width=22, units=enums.LinearUnits.CM
        )
    ),
    shipper=common.ContactAddress(
        contact=common.Contact(
            contact_id='Custom id',
            person_name='Sergio Alvarado',
            company_name='Costomit',
            phone_number='55523423324',
            eMail_address='sergioal18v@gmail.com'
        ),
        address=common.Address(
            postal_code='06040',
            country_code='MX',
            street_lines='complete street 209',
            city='Mexico',
        )
    )
    recipient=common.ContactAddress(
        contact=common.Contact(
            contact_id='Custom id',
            person_name='Sergio Alvarado 2',
            company_name='Costomit client',
            phone_number='55523423324',
            eMail_address='sergioal18v2@gmail.com'
        ),
        address=common.Address(
            postal_code='15530',
            country_code='MX',
            street_lines='another street 209',
            city='Mexico',
        )
    )
    label_specification=ship_components.LabelSpecification(
        label_format_type=enums.LabelFormatTypeEnum.COMMON2D,
        label_stock_type=enums.LabelStockTypeEnum.PAPER_LETTER,
        label_printing_orientation=
            enums.LabelPrintingOrientationEnum.BOTTOM_EDGE_OF_TEXT_FIRST,
        image_type=enums.ImageTypeEnum.PDF
    ),
    package_count=1,
    total_weight=common.Weight(
        units=enums.WeightUnits.KG, value=20)
    )
)
    , 'Custom id to send FedEx service')

Cancel a ship

from fedex_python.components import common, enums

response = client.ship.delete_shipment(
    ship_timestamp='2020-02-15T12:00:00',
    tracking_id=common.TrackingId(
        tracking_id_type=enums.TrackingIdTypeEnum.FEDEX,
        tracking_number='the track id number'
    ),
    deletion_control=enums.DeletionControlEnum.DELETE_ALL_PACKAGES,
    custom_id='Custom id to send FedEx service'
)

Create a pickup

from fedex_python.components import common, enums, pickup_components

response = client.pickup.create_pickup(
    origin_detail=pickup_components.OriginDetail(
        buildin_part_description='reference building,
        package_location=enums.PackageLocationEnum.FRONT,
        building_part_code=enums.BuildingPartCodeEnum.BUILDING,
        ready_timestamp='2020-02-15T12:00:00',
        company_close_time='19:00:00',
        pickup_location=common.ContactAddress(
            contact=common.Contact(
                contact_id='Custom id',
                person_name='Sergio Alvarado',
                company_name='Costomit',
                phone_number='55523423324',
                eMail_address='sergioal18v@gmail.com'
            ),
            address=common.Address(
                postal_code='06040',
                country_code='MX',
                street_lines='complete street 209',
                city='Mexico',
            )
        )
    ),
    total_weight=common.Weight(units=enums.WeightUnits.KG, value=22),
    carrier_code=enums.CarrierCodeTypeEnum.FEDEX_EXPRESS,
    package_count=1,
    country_relationship=enums.CountryRelationshipEnum.DOMESTIC,
    custom_id='Custom id to send FedEx service'
)

Cancel a pickup

from fedex_python.components import enums

response = client.pickup.cancel_pickup(
    scheduled_date='2020-02-15T12:00:00',
    pickup_confirmation_number='1',
    location='branch office code given in pickup,
    carrier_code=enums.CarrierCodeTypeEnum.FEDEX_EXPRESS,
    custom_id='Custom id to send FedEx service'
)

Pickup availables

from fedex_python.components import enums, pickup_components

response = self.client.pickup.availability(
    pickup_components.Availability(
        pickup_address=address=common.Address(
            postal_code='06040',
            country_code='MX',
            street_lines='complete street 209',
            city='Mexico',
        ),
        pickup_request_type=enums.PickupRequestTypeEnum.FUTURE_DAY,
        dispatch_date='2020-02-15',
        package_ready_time='12:00:00',
        customer_close_time='19:00:00',
        carriers=enums.CarrierCodeTypeEnum.FEDEX_EXPRESS,
        number_of_business_days=3,
        shipment_attributes=pickup_components.ShipmentAttributes(
            service_type=enums.ShipServiceTypeEnum.STANDARD_OVERNIGHT,
            packaging_type=enums.PackagingTypeEnum.YOUR_PACKAGING
        )
    ), 'Custom id to send FedEx service'
)

Do a Tracking

from fedex_python.components import track_components, enums
response = client.track.track(
    selection_details=track_components.SelectionDetails(
        carrier_code=enums.CarrierCodeTypeEnum.FEDEX_EXPRESS,
        package_identifier=track_components.PackageIdentifier(
            type=enums.PackageIdentifierType.TRACKING_NUMBER_OR_DOORTAG,
            value='yor track',
            account_number=clinet.account_number
        )
    ),
    processing_options=enums.ProcessingOptionsEnum.INCLUDE_DETAILED_SCANS,
    custom_id='Custom id to send FedEx service')

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fedex-python-0.0.5.tar.gz (228.8 kB view details)

Uploaded Source

File details

Details for the file fedex-python-0.0.5.tar.gz.

File metadata

  • Download URL: fedex-python-0.0.5.tar.gz
  • Upload date:
  • Size: 228.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for fedex-python-0.0.5.tar.gz
Algorithm Hash digest
SHA256 6bbdbb846687f9b4a3dcbcdb94d3527c6a94ff4db10af68a6c6499ece1e33c37
MD5 f24b99c98bb5d8b82d2ecbe328e00ba0
BLAKE2b-256 b67d3d391bf27ebdfd1613b5d34fc74eeea34dd4f7277152375a251fe55ee172

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page