Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Shippo add parcel "extra" field for insurance rates. #283

Open
wants to merge 332 commits into
base: master
Choose a base branch
from

Conversation

defcronyke
Copy link

Fixes #282

Add optional "extra" field to Parcel and Shipment structs, and create Extra and Insurance structs.

I wanted to be able to request shipping rates with insurance, so I added this "extra" field as an Option type.

Unfortunately Shippo will only add the insurance rates to the price for one carrier which you have to specify in the Parcel extra.provider field, and it only supports "UPS" or "FEDEX", so if your Shippo account has more than one carrier enabled and rates are returned from multiple carriers, the other carrier rates will be returned without any insurance amount added, which isn't ideal.

It's possible to request insurance rates from a different insurance company affiliated with Shippo, on the Shipment struct's "extra" field, however I'm not using this personally and not supporting it properly in this PR, because it needs a slightly different Insurance struct with the "amount" field being a String, and instead of the "provider" field, it needs a "content": String field.

Since I wanted to buy insurance from FedEx or UPS and not Shippo's provider, I didn't feel like properly supporting the "extra" field on the Shipment struct. It would be very easy to fix this though.

See for details: https://goshippo.com/docs/insurance/

@augustuswm
Copy link
Contributor

Just to clarify on this, since I have not looked at how insurance is handled closely, can the provider field be an enum over Fedex, USPS, UDS instead of a string? (Insurance would not be able to derive Default, which it probably shouldn't have anyway)

Otherwise looks good to me.

augustuswm and others added 30 commits April 11, 2024 01:04
Fixes oxidecomputer#282

Support getting Shippo shipping rates with
shipping insurance included:
https://goshippo.com/docs/insurance/

It's supported through a field named "extra"
that's missing in Shipment for single parcel
shipments, and for multiple parcel shipments
it's supported in an "extra" field on Parcel.

Add Extra and Insurance structs.
I'm more interested in Fedex or UPS insurance,
which needs a "provider" field on the Parcel
struct, instead of a "content" field on the
Shipment struct.
Per-parcel insurance takes the amount field as a float,
not a String, while per-shipment insurance takes it as
a String.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shippo add "extra" Option field to NewShipment and Parcel to support insurance or other
4 participants