Last active
October 28, 2020 08:22
-
-
Save armcha/da47e2bf7cf03bed32ffd82cf6fe4054 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import shared | |
class IOSInterceptor: Interceptor { | |
func intercept(httpRequestBuilder: Ktor_client_coreHttpRequestBuilder) { | |
let headers = httpRequestBuilder.headers | |
headers.set(name: "IOS", value: "HEADER") | |
} | |
} | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
let apiManager = ApiManager(baseUrl: "https://api-dev.fixn.net/client/api/v1") | |
apiManager.addInterceptor(interceptor: DefaultHeaderInterceptor()) | |
apiManager.addInterceptor(interceptor: IOSInterceptor()) | |
let categoryApiService = CategoryApiService(apiManager: apiManager) | |
categoryApiService.getCategories { (categoryreresponses: [CategoryResponse]?,error: Error?) in | |
if let responses = categoryreresponses { | |
let categories = responses.map { (CategoryResponse) -> shared.Category in | |
CategoryResponse.toCategory() | |
} | |
print("CATEGORIES ===== \(categories)") | |
} else { | |
let nsError = error! as NSError | |
let exception = nsError.kotlinException | |
print("EXCEPTION ===== \(String(describing: exception))") | |
} | |
} | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment