goshippo / shippo-node-client

Shipping API Node.js library (USPS, FedEx, UPS and more)
https://goshippo.com/docs
MIT License
136 stars 54 forks source link

Any way to get Enums through the API #75

Closed JacobShopWired closed 2 years ago

JacobShopWired commented 2 years ago

Is there any way for me to programmatically fetch the Enums available through the API? I'm looking to get the Service Levels and Parcel Templates specifically

Or do I need to enter all of these manually into my application so my users can select which one they want to use?

jfriedr commented 2 years ago

@JacobShopWired generally speaking API will return all possible service levels tokens for a given shipment (note often times it's not all of them). Unless you're using the "insta-label" API call (wherein you're not rate shopping) keeping track of all the service levels isn't necessary.

If you take a look at the raw response (specifically the "rates" nested values this becomes clearer):

{ ...
    "rates": [
        {
            "object_created": "2022-01-06T01:46:28.014Z",
            "object_id": "a15532b51e8e4983be682974ddf1e8d4",
            "object_owner": "example@goshippo.com",
            "shipment": "003da06e40df4943966aab5ca73c62b9",
            "attributes": [
                "FASTEST"
            ],
            "amount": "2927.64",
            "currency": "HKD",
            "amount_local": "375.50",
            "currency_local": "USD",
            "provider": "FedEx",
            "provider_image_75": "https://dev-qa-static-shippodev-com.s3.amazonaws.com/providers/75/FedEx.png",
            "provider_image_200": "https://dev-qa-static-shippodev-com.s3.amazonaws.com/providers/200/FedEx.png",
            "servicelevel": {
                "name": "International First®",
                "token": "fedex_international_first",
                "terms": "",
                "extended_token": "fedex_international_first",
                "parent_servicelevel": null
            },
            "estimated_days": 2,
            "arrives_by": null,
            "duration_terms": "0:00 A.M. IF NO CUSTOMS DELAY",
            "messages": [],
            "carrier_account": "172231ba1742487ca2e3bba9efb3c84a",
            "test": false,
            "zone": "US001D"
        },
        {
            "object_created": "2022-01-06T01:46:28.013Z",
            "object_id": "eaa4c8e742df4348a22cf16cff119f9b",
            "object_owner": "example@goshippo.com",
            "shipment": "003da06e40df4943966aab5ca73c62b9",
            "attributes": [],
            "amount": "2180.10",
            "currency": "HKD",
            "amount_local": "279.62",
            "currency_local": "USD",
            "provider": "FedEx",
            "provider_image_75": "https://dev-qa-static-shippodev-com.s3.amazonaws.com/providers/75/FedEx.png",
            "provider_image_200": "https://dev-qa-static-shippodev-com.s3.amazonaws.com/providers/200/FedEx.png",
            "servicelevel": {
                "name": "International Priority Express",
                "token": "fedex_international_priority_express",
                "terms": "",
                "extended_token": "fedex_international_priority_express",
                "parent_servicelevel": null
            },
            "estimated_days": null,
            "arrives_by": null,
            "duration_terms": "0:00 A.M. IF NO CUSTOMS DELAY",
            "messages": [],
            "carrier_account": "172231ba1742487ca2e3bba9efb3c84a",
            "test": false,
            "zone": "F"
        },
        {
            "object_created": "2022-01-06T01:46:28.013Z",
            "object_id": "b390a3bc2ab24ac39fffb7d8ba2e21ea",
            "object_owner": "example@goshippo.com",
            "shipment": "003da06e40df4943966aab5ca73c62b9",
            "attributes": [
                "BESTVALUE",
                "CHEAPEST",
                "FASTEST"
            ],
            "amount": "2122.09",
            "currency": "HKD",
            "amount_local": "272.18",
            "currency_local": "USD",
            "provider": "FedEx",
            "provider_image_75": "https://dev-qa-static-shippodev-com.s3.amazonaws.com/providers/75/FedEx.png",
            "provider_image_200": "https://dev-qa-static-shippodev-com.s3.amazonaws.com/providers/200/FedEx.png",
            "servicelevel": {
                "name": "International Priority®",
                "token": "fedex_international_priority",
                "terms": "",
                "extended_token": "fedex_international_priority",
                "parent_servicelevel": null
            },
            "estimated_days": 2,
            "arrives_by": null,
            "duration_terms": "0:00 A.M. IF NO CUSTOMS DELAY",
            "messages": [],
            "carrier_account": "172231ba1742487ca2e3bba9efb3c84a",
            "test": false,
            "zone": "F"
        }
    ]
...
}

Please let me know if the above works for your usecase as currently there is not an API call which returns all of the enums.

JacobShopWired commented 2 years ago

Thanks a lot for your reply. I was hoping to use the "insta-label" API call in my application (so we can export information to Shippo without our customers needing to interact with the application I am developing), as well as the rate shopping version.

Do you know if there is a way to get the Parcel templates through the API? As at the moment I foresee the need to enter all of them into my application manually so that my customers can choose some, which I feel will take a long time due to how many there are. Failing that, is there a JSON for these enums I can download for use on my end? Or something I can translate to JSON? Thanks 😄

jfriedr commented 2 years ago

I would recommend first setting up things with the rates and then (per customer) deciding if insta-label is the right choice for them. I'll also add it's a bit easier to debug why something isn't working by first requesting a rate and then purchasing the label. Additionally carriers often include messages related to corrections or errors when making a rate request which can be returned to the customer.

There is not currently a way to get every parcel template via the API. Do you know if each of these box types are available for each of your customers when shipping?

I've passed along your situation to our product team for a possible feature request unfortunately I don't have any sort of timeline on when this will be available.

Is there a specific list of carriers you'd like to start off with for box templates?

JacobShopWired commented 2 years ago

Do you know if each of these box types are available for each of your customers when shipping?

Sadly not, no. I think I need access to them all no matter what as our customers can differ in their needs and shipping locations.

I've passed along your situation to our product team for a possible feature request

Thank you

unfortunately I don't have any sort of timeline on when this will be available

No problem. Thanks for passing it on.

Unfortunately, I need access to all the box templates from all carriers.

I've got the manual exporting setup in my application, where a user is able to choose a rate. I just now need to proceed with the single API call version of exporting, which for me, requires these enums.

Is there a specific list of carriers you'd like to start off with for box templates?

UPS is probably the best place to start with it being the longest.

JacobShopWired commented 2 years ago

Hi guys. Do you have any update for me on this?

jfriedr commented 2 years ago

Hey @JacobShopWired sorry this got dropped. Could you please send an email to partnerships and we can get a list your way. partnerships@goshippo.com