Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking: Notifications Mark II #381

Merged
merged 24 commits into from
Oct 26, 2018

Conversation

jleandroperez
Copy link
Collaborator

@jleandroperez jleandroperez commented Oct 25, 2018

Details:

  1. New Level WordPress.com Error parsing mechanism: DotcomValidator + DotcomError
  2. New NoteHash Entity: in charge of parsing (Notification ID + Hashes)
  3. New Mappers: ** NoteHashListMapper** + SuccessResultMapper
  4. New NotificationsRemote APIs
  5. And, of course, unit tests all over the place!

Testing:

  • Verify the code makes sense!!.
  • Do you think the DotcomValidator / DotcomError mechanisms make sense? (goal is to have a catch-all top level parser, but, by all means, please do let me know if you don't really like it!!!!)
  • Verify (the new and shiny) Unit Tests look good

Ref. #19

cc @bummytime @mindgraffiti
Thanks in advance!!

@jleandroperez jleandroperez added the feature: notifications Related to notifications or notifs. label Oct 25, 2018
@jleandroperez jleandroperez added this to the 0.10 milestone Oct 25, 2018
@jleandroperez jleandroperez self-assigned this Oct 25, 2018
@wpmobilebot
Copy link
Collaborator

1 Warning
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 Danger

@bummytime bummytime added this to MVLP Backlog in MVLP Kanban Board via automation Oct 25, 2018
@bummytime bummytime moved this from MVLP Backlog to Review/Testing in MVLP Kanban Board Oct 25, 2018
Copy link
Member

@bummytime bummytime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jleandroperez This is all great. I have some general comments, but I really couldn't find any issues in this PR.

:shipit:


/// Returns a String with the JSON Representation of the receiver.
///
func toJSONEncoded() -> String? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 !


/// WordPress.com Request Error
///
public struct DotcomError: Error, Decodable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prolly should have done this a while ago...

let encoded = try! encoder.encode(parameters)

return String(data: encoded, encoding: .utf8)
return parameters.toJSONEncoded()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇


/// WordPress.com Response Validator
///
struct DotcomValidator {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this approach with DotcomValidator — preprocessing the response through this first via Remote will give us the latitude to handle many different error conditions (and it's more efficient than letting a mapper error out).

///
public func updateReadStatus(_ notificationID: String, read: Bool, completion: @escaping (Error?) -> Void) {
// Note: Isn't the API wonderful?
let booleanFromPlanetMars = read ? Constants.readAsInteger : Constants.unreadAsInteger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

@jleandroperez
Copy link
Collaborator Author

I'll document DotcomValidator / SuccessMapper in another PR (getting this one in, so that we unlock the Storage Layer task!).

@bummytime @mindgraffiti thanks A LOT for the review!!!!

@jleandroperez jleandroperez merged commit 5e11921 into develop Oct 26, 2018
MVLP Kanban Board automation moved this from Review/Testing to Done/Merged Oct 26, 2018
@jleandroperez jleandroperez deleted the issue/19-notifications-networking-mk2 branch October 26, 2018 16:35
@astralbodies astralbodies mentioned this pull request Nov 1, 2018
39 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: notifications Related to notifications or notifs.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants