merge-api / merge-csharp-client

The C Sharp SDK for accessing various Merge Unified APIs
Other
2 stars 1 forks source link

Enums occasionally have extra values, but this client's serialisation won't handle that #29

Open robfe opened 4 months ago

robfe commented 4 months ago

Enums like Job.Status https://github.com/merge-api/merge-csharp-client/blob/c03fb3311b8db48276b11b7ab9d4081caf0bb68c/src/Merge.Client/Ats/Types/Job.cs#L61 can occasionally have the ATS's raw value passed through if the value isn't mapped

Yash Gogri at Merge helped me understand this in a prior email conversation: image

In the situations where there may be custom values set up by the end-user, Merge will not have those enums mapped (since they aren't standard). In those situations, we will return the raw value from the API. While our Platform team aims to map as much values into the enums as possible, it's always possible a new customer can have a custom set-up where their status values don't fall into what's been already mapped. 
Screenshot 2023-12-11 at 11.11.33 AM.png

Due to this, we do recommend keeping additional checks / leniency around enum values. Many of our customers implement fuzzy matching on top of our enums whenever a raw value gets returned. Some customers actually during their onboarding process directly ask their customers what Status Values they use in their system and how they'd like that reflected in the product. From there, they'll use our show_enum_origins parameter to always return the raw value and map those accordingly based on the customer's ask. 

Is it possible to implement such leniency in this client, perhaps Job.Status should be a OneOf string / JobStatus enum?