Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Conversation

@ghost
Copy link

@ghost ghost commented Jan 8, 2019

Description

Implements the service to fulfill the service implementation of this issue.

Testing

  • Checkout the branch. Confirm that it builds & tests pass.
  • For additional assurance, consider checking out the WPiOS branch issue/10319-wordpresskit-wip and verify that it builds and that tests pass.

@ghost ghost added the enhancement New feature or request label Jan 8, 2019
@ghost ghost self-assigned this Jan 8, 2019
@ghost ghost requested review from ctarda, frosty and yaelirub January 8, 2019 22:54
@ghost ghost force-pushed the issue/10319-site-creation-verticals-service branch from 5a427a5 to 5aea34e Compare January 8, 2019 23:04
func retrievalVerticals(request: SiteVerticalsRequest, completion: @escaping SiteVerticalsServiceCompletion) {

let endpoint = "verticals"
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)
Copy link
Contributor

@yaelirub yaelirub Jan 9, 2019

Choose a reason for hiding this comment

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

At my last workplace we had a lot of issues due to the lack of API versioning and now I see the APi versions for ServiceRemoteWordPressComRESTApiVersion. This is great!

let response = try self.decodeResponse(responseObject: responseObject)
completion(.success(response))
} catch {
DDLogError("Failed to decode \([SiteVertical].self) : \(error.localizedDescription)")
Copy link
Contributor

@yaelirub yaelirub Jan 9, 2019

Choose a reason for hiding this comment

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

I know it's not that important but just wondering: Any reason why you're logging the localizedDescription here but not in encodeRequestParameters?

Copy link
Author

Choose a reason for hiding this comment

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

I like that the error which could arise from that method is closer to the completion handler for the failure case.

I don't feel strongly about it though. :)

XCTAssertNoThrow(try JSONSerialization.jsonObject(with: encodedJSON, options: []))
let serializedJSON = try! JSONSerialization.jsonObject(with: encodedJSON, options: [])

if let _ = serializedJSON as? [String : AnyObject] {} else {
Copy link
Contributor

@yaelirub yaelirub Jan 9, 2019

Choose a reason for hiding this comment

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

Can we do

Suggested change
if let _ = serializedJSON as? [String : AnyObject] {} else {
guard let jsonDictionary = serializedJSON as [String : AnyObject] else {
XCTFail("Failed to encode a proper JSON dictionary!")
}

and then remove let jsonDictionary = serializedJSON as! [String : AnyObject]

?

Copy link
Author

Choose a reason for hiding this comment

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

I like it. I will push a change that takes care of this in each of these test methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Do you think we should do the same in line 53?

// MARK: Multiple Verticals

func testSiteParsingOfMultipleVerticalsWorksAsExpected() {
XCTAssertTrue(!verticalsSUT.isEmpty)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to test that its not empty and that it is equal 5? shouldn't equal 5 be enough?

Copy link
Author

Choose a reason for hiding this comment

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

You're not wrong. 😁 I will push a commit that takes care of this as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@yaelirub
Copy link
Contributor

yaelirub commented Jan 9, 2019

@stevebaranski , thank you so much for including me in this! Such a well written PR!

@ghost
Copy link
Author

ghost commented Jan 9, 2019

@yaelirub thanks for the thoughtful feedback! I have pushed a commit that incorporates your suggestions.

Copy link
Contributor

@frosty frosty left a comment

Choose a reason for hiding this comment

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

Great stuff 👍 Tests passing both here and in the WPiOS wip branch.

@ghost ghost merged commit 1fd43b0 into develop Jan 9, 2019
@ghost ghost deleted the issue/10319-site-creation-verticals-service branch January 9, 2019 15:59
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants