Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created May 1, 2020 17:51
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 cardoso/19c15f67f091836bc9a63be2fa4a1286 to your computer and use it in GitHub Desktop.
Save cardoso/19c15f67f091836bc9a63be2fa4a1286 to your computer and use it in GitHub Desktop.
import Foundation
struct AuthRequest: Codable {
let appleUid: String
let appleAuthCode: String
let name: String?
func encoded() -> Data {
try! JSONEncoder().encode(self)
}
}
struct AuthResponse: Codable {
let apiKey: String
let streamId: String
let streamToken: String
let email: String
let name: String?
init?(data: Data) {
guard let res = try? JSONDecoder().decode(AuthResponse.self, from: data) else {
return nil
}
self = res
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment