Skip to content

Commit

Permalink
fix/#388 PromiseViewModel 개행 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
youz2me committed Sep 15, 2024
1 parent 616f68f commit 84f007b
Showing 1 changed file with 22 additions and 68 deletions.
90 changes: 22 additions & 68 deletions KkuMulKum/Source/Promise/ViewModel/PromiseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ class PromiseViewModel {

// MARK: Property

/// 서버 통신을 위해 생성자로 주입받을 약속 ID
let promiseID: Int

private let service: PromiseServiceProtocol


// MARK: Initialize

init(
promiseID: Int,
service: PromiseServiceProtocol
) {
init(promiseID: Int, service: PromiseServiceProtocol) {
self.service = service
self.promiseID = promiseID
}
Expand All @@ -37,19 +33,15 @@ extension PromiseViewModel {
func fetchPromiseInfo() {
Task {
do {
let result = try await service.fetchPromiseInfo(
with: promiseID
)
let result = try await service.fetchPromiseInfo(with: promiseID)

guard let success = result?.success,
success == true
else {
return
}
} catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}
Expand All @@ -58,19 +50,15 @@ extension PromiseViewModel {
func fetchPromiseParticipantList() {
Task {
do {
let responseBody = try await service.fetchPromiseParticipantList(
with: promiseID
)
let responseBody = try await service.fetchPromiseParticipantList(with: promiseID)

guard let success = responseBody?.success,
success == true
else {
return
}
} catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}
Expand All @@ -79,19 +67,15 @@ extension PromiseViewModel {
func fetchMyReadyStatus() {
Task {
do {
let responseBody = try await service.fetchMyReadyStatus(
with: promiseID
)
let responseBody = try await service.fetchMyReadyStatus(with: promiseID)

guard let success = responseBody?.success,
success == true
else {
return
}
} catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}
Expand All @@ -100,9 +84,7 @@ extension PromiseViewModel {
func updatePreparationStatus() {
Task {
do {
let responseBody = try await service.updatePreparationStatus(
with: promiseID
)
let responseBody = try await service.updatePreparationStatus(with: promiseID)

guard let success = responseBody?.success,
success == true
Expand All @@ -111,9 +93,7 @@ extension PromiseViewModel {
}
}
catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}
Expand All @@ -122,9 +102,7 @@ extension PromiseViewModel {
func updateDepartureStatus() {
Task {
do {
let responseBody = try await service.updateDepartureStatus(
with: promiseID
)
let responseBody = try await service.updateDepartureStatus(with: promiseID)

guard let success = responseBody?.success,
success == true
Expand All @@ -133,22 +111,16 @@ extension PromiseViewModel {
}
}
catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}

/// 도착 완료 업데이트 API 구현 함수
func updateArrivalStatus(
completion: @escaping () -> Void
) {
func updateArrivalStatus() {
Task {
do {
let responseBody = try await service.updateArrivalStatus(
with: promiseID
)
let responseBody = try await service.updateArrivalStatus(with: promiseID)

guard let success = responseBody?.success,
success == true
Expand All @@ -157,9 +129,7 @@ extension PromiseViewModel {
}
}
catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}
Expand All @@ -168,19 +138,15 @@ extension PromiseViewModel {
func fetchTardyInfo() {
Task {
do {
let responseBody = try await service.fetchTardyInfo(
with: promiseID
)
let responseBody = try await service.fetchTardyInfo(with: promiseID)

guard let success = responseBody?.success,
success == true
else {
return
}
} catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}
Expand All @@ -189,59 +155,47 @@ extension PromiseViewModel {
func updatePromiseCompletion() {
Task {
do {
let responseBody = try await service.updatePromiseCompletion(
with: promiseID
)
let responseBody = try await service.updatePromiseCompletion(with: promiseID)

guard let success = responseBody?.success,
success == true
else {
return
}
} catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}

func deletePromise() {
Task {
do {
let result = try await service.deletePromise(
promiseID: promiseID
)
let result = try await service.deletePromise(promiseID: promiseID)

guard let success = result?.success,
success == true
else {
return
}
} catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}

func exitPromise() {
Task {
do {
let result = try await service.exitPromise(
promiseID: promiseID
)
let result = try await service.exitPromise(promiseID: promiseID)

guard let success = result?.success,
success == true
else {
return
}
} catch {
print(
">>>>> \(error.localizedDescription) : \(#function)"
)
print(">>>>> \(error.localizedDescription) : \(#function)")
}
}
}
Expand Down

0 comments on commit 84f007b

Please sign in to comment.