Skip to content

Instantly share code, notes, and snippets.

@armcha
Last active October 28, 2020 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save armcha/da47e2bf7cf03bed32ffd82cf6fe4054 to your computer and use it in GitHub Desktop.
Save armcha/da47e2bf7cf03bed32ffd82cf6fe4054 to your computer and use it in GitHub Desktop.
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