Skip to content

Instantly share code, notes, and snippets.

@bill350
Created March 22, 2019 19:03
Show Gist options
  • Save bill350/35b77885a9b54c2053441f8afcfef7bc to your computer and use it in GitHub Desktop.
Save bill350/35b77885a9b54c2053441f8afcfef7bc to your computer and use it in GitHub Desktop.
// 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