Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

SDK V2 #28

Merged
merged 45 commits into from
Oct 18, 2018
Merged

SDK V2 #28

merged 45 commits into from
Oct 18, 2018

Conversation

PimCoumans
Copy link
Contributor

@PimCoumans PimCoumans commented Oct 8, 2018

Big update again. It was too complicated to break this down into separate branches as most changes were touching too many files.

What happened?

As with WeTransfer API V2, the SDK now allows the implementer to use both Boards and Transfers with their respective unique functionality.

What to look for

  • Is the separation cleanly implemented? Does the Transferable protocol make sense?
  • Most operations have some branching logic for either a Transfer or a Board, is this done correctly?
  • I'm still looking through the documentation, making sure everything still makes sense

While this PR might lightly address some, please look at the standing issues before commenting unrelated structural quirks.

Copy link
Contributor

@AvdLee AvdLee left a comment

Choose a reason for hiding this comment

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

Great to see it's Swift 4.2 already! To bad it's such a big PR again. Can we do something about that to make this review go faster?

First part of my review is here at least.

WeTransfer/Models/Board.swift Outdated Show resolved Hide resolved
import Foundation

/// Desribes a single board to be created, adding files to and uploading files from. Used as an identifier between each request to be made and a local representation of the server-side board.
/// Files should be added through the approapriate addFiles method
Copy link
Contributor

Choose a reason for hiding this comment

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

approapriate typo


/// Desribes a single board to be created, adding files to and uploading files from. Used as an identifier between each request to be made and a local representation of the server-side board.
/// Files should be added through the approapriate addFiles method
public final class Board: Transferrable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Transferrable -> Transferable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

public let description: String?

/// References to all the files added to the board. Files can be added with the public method on the WeTransfer struct
public private(set) var files: [File] = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Boards can contain links as well, which are not files. Rather call this Content

Copy link
Contributor Author

@PimCoumans PimCoumans Oct 9, 2018

Choose a reason for hiding this comment

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

Links wil be added when addressing #8, for now boards and transfer only support files.


init(name: String, description: String?) {
self.name = name
self.description = description
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just tabs, just like in the rest of the project. Will be addressed in future PR

/// Number of multiparts (chunks) and upload identifier for uploading
let meta: Meta
let multipart: Multipart
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this upload info? Multipart is not really describing to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be picked up when addressing #16. For now all responses are exactly as returned by the API (minus snake case of course)

Copy link
Contributor

Choose a reason for hiding this comment

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

You can adjust the name here, right? It's really simple to change just a parameter name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh you mean the struct name, that is indeed possible. Done!

/// Response from complete upload request
struct CompleteUploadResponse: Decodable {
struct CompleteTransferFileUploadResponse: Decodable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather define a generic EmptyResponse instead so it can be reused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, great suggestion.

operation.onResult = { result in
DispatchQueue.main.async {
completion(result)
}
}

// Externally create the board if not already in the queue
if board.identifier == nil && client.operationQueue.operations.first(where: { $0 is CreateBoardOperation }) == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this identifier the publicIdentifier? we can make this line more describing by making something like board.isShared. Now I'm guessing, so we only do this when the identifier is nil? Like, why only then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mentioned and now appended in #13, good stuff 👍

@ghost
Copy link

ghost commented Oct 9, 2018

1 Error
🚫 Coverage creation failed
1 Message
📖 Executed 20 tests, with 0 failures (0 unexpected) in 17.346 (17.368) seconds

Generated by 🚫 Danger


override func execute() {
guard board.identifier == nil else {
self.finish(with: .success(board))
Copy link
Contributor

Choose a reason for hiding this comment

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

self is not needed

self.file = file
self.chunkIndex = chunkIndex
}

override func execute() {
guard let fileIdentifier = file.identifier, let uploadIdentifier = file.multipartUploadIdentifier else {
guard let containerIdentifier = container.identifier, let fileIdentifier = file.identifier else {
self.finish(with: .failure(Error.fileNotYetAdded))
Copy link
Contributor

Choose a reason for hiding this comment

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

self is not needed

endpoint = .requestTransferUploadURL(transferIdentifier: containerIdentifier, fileIdentifier: fileIdentifier, chunkIndex: chunkIndex)
} else if container is Board {
guard let multipartIdentifier = file.multipartUploadIdentifier else {
self.finish(with: .failure(Error.fileNotYetAdded))
Copy link
Contributor

Choose a reason for hiding this comment

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

self is not needed

@@ -9,7 +9,7 @@
import Foundation

/// Handles the uploading of all files -- that are not uploaded yet -- in the provided transfer. Creates an operation queue with an `UploadFileOperation` for each file to be uploaded.
final class UploadFilesOperation: ChainedAsynchronousResultOperation<Transfer, Transfer>, URLSessionDataDelegate {
final class UploadFilesOperation<Container>: ChainedAsynchronousResultOperation<Container, Container>, URLSessionDataDelegate where Container: Transferable {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just use Container: Transferable, right? And shouldn't we name it like transferrable with 2 rs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was actually the other way around, I typed it with 2 rs originally but that's not the correct spelling.

override func tearDown() {
super.tearDown()
TestConfiguration.resetConfiguration()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you want to create a base test class? quite some duplicate code everywhere now with the same tearDown and setUp


var observation: NSKeyValueObservation?

func testFileUpload() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test seems to do more than one thing indeed. You might want to split this up

@PimCoumans
Copy link
Contributor Author

@AvdLee All your comments should be resolved now
@Boris-Em Would you like to take a look too?

/// Number of multiparts (chunks) and upload identifier for uploading
let multipart: Multipart
/// Upload info for the file
let multipart: UploadInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's good to also rename the parameter name to uploadInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I’m not going to do that know. All changed to Decodable structs will be addressed when fixing issue #16

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not? It's really easy. Find +replace or using the refactor mechanism in Xcode. It only makes your life easier with #16. I don't really get why you don't want to do it here actually 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it’s a response from the server and if I add the CodingKeys here, I’d rather do those all at once

@PimCoumans PimCoumans mentioned this pull request Oct 18, 2018
@PimCoumans PimCoumans merged commit 5bc39b5 into master Oct 18, 2018
@PimCoumans PimCoumans deleted the feature/transfer-board-split branch October 18, 2018 09:19
@PimCoumans PimCoumans restored the feature/transfer-board-split branch October 18, 2018 09:24
@PimCoumans PimCoumans deleted the feature/transfer-board-split branch October 18, 2018 09:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants