Created
March 22, 2019 19:03
-
-
Save bill350/35b77885a9b54c2053441f8afcfef7bc 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
// MARK: Lokalise downloading and copying | |
// Lokalise Constants | |
let LokalisePOSTUrl = "https://api.lokalise.co/api2/projects/\(lokaliseProjectId)/files/download" | |
let LokalizableZipName = "Mobile-Localizable" | |
struct LokaliseRequestBody: Codable { | |
let format = "ios_sdk" | |
let original_filenames = true | |
} | |
struct LokaliseFileDownloadResponse: Codable { | |
let project_id: String | |
let bundle_url: String | |
} | |
let configuration = URLSessionConfiguration.default | |
configuration.requestCachePolicy = .reloadIgnoringLocalCacheData | |
let urlSession = URLSession(configuration: configuration) | |
var lokaliseRequest = URLRequest(url: URL(string: LokalisePOSTUrl)!) | |
lokaliseRequest.httpMethod = "POST" | |
lokaliseRequest.httpBody = try { | |
let jsonEncoder = JSONEncoder() | |
return try jsonEncoder.encode(LokaliseRequestBody()) | |
}() | |
lokaliseRequest.allHTTPHeaderFields = { | |
let headers = ["x-api-token" : lokaliseApiToken, | |
"Content-Type": "application/json"] | |
return headers | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment