-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddee33c
commit 3691613
Showing
25 changed files
with
2,880 additions
and
858 deletions.
There are no files selected for viewing
732 changes: 693 additions & 39 deletions
732
OpenApiGenerator/Sources/OpenapiGenerated/Client.swift
Large diffs are not rendered by default.
Oops, something went wrong.
2,543 changes: 1,880 additions & 663 deletions
2,543
OpenApiGenerator/Sources/OpenapiGenerated/Types.swift
Large diffs are not rendered by default.
Oops, something went wrong.
Submodule 3days-oas
updated
3 files
+1 −0 | .github/codeowners | |
+29 −0 | .github/workflows/validation.yaml | |
+545 −129 | openapi.yaml |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// SMSSendResponse.swift | ||
// CoreKit | ||
// | ||
// Created by 김지수 on 10/9/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum UserType: String { | ||
case NEW = "NEW" | ||
case EXISTING = "EXISTING" | ||
} | ||
|
||
public struct SMSSendResponse { | ||
public let userType: UserType | ||
public let authCodeId: String | ||
public let phoneNumber: String | ||
|
||
public init( | ||
userType: UserType, | ||
authCodeId: String, | ||
phoneNumber: String | ||
) { | ||
self.userType = userType | ||
self.authCodeId = authCodeId | ||
self.phoneNumber = phoneNumber | ||
} | ||
} |
This file contains 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
76 changes: 0 additions & 76 deletions
76
Projects/Core/NetworkKit/Sources/AuthService/AuthEndpoint.swift
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
Projects/Core/NetworkKit/Sources/AuthService/AuthService.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// AuthService.swift | ||
// NetworkKit | ||
// | ||
// Created by 김지수 on 8/25/24. | ||
// Copyright © 2024 com.studentcenter. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Model | ||
import CoreKit | ||
|
||
enum AuthEndpointError: Error { | ||
case emptyToken | ||
case tokenResponseNotValid | ||
} | ||
|
||
public enum AuthService: Endpointable { | ||
public static func requestSendSMS(phone: String) async throws -> SMSSendResponse { | ||
let response = try await client.requestVerification( | ||
headers: .init(X_hyphen_OS_hyphen_Type: .IOS), | ||
body: .json(.init(phoneNumber: phone)) | ||
).created.body.json | ||
|
||
return SMSSendResponse( | ||
userType: UserType( | ||
rawValue: response.userStatus?.rawValue ?? "NEW" | ||
) ?? .NEW, | ||
authCodeId: response.authCodeId, | ||
phoneNumber: phone | ||
) | ||
} | ||
|
||
public static func requestNewUserVerifyCode( | ||
_ request: SMSVerificationRequest | ||
) async throws -> String { | ||
let response = try await client.newUserVerifyCode( | ||
path: .init(authCodeId: request.verificationId), | ||
body: .json(.init(verificationCode: request.verificationCode)) | ||
).ok.body.json | ||
return response.registerToken | ||
} | ||
|
||
public static func requestExistingUserVerifyCode( | ||
_ request: SMSVerificationRequest | ||
) async throws -> ExistingUserVerificationResponse { | ||
let response = try await client.existingUserVerifyCode( | ||
path: .init(authCodeId: request.verificationId), | ||
body: .json(.init(verificationCode: request.verificationCode)) | ||
).ok.body.json | ||
|
||
return ExistingUserVerificationResponse( | ||
refreshToken: response.refreshToken, | ||
accessToken: response.accessToken | ||
) | ||
} | ||
} | ||
|
||
//MARK: - AccessToken Refresh | ||
extension AuthService { | ||
static func refreshAccessToken() async throws -> RefreshTokenResponse { | ||
guard let refreshToken = TokenManager.refreshToken else { | ||
throw AuthEndpointError.emptyToken | ||
} | ||
|
||
let response = try await client.refreshToken( | ||
body: .json(.init(refreshToken: refreshToken)) | ||
) | ||
|
||
let result = try response.ok.body.json | ||
|
||
TokenManager.accessToken = result.accessToken | ||
TokenManager.refreshToken = result.refreshToken | ||
|
||
return RefreshTokenResponse( | ||
refreshToken: result.refreshToken, | ||
accessToken: result.accessToken | ||
) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.