File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -35,4 +35,25 @@ final class HomeAPI {
35
35
}
36
36
}
37
37
}
38
+
39
+ func visitPatchAPI( completion: @escaping ( Result < GeneralResponse < NilType > , SmeemError > ) -> ( ) ) {
40
+ homeProvider. request ( . visit) { result in
41
+ switch result {
42
+ case . success( let response) :
43
+ let statusCode = response. statusCode
44
+ do {
45
+ try NetworkManager . statusCodeErrorHandling ( statusCode: response. statusCode)
46
+ guard let data = try ? response. map ( GeneralResponse< NilType> . self ) else {
47
+ throw SmeemError . clientError
48
+ }
49
+ completion ( . success( data) )
50
+ } catch {
51
+ guard let error = error as? SmeemError else { return }
52
+ completion ( . failure( error) )
53
+ }
54
+ case . failure( _) :
55
+ completion ( . failure( . userError) )
56
+ }
57
+ }
58
+ }
38
59
}
Original file line number Diff line number Diff line change @@ -11,20 +11,25 @@ import Moya
11
11
12
12
enum HomeService {
13
13
case HomeDiary( startDate: String , endDate: String )
14
+ case visit
14
15
}
15
16
16
17
extension HomeService : BaseTargetType {
17
18
var path : String {
18
19
switch self {
19
20
case . HomeDiary:
20
21
return URLConstant . diaryURL
22
+ case . visit:
23
+ return URLConstant . visitURL
21
24
}
22
25
}
23
26
24
27
var method : Moya . Method {
25
28
switch self {
26
29
case . HomeDiary:
27
30
return . get
31
+ case . visit:
32
+ return . patch
28
33
}
29
34
}
30
35
@@ -34,6 +39,8 @@ extension HomeService: BaseTargetType {
34
39
return . requestParameters( parameters: [ " start " : startDate,
35
40
" end " : endDate] ,
36
41
encoding: URLEncoding . queryString)
42
+ case . visit:
43
+ return . requestPlain
37
44
}
38
45
}
39
46
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ enum URLConstant {
42
42
43
43
static let diaryURL = " /diaries "
44
44
45
+ // MARK: - Home
46
+
47
+ static let visitURL = " /members/visit "
48
+
45
49
// MARK: - Correction
46
50
47
51
static let correctionPostURL = " /corrections/diary "
Original file line number Diff line number Diff line change @@ -197,6 +197,7 @@ final class HomeViewController: BaseViewController {
197
197
override func viewWillAppear( _ animated: Bool ) {
198
198
homeDiaryWithAPI ( start: Date ( ) . startOfMonth ( ) . addingDate ( addValue: - 7 ) , end: Date ( ) . endOfMonth ( ) . addingDate ( addValue: 7 ) )
199
199
checkPopupView ( )
200
+ visitPatchAPI ( )
200
201
}
201
202
202
203
// MARK: - @objc
@@ -548,4 +549,19 @@ extension HomeViewController {
548
549
SmeemLoadingView . hideLoading ( )
549
550
}
550
551
}
552
+
553
+ func visitPatchAPI( ) {
554
+ SmeemLoadingView . showLoading ( )
555
+
556
+ HomeAPI . shared. visitPatchAPI { result in
557
+
558
+ switch result {
559
+ case . success( _) :
560
+ SmeemLoadingView . hideLoading ( )
561
+ case . failure( let error) :
562
+ self . showToast ( toastType: . smeemErrorToast( message: error) )
563
+ SmeemLoadingView . hideLoading ( )
564
+ }
565
+ }
566
+ }
551
567
}
You can’t perform that action at this time.
0 commit comments