Skip to content

Commit

Permalink
Generate reconnection helpers including route namespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlocke committed Aug 26, 2024
1 parent 1951433 commit 67285bf
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

import Foundation

// The case string below must match those created by ReconnectionHelpers+Handwritten.swift using
// the route name and namespace as formatted for the generate `Route` object in SwiftyTypes.jinja
// Format: "<namespace>/<route_name>" e.g., "files/upload_session/append_v2" for Files.uploadSessionAppendV2
enum AppAuthReconnectionHelpers: ReconnectionHelpersShared {
static func rebuildRequest(apiRequest: ApiRequest, client: DropboxTransportClientInternal) throws -> DropboxAppBaseRequestBox {
let info = try persistedRequestInfo(from: apiRequest)

switch info.routeName {
case "get_thumbnail_v2":
return .getThumbnailV2(
switch info.namespaceRouteName {
case "files/get_thumbnail_v2":
return .files_getThumbnailV2(
rebuildRequest(
apiRequest: apiRequest,
info: info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import Foundation

/// Allows for heterogenous collections of typed requests
public enum DropboxAppBaseRequestBox: CustomStringConvertible {
case getThumbnailV2(DownloadRequestFile<Files.PreviewResultSerializer, Files.ThumbnailV2ErrorSerializer>)
case files_getThumbnailV2(DownloadRequestFile<Files.PreviewResultSerializer, Files.ThumbnailV2ErrorSerializer>)

public var description: String {
switch self {
case .getThumbnailV2:
return "getThumbnailV2"
case .files_getThumbnailV2:
return "files/get_thumbnail_v2"
}
}
}
110 changes: 55 additions & 55 deletions Source/SwiftyDropbox/Shared/Generated/DropboxBaseRequestBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,63 @@ import Foundation

/// Allows for heterogenous collections of typed requests
public enum DropboxBaseRequestBox: CustomStringConvertible {
case alphaUpload(UploadRequest<Files.FileMetadataSerializer, Files.UploadErrorSerializer>)
case download(DownloadRequestFile<Files.FileMetadataSerializer, Files.DownloadErrorSerializer>)
case downloadZip(DownloadRequestFile<Files.DownloadZipResultSerializer, Files.DownloadZipErrorSerializer>)
case export(DownloadRequestFile<Files.ExportResultSerializer, Files.ExportErrorSerializer>)
case getPreview(DownloadRequestFile<Files.FileMetadataSerializer, Files.PreviewErrorSerializer>)
case getThumbnail(DownloadRequestFile<Files.FileMetadataSerializer, Files.ThumbnailErrorSerializer>)
case getThumbnailV2(DownloadRequestFile<Files.PreviewResultSerializer, Files.ThumbnailV2ErrorSerializer>)
case paperCreate(UploadRequest<Files.PaperCreateResultSerializer, Files.PaperCreateErrorSerializer>)
case paperUpdate(UploadRequest<Files.PaperUpdateResultSerializer, Files.PaperUpdateErrorSerializer>)
case upload(UploadRequest<Files.FileMetadataSerializer, Files.UploadErrorSerializer>)
case uploadSessionAppendV2(UploadRequest<VoidSerializer, Files.UploadSessionAppendErrorSerializer>)
case uploadSessionAppend(UploadRequest<VoidSerializer, Files.UploadSessionAppendErrorSerializer>)
case uploadSessionFinish(UploadRequest<Files.FileMetadataSerializer, Files.UploadSessionFinishErrorSerializer>)
case uploadSessionStart(UploadRequest<Files.UploadSessionStartResultSerializer, Files.UploadSessionStartErrorSerializer>)
case docsCreate(UploadRequest<Paper.PaperDocCreateUpdateResultSerializer, Paper.PaperDocCreateErrorSerializer>)
case docsDownload(DownloadRequestFile<Paper.PaperDocExportResultSerializer, Paper.DocLookupErrorSerializer>)
case docsUpdate(UploadRequest<Paper.PaperDocCreateUpdateResultSerializer, Paper.PaperDocUpdateErrorSerializer>)
case getSharedLinkFile(DownloadRequestFile<Sharing.SharedLinkMetadataSerializer, Sharing.GetSharedLinkFileErrorSerializer>)
case files_alphaUpload(UploadRequest<Files.FileMetadataSerializer, Files.UploadErrorSerializer>)
case files_download(DownloadRequestFile<Files.FileMetadataSerializer, Files.DownloadErrorSerializer>)
case files_downloadZip(DownloadRequestFile<Files.DownloadZipResultSerializer, Files.DownloadZipErrorSerializer>)
case files_export(DownloadRequestFile<Files.ExportResultSerializer, Files.ExportErrorSerializer>)
case files_getPreview(DownloadRequestFile<Files.FileMetadataSerializer, Files.PreviewErrorSerializer>)
case files_getThumbnail(DownloadRequestFile<Files.FileMetadataSerializer, Files.ThumbnailErrorSerializer>)
case files_getThumbnailV2(DownloadRequestFile<Files.PreviewResultSerializer, Files.ThumbnailV2ErrorSerializer>)
case files_paperCreate(UploadRequest<Files.PaperCreateResultSerializer, Files.PaperCreateErrorSerializer>)
case files_paperUpdate(UploadRequest<Files.PaperUpdateResultSerializer, Files.PaperUpdateErrorSerializer>)
case files_upload(UploadRequest<Files.FileMetadataSerializer, Files.UploadErrorSerializer>)
case files_uploadSessionAppendV2(UploadRequest<VoidSerializer, Files.UploadSessionAppendErrorSerializer>)
case files_uploadSessionAppend(UploadRequest<VoidSerializer, Files.UploadSessionAppendErrorSerializer>)
case files_uploadSessionFinish(UploadRequest<Files.FileMetadataSerializer, Files.UploadSessionFinishErrorSerializer>)
case files_uploadSessionStart(UploadRequest<Files.UploadSessionStartResultSerializer, Files.UploadSessionStartErrorSerializer>)
case paper_docsCreate(UploadRequest<Paper.PaperDocCreateUpdateResultSerializer, Paper.PaperDocCreateErrorSerializer>)
case paper_docsDownload(DownloadRequestFile<Paper.PaperDocExportResultSerializer, Paper.DocLookupErrorSerializer>)
case paper_docsUpdate(UploadRequest<Paper.PaperDocCreateUpdateResultSerializer, Paper.PaperDocUpdateErrorSerializer>)
case sharing_getSharedLinkFile(DownloadRequestFile<Sharing.SharedLinkMetadataSerializer, Sharing.GetSharedLinkFileErrorSerializer>)

public var description: String {
switch self {
case .alphaUpload:
return "alphaUpload"
case .download:
return "download"
case .downloadZip:
return "downloadZip"
case .export:
return "export"
case .getPreview:
return "getPreview"
case .getThumbnail:
return "getThumbnail"
case .getThumbnailV2:
return "getThumbnailV2"
case .paperCreate:
return "paperCreate"
case .paperUpdate:
return "paperUpdate"
case .upload:
return "upload"
case .uploadSessionAppendV2:
return "uploadSessionAppendV2"
case .uploadSessionAppend:
return "uploadSessionAppend"
case .uploadSessionFinish:
return "uploadSessionFinish"
case .uploadSessionStart:
return "uploadSessionStart"
case .docsCreate:
return "docsCreate"
case .docsDownload:
return "docsDownload"
case .docsUpdate:
return "docsUpdate"
case .getSharedLinkFile:
return "getSharedLinkFile"
case .files_alphaUpload:
return "files/alpha/upload"
case .files_download:
return "files/download"
case .files_downloadZip:
return "files/download_zip"
case .files_export:
return "files/export"
case .files_getPreview:
return "files/get_preview"
case .files_getThumbnail:
return "files/get_thumbnail"
case .files_getThumbnailV2:
return "files/get_thumbnail_v2"
case .files_paperCreate:
return "files/paper/create"
case .files_paperUpdate:
return "files/paper/update"
case .files_upload:
return "files/upload"
case .files_uploadSessionAppendV2:
return "files/upload_session/append_v2"
case .files_uploadSessionAppend:
return "files/upload_session/append"
case .files_uploadSessionFinish:
return "files/upload_session/finish"
case .files_uploadSessionStart:
return "files/upload_session/start"
case .paper_docsCreate:
return "paper/docs/create"
case .paper_docsDownload:
return "paper/docs/download"
case .paper_docsUpdate:
return "paper/docs/update"
case .sharing_getSharedLinkFile:
return "sharing/get_shared_link_file"
}
}
}
}
77 changes: 40 additions & 37 deletions Source/SwiftyDropbox/Shared/Generated/ReconnectionHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,166 +4,169 @@

import Foundation

// The case string below must match those created by ReconnectionHelpers+Handwritten.swift using
// the route name and namespace as formatted for the generate `Route` object in SwiftyTypes.jinja
// Format: "<namespace>/<route_name>" e.g., "files/upload_session/append_v2" for Files.uploadSessionAppendV2
enum ReconnectionHelpers: ReconnectionHelpersShared {
static func rebuildRequest(apiRequest: ApiRequest, client: DropboxTransportClientInternal) throws -> DropboxBaseRequestBox {
let info = try persistedRequestInfo(from: apiRequest)

switch info.routeName {
case "alpha/upload":
return .alphaUpload(
switch info.namespaceRouteName {
case "files/alpha/upload":
return .files_alphaUpload(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.alphaUpload,
client: client
)
)
case "download":
return .download(
case "files/download":
return .files_download(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.download,
client: client
)
)
case "download_zip":
return .downloadZip(
case "files/download_zip":
return .files_downloadZip(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.downloadZip,
client: client
)
)
case "export":
return .export(
case "files/export":
return .files_export(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.export,
client: client
)
)
case "get_preview":
return .getPreview(
case "files/get_preview":
return .files_getPreview(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.getPreview,
client: client
)
)
case "get_thumbnail":
return .getThumbnail(
case "files/get_thumbnail":
return .files_getThumbnail(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.getThumbnail,
client: client
)
)
case "get_thumbnail_v2":
return .getThumbnailV2(
case "files/get_thumbnail_v2":
return .files_getThumbnailV2(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.getThumbnailV2,
client: client
)
)
case "paper/create":
return .paperCreate(
case "files/paper/create":
return .files_paperCreate(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.paperCreate,
client: client
)
)
case "paper/update":
return .paperUpdate(
case "files/paper/update":
return .files_paperUpdate(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.paperUpdate,
client: client
)
)
case "upload":
return .upload(
case "files/upload":
return .files_upload(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.upload,
client: client
)
)
case "upload_session/append_v2":
return .uploadSessionAppendV2(
case "files/upload_session/append_v2":
return .files_uploadSessionAppendV2(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.uploadSessionAppendV2,
client: client
)
)
case "upload_session/append":
return .uploadSessionAppend(
case "files/upload_session/append":
return .files_uploadSessionAppend(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.uploadSessionAppend,
client: client
)
)
case "upload_session/finish":
return .uploadSessionFinish(
case "files/upload_session/finish":
return .files_uploadSessionFinish(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.uploadSessionFinish,
client: client
)
)
case "upload_session/start":
return .uploadSessionStart(
case "files/upload_session/start":
return .files_uploadSessionStart(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Files.uploadSessionStart,
client: client
)
)
case "docs/create":
return .docsCreate(
case "paper/docs/create":
return .paper_docsCreate(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Paper.docsCreate,
client: client
)
)
case "docs/download":
return .docsDownload(
case "paper/docs/download":
return .paper_docsDownload(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Paper.docsDownload,
client: client
)
)
case "docs/update":
return .docsUpdate(
case "paper/docs/update":
return .paper_docsUpdate(
rebuildRequest(
apiRequest: apiRequest,
info: info,
route: Paper.docsUpdate,
client: client
)
)
case "get_shared_link_file":
return .getSharedLinkFile(
case "sharing/get_shared_link_file":
return .sharing_getSharedLinkFile(
rebuildRequest(
apiRequest: apiRequest,
info: info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class DropboxTransportClientImpl: DropboxTransportClientInternal {
return _serializeOnBackgroundThread
}
}
private static var staticConfigurationLock = NSLock()

private static var staticConfigurationLock = NSLock()
private static var _serializeOnBackgroundThread: Bool = false

public var identifier: String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MockApiRequest: ApiRequest {
func setProgressHandler(_ handler: @escaping (Progress) -> Void) -> Self { self }

func setCompletionHandlerProvider(queue: DispatchQueue?, completionHandlerProvider: RequestCompletionHandlerProvider) -> Self {
self.completionHandler = completionHandlerProvider
completionHandler = completionHandlerProvider
return self
}

Expand Down
Loading

0 comments on commit 67285bf

Please sign in to comment.