feat: add function to update channel in notifications preferences #34
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.
In this PR
This PR contains two things:
Discussion
The
/notification_preferences
endpoint is funny in the way that aGET
request returns a different shape than aPUT
request expects. The former returnslabels
while the later does not expectlabels
. It doesn't hurt passing them, and thePUT
will simply ignore them, but I've opted for making this behaviour explicit in the docstrings, and unit tests.The solution I went with simply drops the
label
keys when encodingNotificationPreferencesEntity
(see changes in Source/Features/NotificationPreferences/Data/NotificationPreferencesEntity.swift). I tried alternative approaches, but the Harmony framework in use is expecting GET and PUT datasources to have the same entity type, making it impossible to have one with, and one without labels (see this line of code and theGet.T == T, Put.T == T
). I've added a comment to the codebase that describes the behaviour.Test Plan
Tested in the sample App as shown in this video:
notification.preferences.mp4