Add shipped labels to manifest to handle errors #3
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.
When adding labels to a manifest, we can receive partially successful responses from DHL. These changes add labels to the manifest and only appends the shipping labels that were successfully attached to the closeout.
http://api.dhlglobalmail.com/docs/closeout.html
I'm open to alternate design approaches here, but I needed a way to differentiate between what labels were actually appended to the manifest and which failed to attach (normally because they were closed out previously).
An alternate approach I abandoned because it seemed too obscured is to take an optional block as a parameter that is passed failed labels so the caller can decide what to do with them.
The main downside to the way I have attached labels to the returned manifest object is that this data is not actually returned by the API. Rather, it is constructed from the input to .create(labels). This could lead to inconsistency in what data is present since a caller could pass any ducktyped object that has the impb construct on it to be added to the manifest. I'm not too worried about this since the caller both injects that information and then uses it after the call, but I'm open to ways to clean it up.
Also includes a small refactor on the manifest.rb to chunk out the individual steps in the three step manifest process for clarity.