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: Remote Infrastructure #54

Merged
merged 97 commits into from
May 9, 2018

Conversation

jleandroperez
Copy link
Collaborator

@jleandroperez jleandroperez commented May 7, 2018

Description:

This PR implements the basic Remote infrastructure we'll be using to call remote API's.

Ref. #24

Details:

  • Collections of Endpoints will live in subclasses of Remote (this is analog to WPiOS).
  • Remote comes, from factory, with a new Mapping mechanism, along with Unit Testing support (without requiring external dependencies).
  • We're implementing a basic Data Model: Order + OrderStatus + Address. This is not 100% finished, yet, and will be addressed in a third PR.

Response Mapping:

This concept was envisioned by @diegoreymendez. The idea is all about defining the piece of code that parses Backend Responses, establishing a protocol with the expected API, and implementing "Mapping" objects, which will be responsible for parsing documents.

Huge benefits of this approach are, mostly:

  • Code Reuse: Any endpoint with a similar response can just use the same Mapper
  • Separation of responsibilities: The Remote implementation is no longer responsible for doing everything.

Unit Testing

In Unit Testing Targets, we'll be able to access a Remote internal initializer which allows us to inject NetworkMockup (see OrderRemoteTests).

By means of NetworkMockup, we'll be able to specify which json file should be returned, whenever a given remote RPC is performed.


Testing:

  • Verify the unit tests look good (single test added here, more to come in another PR)
  • Please review all of the code superclose!!

@mindgraffiti May i bug you with this one Thuy?.
cc @diegoreymendez @astralbodies We should seriously consider bringing this architecture back to WPiOS

@jleandroperez jleandroperez changed the title [NOT Ready!] Networking: Remote Infrastructure Networking: Remote Infrastructure May 9, 2018
@jleandroperez jleandroperez added this to the Internal alpha release milestone May 9, 2018
@jleandroperez jleandroperez added the category: architecture Related to architecture such as the database, FluxC, Networking, Core Data, etc. label May 9, 2018
@jleandroperez jleandroperez added this to In Progress in MVLP Kanban Board May 9, 2018
Copy link
Contributor

@mindgraffiti mindgraffiti left a comment

Choose a reason for hiding this comment

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

Looks great! Needs a little 💟on some nitpicky spelling items, then :shipit: !


/// Date And Time Formatter
///
static let dateTimeFormatter: DateFormatter = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not part of the WPShared pod? I thought it had several date helpers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haven't really checked! but since it's a Woo-Backend format, it's okay to add a few lines here (vs linking an entire dependency!!). Goal is to keep this fellow as lightweight as possible ❤️

}



Copy link
Contributor

Choose a reason for hiding this comment

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

Nuke extra line



/// OrderList Disposable Entity:
/// `Load All Orders` endpoint returns all of it's orders within the `data` key. This entity
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicky!!! its instead of it's

/// - Parameters:
/// - request: Request that should be performed.
/// - completion: Closure to be executed upon completion.
/// - completion: Closure to be executed upon completion. Will receive the JSON Parsed Response (if successfull)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicky - successful instead of successfull

@jleandroperez
Copy link
Collaborator Author

Thanks A LOT for the review @mindgraffiti (all of the feedback addressed, thanks thanks thanks!!!!)

@jleandroperez jleandroperez merged commit 21e833f into develop May 9, 2018
MVLP Kanban Board automation moved this from In Progress to Done/Merged May 9, 2018
@jleandroperez jleandroperez deleted the issue/24-remote-infrastructure branch May 9, 2018 20:46
@astralbodies astralbodies mentioned this pull request May 17, 2018
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: architecture Related to architecture such as the database, FluxC, Networking, Core Data, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants