Skip to content

Commit

Permalink
[FEAT] DO-NOTTO-DO#84 - 성취뷰 캘린더 API 재연결
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Jan 13, 2023
1 parent 41ff5a1 commit efcc6b6
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 270 deletions.
4 changes: 0 additions & 4 deletions NotToDo/NotToDo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
090D3DDB297139B1000F468C /* CalendarCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090D3DDA297139B1000F468C /* CalendarCustomCell.swift */; };
090FA2E7295F51BB00918AED /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 090FA2E6295F51BB00918AED /* GoogleService-Info.plist */; };
090FA2F52960B70400918AED /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 090FA2F42960B70400918AED /* SnapKit */; };
090FA2F82960B74000918AED /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = 090FA2F72960B74000918AED /* Then */; };
Expand Down Expand Up @@ -148,7 +147,6 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
090D3DDA297139B1000F468C /* CalendarCustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarCustomCell.swift; sourceTree = "<group>"; };
090FA2E6295F51BB00918AED /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
0951EE8C297130DF004A3B5B /* AchieveCalendarResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AchieveCalendarResponseDTO.swift; sourceTree = "<group>"; };
09611EE6296FD52700561CAA /* RecommendService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -350,7 +348,6 @@
09F695DC296C52F000877EA7 /* SituationTableViewCell.swift */,
099F0727296B94790036CF55 /* StatisticsEmptyTableViewCell.swift */,
09F695DA296C52B600877EA7 /* MissionTableViewCell.swift */,
090D3DDA297139B1000F468C /* CalendarCustomCell.swift */,
);
path = Cells;
sourceTree = "<group>";
Expand Down Expand Up @@ -1265,7 +1262,6 @@
3BE0700E296F43B6002CC50A /* Strings.swift in Sources */,
099F06FA2967EE9F0036CF55 /* LabelCollectionViewCell.swift in Sources */,
3BBE56F3296C4EB000771DE4 /* SecondOnboardingViewController.swift in Sources */,
090D3DDB297139B1000F468C /* CalendarCustomCell.swift in Sources */,
096BDFD92964FEF6009ED396 /* CustomCalendarView.swift in Sources */,
099F072A296B98B90036CF55 /* SituationTitleView.swift in Sources */,
3B2748632970B570005DBD46 /* AddAnotherDayResponseDTO.swift in Sources */,
Expand Down
47 changes: 32 additions & 15 deletions NotToDo/NotToDo/Network/API/Achieve/AchieveAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class AchieveAPI {

public private(set) var situationStatisticsData: GeneralArrayResponse<SituationStatistcsResponse>?
public private(set) var missionStatisticsData: GeneralArrayResponse<MissionStatistcsResponse>?
public private(set) var achieveCalendarData: GeneralArrayResponse<AchieveCalendarResponse>?
public private(set) var achieveCalendarData: GeneralResponse<AchieveCalendarResponseDTO>?

// MARK: - GET

Expand Down Expand Up @@ -63,21 +63,38 @@ final class AchieveAPI {

// MARK: - GET

func getAchieveCalendar(month: String, completion: @escaping (GeneralArrayResponse<AchieveCalendarResponse>?) -> Void) {
achieveProvider.request(.achieveCalendar(month: month)) { result in
switch result {
case .success(let response):
do {
self.achieveCalendarData = try response.map(GeneralArrayResponse<AchieveCalendarResponse>?.self)
guard let situationStatisticsData = self.achieveCalendarData else { return }
completion(self.achieveCalendarData)
} catch (let err) {
print(err.localizedDescription, 500)
}
case .failure(let err):
print(err.localizedDescription)
completion(nil)
// func getAchieveCalendar(month: String, completion: @escaping (GeneralResponse<AchieveCalendarResponse>?) -> Void) {
// achieveProvider.request(.achieveCalendar(month: month)) { result in
// switch result {
// case .success(let response):
// do {
// self.achieveCalendarData = try response.map(GeneralResponse<AchieveCalendarResponse>?.self)
// guard let achieveCalendarData = self.achieveCalendarData else { return }
// completion(self.achieveCalendarData)
// } catch (let err) {
// print(err.localizedDescription, 500)
// }
// case .failure(let err):
// print(err.localizedDescription)
// completion(nil)
// }
// }
// }


func getAchieveCalendar(month: String, completion: @escaping (NetworkResult<Any>) -> Void) {
achieveProvider.request(.achieveCalendar(month: month)) { response in
switch response {
case let .success(response):
let statusCode = response.statusCode
let data = response.data
let networkResult = NetworkBase.judgeStatus(by: statusCode, data,
[AchieveCalendarResponseDTO].self)
completion(networkResult)
case let .failure(err):
print(err)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

// MARK: - AchieveCalendarResponse
struct AchieveCalendarResponse: Codable {
struct AchieveCalendarResponseDTO: Codable {
let actionDate: String
let count: Int
}
6 changes: 3 additions & 3 deletions NotToDo/NotToDo/Network/Service/Achieve/AchieveService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ extension AchieveService: TargetType {

var path: String {
switch self {
case .achieveCalendar(month: let month):
return URLConstant.achieveCalendar+"/\(month)"
case .achieveCalendar(let month):
return URLConstant.achieveCalendar + "/\(month)"
case .missionStatistics:
return URLConstant.missionStatistics
case .situationStatistics:
return URLConstant.situationStatistics
}
}

var method: Moya.Method {
switch self {
case .achieveCalendar, .missionStatistics, .situationStatistics:
Expand Down

This file was deleted.

Loading

0 comments on commit efcc6b6

Please sign in to comment.