Skip to content

Conversation

@SergioEstevao
Copy link
Contributor

Refs #5245

This is the first step to implementing our Network layer using NSURLSession stack.
In this PR I implemented a first version of the WP.com REST API object using the AFNetworking class that use NSURLSession.

One of the main design decisions was to hide away the implementations details on how the Network layer is implemented in a way that we can later switch to another solution if we want to.

This PR only changed the MediaServiceRest to use the new API object other PRs will follow that will change the other services one by one.

To test:

  • Start a new post on a WP.com blog/site
  • Add media to it image and videos.
  • See if the progress indicator are working.
  • See if it's possible to cancel the uploads
  • Check setting an featured image
  • When inserting media check if it's possible to view the WordPress media library.
  • Do the same tests using the legacy editor.

Needs review: @koke

…using_NSURLSession

# Conflicts:
#	WordPress/Classes/Models/Blog.m
#	WordPress/Classes/Services/MediaService.m
@return a WordPressComRestApi object if available
*/
- (WordPressComRestApi *)comRestApi;
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with WPAccount, I'd call this wordPressComRestApi. Also, make sure to mark it _Nullabe once #5325 is merged.

@SergioEstevao
Copy link
Contributor Author

@koke ready for another look.

@koke
Copy link
Member

koke commented May 11, 2016

I like the changes. Can you fix the merge conflicts before I do a final test?

…using_NSURLSession

# Conflicts:
#	WordPress/WordPress.xcodeproj/project.pbxproj
@SergioEstevao
Copy link
Contributor Author

@koke ready for another round of review.

…using_NSURLSession

# Conflicts:
#	WordPress/Classes/ViewRelated/Me/GravatarPickerViewController.swift
#	WordPress/Classes/ViewRelated/Me/MeViewController.swift
*/
@interface WPUserAgent : NSObject

+ (instancetype)sharedInstance;
Copy link
Member

Choose a reason for hiding this comment

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

Since WPUserAgent doesn't hold any state, why do you need a shared instance? Can't you just instantiate a new one when needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I removed this out and just use a simple instance.

userInfo[NSLocalizedDescriptionKey] = errorMessage;
newError = [[NSError alloc] initWithDomain:WordPressComApiErrorDomain code:errorCode userInfo:userInfo];
} else if ([error.domain isEqualToString:WordPressComRestApiErrorDomain]) {

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to do anything

@koke
Copy link
Member

koke commented May 11, 2016

Looks good, :shipit:

@SergioEstevao SergioEstevao merged commit 53cc161 into develop May 11, 2016
@SergioEstevao SergioEstevao deleted the issue/5245_Implement_WordPressComRESTAPI_using_NSURLSession branch May 11, 2016 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants