-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat] 닉네임 api 연결
- Loading branch information
Showing
18 changed files
with
537 additions
and
227 deletions.
There are no files selected for viewing
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.developer.applesignin</key> | ||
<array> | ||
<string>Default</string> | ||
</array> | ||
<key>keychain-access-groups</key> | ||
<array> | ||
<string>$(AppIdentifierPrefix)KkuMulKum.yizihn</string> | ||
</array> | ||
</dict> | ||
</plist> |
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,12 @@ | ||
// | ||
// NicknameModel.swift | ||
// KkuMulKum | ||
// | ||
// Created by 이지훈 on 7/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct NameResponseModel: ResponseModelType { | ||
let name: String | ||
} |
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,12 @@ | ||
// | ||
// ProfileModel.swift | ||
// KkuMulKum | ||
// | ||
// Created by 이지훈 on 7/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct ProfileImageResponseModel: ResponseModelType { | ||
// 성공 시 data가 null | ||
} |
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,54 @@ | ||
// | ||
// LoginTatgetType.swift | ||
// KkuMulKum | ||
// | ||
// Created by 이지훈 on 7/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
enum NicknameTargetType { | ||
case updateName(name: String) | ||
} | ||
|
||
extension NicknameTargetType: TargetType { | ||
|
||
var baseURL: URL { | ||
guard let privacyInfo = Bundle.main.privacyInfo, | ||
let urlString = privacyInfo["BASE_URL"] as? String, | ||
let url = URL(string: urlString) else { | ||
fatalError("Invalid BASE_URL in PrivacyInfo.plist") | ||
} | ||
return url | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case .updateName: | ||
return "/api/v1/users/me/name" | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .updateName: | ||
return .patch | ||
} | ||
} | ||
|
||
var task: Task { | ||
switch self { | ||
case .updateName(let name): | ||
return .requestParameters(parameters: ["name": name], encoding: JSONEncoding.default) | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
guard let token = DefaultKeychainService.shared.accessToken else { | ||
fatalError("No access token available") | ||
} | ||
return ["Content-Type": "application/json", "Authorization": "Bearer \(token)"] | ||
} | ||
} |
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,59 @@ | ||
// | ||
// ProfileTargetType.swift | ||
// KkuMulKum | ||
// | ||
// Created by 이지훈 on 7/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
enum ProfileTargetType { | ||
///jpg 고정이 아닌 jpg, png, webp 같이 받기위함 | ||
case updateProfileImage(image: Data, fileName: String, mimeType: String) | ||
} | ||
|
||
extension ProfileTargetType: TargetType { | ||
var baseURL: URL { | ||
guard let privacyInfo = Bundle.main.privacyInfo, | ||
let urlString = privacyInfo["BASE_URL"] as? String, | ||
let url = URL(string: urlString) else { | ||
fatalError("Invalid BASE_URL in PrivacyInfo.plist") | ||
} | ||
return url | ||
} | ||
|
||
var path: String { | ||
return "/api/v1/users/me/image" | ||
} | ||
|
||
var method: Moya.Method { | ||
return .patch | ||
} | ||
|
||
var task: Task { | ||
switch self { | ||
case .updateProfileImage(let imageData, let fileName, let mimeType): | ||
let formData: [MultipartFormData] = [ | ||
MultipartFormData( | ||
provider: .data(imageData), | ||
name: "image", | ||
fileName: fileName, | ||
mimeType: mimeType | ||
) | ||
] | ||
return .uploadMultipart(formData) | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
guard let token = DefaultKeychainService.shared.accessToken else { | ||
return ["Content-Type": "multipart/form-data"] | ||
} | ||
return [ | ||
"Authorization": "Bearer \(token)", | ||
"Content-Type": "multipart/form-data" | ||
] | ||
} | ||
} |
Oops, something went wrong.