Skip to content

Commit

Permalink
update DropboxTransportClient to have downloadContentHost
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesyangf authored and James Yang committed May 16, 2024
1 parent ac36a3f commit 98f1d83
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public class DropboxTransportClientImpl: DropboxTransportClientInternal {
for route: Route<ASerial, RSerial, ESerial>,
baseHosts: BaseHosts = .default
) -> URL {
let urlString = "\(baseHosts.url(for: route.attributes.host))/\(route.namespace)/\(route.name)"
let urlString = "\(baseHosts.url(for: route.attributes))/\(route.namespace)/\(route.name)"
return URL(string: urlString)!
}

Expand All @@ -529,6 +529,8 @@ public class BaseHosts: NSObject {
@objc
let contentHost: String
@objc
var downloadContentHost: String
@objc
let notifyHost: String

@objc
Expand All @@ -539,9 +541,20 @@ public class BaseHosts: NSObject {
) {
self.apiHost = apiHost
self.contentHost = contentHost
self.downloadContentHost = contentHost
self.notifyHost = notifyHost
}

@objc public convenience init(
apiHost: String,
contentHost: String,
downloadContentHost: String,
notifyHost: String
) {
self.init(apiHost: apiHost, contentHost: contentHost, notifyHost: notifyHost)
self.downloadContentHost = downloadContentHost
}

public static var `default`: Self {
.init(
apiHost: ApiClientConstants.apiHost,
Expand All @@ -552,12 +565,15 @@ public class BaseHosts: NSObject {
}

extension BaseHosts {
func url(for host: RouteHost) -> String {
func url(for attr: RouteAttributes) -> String {
{
switch host {
switch attr.host {
case .api:
return apiHost
case .content:
if attr.style == .download {
return downloadContentHost
}
return contentHost
case .notify:
return notifyHost
Expand Down

0 comments on commit 98f1d83

Please sign in to comment.