Skip to content

Commit

Permalink
[Feat] Team-Sopetit#117 - 버전조회 API 세팅
Browse files Browse the repository at this point in the history
  • Loading branch information
ahra1221 committed Jan 30, 2024
1 parent 6244c15 commit 62ab682
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sopetit-iOS/Sopetit-iOS/Network/Base/URLConstant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum URLConstant {
static let logoutURL = baseURL + "/api/v1/auth/logout"
static let resignURL = baseURL + "/api/v1/auth"
static let reissueURL = baseURL + "/api/v1/auth/token"
static let versionURL = baseURL + "/api/v1/versions/client/app"

// MARK: - OnBoarding URL

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// VersionEntity.swift
// Sopetit-iOS
//
// Created by 고아라 on 1/31/24.
//

import Foundation

struct VersionEntity: Codable {
let iosVersion, androidVersion: Version
let notificationTitle, notificationContent: String
}

// MARK: - Version
struct Version: Codable {
let appVersion, forceUpdateVersion: String
}
23 changes: 23 additions & 0 deletions Sopetit-iOS/Sopetit-iOS/Network/Services/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,27 @@ extension AuthService {
}
}
}

func getVersionAPI(completion: @escaping (NetworkResult<Any>) -> Void) {
let url = URLConstant.versionURL
let header: HTTPHeaders = NetworkConstant.noTokenHeader
let dataRequest = AF.request(url,
method: .get,
encoding: JSONEncoding.default,
headers: header)

dataRequest.responseData { response in
switch response.result {
case .success:
guard let statusCode = response.response?.statusCode else { return }
guard let data = response.data else { return }
let networkResult = self.judgeStatus(by: statusCode,
data,
VersionEntity.self)
completion(networkResult)
case .failure:
completion(.networkFail)
}
}
}
}

0 comments on commit 62ab682

Please sign in to comment.