import Vapor struct OpenApi { func registerRoutes(_ app: Application) { let group = app.grouped("openapi", "service") group.post("v3", "util", "country", "get") { req async -> String in "{\"country\": \"us\"}" } group.post("v4", "device", "accessToken", "create") { req async -> AccessTokenResponse in AccessTokenResponse(accessToken: "fwPla7fQ8ty9+DZT/lD//uWZD4uD6C4lD6gGIIZTLKRTQ52/SLCRmk/370jcWGs+e+1iSoZtL7lj8ov9B0/jHmijH4nsHPQT6pchaQM1M9mtwYNQq0BWhVr9hF0jjCK/a5LIVd1kBac/Gemv29WKEDKSrUS9HxxUigoPRwtOy8m+oDj9FmDJZ+rzqWCc0QjES4Ky0fTpXZ7ESoguDzNmRtW3FYr+OFexw8wBPlwiC4w=", expiryTime: Int(Date.init(timeIntervalSinceNow: .init(0)).timeIntervalSince1970)) } group.post("v3", "agreement", "getForLogin") { req async throws -> String in let body = try req.content.decode(LoginAgreementRequest.self, as: .json) return #""" { "adAgreementStatus": "n", "agreement": { "E001": "n", "E002": "n", "E006": "n", "N002": "n", "N003": "n", "timestamp": "\#(Int(Date().timeIntervalSince1970) * 1000)" }, "agreementPopup": "n", "appId": "\#(body.appId)", "appName": "World Flipper (NA)", "context": "login", "country": "\#(body.country)", "firstAgreement": "n", "idpCode": "\#(body.idpCode)", "idpId": "6076008646", "informationSecurityCountry": "kr", "kakaoSyncAgreementGetSet": "n", "kakaoSyncStatus": "off", "kakaogameSdkVer": "3.0", "lang": "\#(body.lang)", "partnerId": 825, "partnerName": "주식회사 카카오게임즈", "plusFriendStatusInfo": null, "policyApplyTime": 1630854000000 } """# } group.post("v4", "auth", "loginDevice") { req async throws -> Response in let body = try req.content.decode(LoginDeviceRequest.self, as: .json) dump(body) if let rawAccountId = req.headers["playerId"].first { } return Response(status: .notImplemented) } } } struct AccessTokenResponse: Content { let accessToken: String let expiryTime: Int } struct LoginAgreementRequest: Content { let deviceId: String let os: String let country: String let lang: String let appId: String let idpCode: String let serialNo: String let idpId: String } struct LoginDeviceRequest: Content { let lang: String let clientTime: Int let deviceId: String let serialNo: String let country: String let whiteKey: String let market: String let appSecret: String let deviceAppKey: String let sdkVer: String let appVer: String let os: String let loginType: String let accessToken: String let resume: Bool let osVer: String let appId: String let deviceModel: String let network: String let isIosAppOnMac: Bool let adid: String let timezoneOffset: Int let fields: [String] let telecom: String } struct LoginDeviceResponse: Content { let zatExpiryTime: Int let zrtExpiryTime: Int let firstLogin: Bool let externalToken: String let zat: String let zrt: String let player: Player } struct Player: Content { let idpId: String let appId: String let lang: String let playerId: String let agreement: AgreementResponse let pushOption: PushOptionResponse let lastLoginTime: Int let regTime: Int let idpAlias: String let firstLoginTime: Int let status: String } struct AgreementResponse: Content { let E001: String let E002: String let E006: String let N002: String let N003: String let timestamp: String } struct PushOptionResponse: Content { let night: String let player: String }