-
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.
Showing
27 changed files
with
548 additions
and
796 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
59 changes: 0 additions & 59 deletions
59
iOS-NOTTODO/iOS-NOTTODO/Network/API/Achieve/AchieveAPI.swift
This file was deleted.
Oops, something went wrong.
124 changes: 0 additions & 124 deletions
124
iOS-NOTTODO/iOS-NOTTODO/Network/API/AddMission/AddMissionAPI.swift
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,69 @@ | ||
// | ||
// BaseAPI.swift | ||
// iOS-NOTTODO | ||
// | ||
// Created by JEONGEUN KIM on 3/10/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
enum BaseDomain { | ||
case auth | ||
case mission | ||
case recommend | ||
} | ||
|
||
extension BaseDomain { | ||
|
||
var url: String { | ||
switch self { | ||
case .auth: | ||
return "/auth" | ||
case .mission: | ||
return "/mission" | ||
case .recommend: | ||
return "/recommend" | ||
} | ||
} | ||
} | ||
|
||
protocol BaseService: TargetType { | ||
var domain: BaseDomain { get } | ||
var urlPath: String { get } | ||
var headerType: HeaderType { get } | ||
} | ||
|
||
extension BaseService { | ||
var baseURL: URL { | ||
return URL(string: Bundle.main.baseURL)! | ||
} | ||
|
||
var path: String { | ||
return domain.url + urlPath | ||
} | ||
|
||
var validationType: ValidationType { | ||
return .successCodes | ||
} | ||
|
||
var headers: [String: String]? { | ||
return headerType.value | ||
} | ||
} | ||
|
||
public enum HeaderType { | ||
case json | ||
case jsonWithToken | ||
|
||
public var value: [String: String] { | ||
switch self { | ||
case .json: | ||
return ["Content-Type": "application/json"] | ||
case .jsonWithToken: | ||
return ["Content-Type": "application/json", | ||
"Authorization": "\(KeychainUtil.getAccessToken())"] | ||
} | ||
} | ||
} |
Oops, something went wrong.