Created
March 4, 2026 11:59
-
-
Save jacobsapps/3b2804b382d6f0682c79af3616be5cfb 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
| private func makeIdempotencyKey(enabled: Bool) -> String? { | |
| guard enabled else { return nil } | |
| let key = UUID().uuidString | |
| return key | |
| } | |
| private func makePostRequest(text: String, idempotencyKey: String?) throws -> URLRequest { | |
| var request = makeRequest(path: "level2/tweets", method: "POST") | |
| request.setValue("application/json", forHTTPHeaderField: "Content-Type") | |
| if let idempotencyKey { | |
| request.setValue(idempotencyKey, forHTTPHeaderField: "Idempotency-Key") | |
| } | |
| request.httpBody = try encoder.encode(Level2PostBody(text: text)) | |
| return request | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment