[feat] Add ability to construct Options object from dictionary #547
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The
Options
object has always been in a weird middle-ground since we introduced parameter objects over a year ago, mainly because it it one of the few object classes in the library that is used in both requests (parameter sets) and responses (property of aShipment
model). Because the object is so large, with several dozen different "properties" (options), we've chosen not to duplicate it into request-specific and response-specific classes, but simply use the existingOptions
class, designed primarily for response JSON serialization, also for request JSON deserialization in parameter sets.That has made the
Options
class difficult to transition to the parameter set construction paradigm we've established, especially because of how many properties it has that can be set.This PR offers a "shortcut" to allow end-users to use a dictionary (for those still using the legacy dictionary method instead of parameter sets) to generate an
Options
object via a behind-the-scenes deserialization-serialization process. As with all our legacy dictionary-based functionality, this method relies on the end-user to properly construct a dictionary with the valid schema and key-value pairs (any invalid key-value pairs are inherently ignored and therefore won't produce the anticipatedOptions
object upon de/serialization).This is potentially the start of a larger effort to offer
FromDictionary
methods for all the Parameter classes to better facility (and validate) those still using the legacy dictionary workflow. For now, theOptions
object, due to its double-duty usage and its size and complexity, is the perfect initial candidate for this concept.Testing
FromDictionary
method works as expectedPull Request Type
Please select the option(s) that are relevant to this PR.