// // Result+Dropbox.swift // Harmony-Dropbox // // Created by Riley Testut on 3/12/19. // Copyright © 2019 Riley Testut. All rights reserved. // import Harmony import SwiftyDropbox extension Result { init(_ value: Success?, _ error: SwiftyDropbox.CallError?) where Failure == DropboxService.CallError { switch (value, error) { case (let value?, _): self = .success(value) case (_, let error?): self = .failure(DropboxService.CallError(error)) case (nil, nil): self = .failure(DropboxService.CallError(SwiftyDropbox.CallError.clientError(ServiceError.invalidResponse))) } } } extension Result where Success == Void { init(_ error: SwiftyDropbox.CallError?) where Failure == DropboxService.CallError { if let error = error { self = .failure(DropboxService.CallError(error)) } else { self = .success } } }