You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified that the requested feature does not already exist or has not already been requested.
Description of the feature
Certain fields require one of a few specific, well-defined by Easypost, values. For example, the incoterm field must be one of the following ("EXW", "FCA", "CPT", "CIP", "DAT", "DAP", "DDP", "FAS", "FOB", "CFR", and "CIF"). Currently the fields in structs just accept a string that can be one of the previously provided options or something incorrect.
Defining const would reduce the chances of users of providing unacceptable values since the user would use a const instead. This reduces typos, as well as the need to go back-and-forth between code and the API docs. Code editors would also be able to provide auto-completion hints based on the type of a struct field and the consts defined for that type.
This would not break existing code that uses strings to provide the value. The types defined as type t string would still accept "string" values instead of the consts.
dropoff_type (maybe prefix the const names with FedEx as applicable).
deliver_confirmation
...
Example:
//Define the type.typeincotermstring//Define list of consts, with comments on separate previous line for code-editor hints, as needed...const (
IncotermEXWincoterm="EXW"
)
//Modify the struct type definition...typeShipmentOptions {
//...Incotermincoterm`json:"incoterm,omitempty"`//...
}
We've been exploring the ideas of using constants/enums in our client libraries for common values as you've suggested. It's good to know that some of our end-users would clearly benefit from their inclusion.
Feature Request Is New
Description of the feature
Certain fields require one of a few specific, well-defined by Easypost, values. For example, the
incoterm
field must be one of the following ("EXW", "FCA", "CPT", "CIP", "DAT", "DAP", "DDP", "FAS", "FOB", "CFR", and "CIF"). Currently the fields in structs just accept astring
that can be one of the previously provided options or something incorrect.Defining const would reduce the chances of users of providing unacceptable values since the user would use a const instead. This reduces typos, as well as the need to go back-and-forth between code and the API docs. Code editors would also be able to provide auto-completion hints based on the type of a struct field and the consts defined for that type.
This would not break existing code that uses strings to provide the value. The types defined as
type t string
would still accept"string"
values instead of the consts.Some places where this would be applicable:
Example:
Use as...
This still works...
The text was updated successfully, but these errors were encountered: