poundifdef / ClassicUPS

Wrapper around the UPS API for creating shipping labels and fetching a package's tracking status.
Other
58 stars 36 forks source link

Get shipping service name by its code #2

Open eriktelepovsky opened 10 years ago

eriktelepovsky commented 10 years ago

It would be great if I could get service name by its code with something like this:

def get_service_name(service_code):
    """
    Given a service code, return the human-readable name for 
    that service

    @return: string on success or False
    """
    return SHIPPING_SERVICES_NAMES.get(service_code, service_code)
poundifdef commented 10 years ago

I don't immediately object to this. What is the use case? For example, when requesting tracking information, the return XML from UPS gives a human-readable description of the shipping type in TrackResponse.Shipment.Service.Description. Would it be sufficient to expose that? Or is the goal to get a list of all supported types? In that case, would it just return the existing SHIPPING_SERVICES dict?

eriktelepovsky commented 10 years ago

Well, the existing dict

SHIPPING_SERVICES = {
        '1dayair': '01',  # Next Day Air
        '2dayair': '02',  # 2nd Day Air
        'ground': '03',  # Ground
        'express': '07',  # Express
        'worldwide_expedited': '08',  # Expedited
        'standard': '11',  # UPS Standard
        '3_day_select': '12',  # 3 Day Select
        'next_day_air_saver': '13',  # Next Day Air Saver
        'next_day_air_early_am': '14',  # Next Day Air Early AM
        'express_plus': '54',  # Express Plus
        '2nd_day_air_am': '59',  # 2nd Day Air A.M.
        'ups_saver': '65',  # UPS Saver.
        'ups_today_standard': '82',  # UPS Today Standard
        'ups_today_dedicated_courier': '83',  # UPS Today Dedicated Courier
        'ups_today_intercity': '84',  # UPS Today Intercity
        'ups_today_express': '85',  # UPS Today Express
        'ups_today_express_saver': '86',  # UPS Today Express Saver.
    }

returns only ID of each service. I would like to get its name. For example: get_service_name('1dayair') or get_service_name('01') would return 'Next Day Air'. I am also trying to get rates for a giving package information for all available shipping services without confirming the created shipping. Is it possible?