Commit 6db087374e59cf79e7165374c8f0213c836420c9

Authored by vlad.lopatynets
1 parent fce9cac5

api

... ... @@ -35,7 +35,7 @@
35 35 1738F7DA2850F5F1003F1806 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1738F7D92850F5F1003F1806 /* SettingsView.swift */; };
36 36 175DA474285241C90075F0A9 /* SettingsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 175DA473285241C90075F0A9 /* SettingsModel.swift */; };
37 37 1763F7FC2861FFFD005D988C /* ResidentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1763F7FB2861FFFD005D988C /* ResidentTableViewCell.swift */; };
38   - 1764A05C28670B9F00847A30 /* AuthNetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1764A05B28670B9F00847A30 /* AuthNetworkManager.swift */; };
  38 + 1764A05C28670B9F00847A30 /* AuthService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1764A05B28670B9F00847A30 /* AuthService.swift */; };
39 39 1764A05E28673C7F00847A30 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1764A05D28673C7F00847A30 /* Constants.swift */; };
40 40 1774213D2866EE13002730EE /* AuthModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1774213C2866EE13002730EE /* AuthModel.swift */; };
41 41 17ABE070285B80DC0006E7EC /* DisplayNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17ABE06F285B80DC0006E7EC /* DisplayNameCell.swift */; };
... ... @@ -87,7 +87,7 @@
87 87 1738F7D92850F5F1003F1806 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
88 88 175DA473285241C90075F0A9 /* SettingsModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsModel.swift; sourceTree = "<group>"; };
89 89 1763F7FB2861FFFD005D988C /* ResidentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResidentTableViewCell.swift; sourceTree = "<group>"; };
90   - 1764A05B28670B9F00847A30 /* AuthNetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthNetworkManager.swift; sourceTree = "<group>"; };
  90 + 1764A05B28670B9F00847A30 /* AuthService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthService.swift; sourceTree = "<group>"; };
91 91 1764A05D28673C7F00847A30 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
92 92 1774213C2866EE13002730EE /* AuthModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthModel.swift; sourceTree = "<group>"; };
93 93 17ABE06F285B80DC0006E7EC /* DisplayNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayNameCell.swift; sourceTree = "<group>"; };
... ... @@ -376,7 +376,7 @@
376 376 1764A05A28670B7200847A30 /* NetworkManager */ = {
377 377 isa = PBXGroup;
378 378 children = (
379   - 1764A05B28670B9F00847A30 /* AuthNetworkManager.swift */,
  379 + 1764A05B28670B9F00847A30 /* AuthService.swift */,
380 380 );
381 381 path = NetworkManager;
382 382 sourceTree = "<group>";
... ... @@ -679,7 +679,7 @@
679 679 isa = PBXSourcesBuildPhase;
680 680 buildActionMask = 2147483647;
681 681 files = (
682   - 1764A05C28670B9F00847A30 /* AuthNetworkManager.swift in Sources */,
  682 + 1764A05C28670B9F00847A30 /* AuthService.swift in Sources */,
683 683 17ABE070285B80DC0006E7EC /* DisplayNameCell.swift in Sources */,
684 684 00A48B73285F8EB000EF0A08 /* SquereCheckBox.swift in Sources */,
685 685 1729E22128465DA9006C7C29 /* PhonePickerModel.swift in Sources */,
... ... @@ -865,7 +865,7 @@
865 865 CODE_SIGN_IDENTITY = "Apple Development";
866 866 CODE_SIGN_STYLE = Automatic;
867 867 CURRENT_PROJECT_VERSION = 1;
868   - DEVELOPMENT_TEAM = 4X46JG9W6V;
  868 + DEVELOPMENT_TEAM = 52KCA3JZ59;
869 869 GENERATE_INFOPLIST_FILE = YES;
870 870 INFOPLIST_FILE = "InterQR-Internship/Info.plist";
871 871 INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
... ... @@ -894,7 +894,7 @@
894 894 ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
895 895 CODE_SIGN_STYLE = Automatic;
896 896 CURRENT_PROJECT_VERSION = 1;
897   - DEVELOPMENT_TEAM = 4X46JG9W6V;
  897 + DEVELOPMENT_TEAM = 52KCA3JZ59;
898 898 GENERATE_INFOPLIST_FILE = YES;
899 899 INFOPLIST_FILE = "InterQR-Internship/Info.plist";
900 900 INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
... ...
... ... @@ -30,8 +30,8 @@
30 30 filePath = "InterQR-Internship/Modules/ResidentsScreen/ViewController/ResidentsViewController.swift"
31 31 startingColumnNumber = "9223372036854775807"
32 32 endingColumnNumber = "9223372036854775807"
33   - startingLineNumber = "115"
34   - endingLineNumber = "115"
  33 + startingLineNumber = "116"
  34 + endingLineNumber = "116"
35 35 landmarkName = "didRemoveButtonTapped(cell:)"
36 36 landmarkType = "7">
37 37 </BreakpointContent>
... ...
... ... @@ -13,7 +13,7 @@ class CodeVerificationViewController: UIViewController {
13 13 var isKeyboardAppear = false
14 14
15 15 private let mainView = CodeVerificationView()
16   - private let networkManager = AuthNetworkManager()
  16 + private let networkManager = AuthService()
17 17 override func loadView() {
18 18 view = mainView
19 19 }
... ... @@ -39,7 +39,7 @@ class CodeVerificationViewController: UIViewController {
39 39 func networkingVerify() {
40 40 guard let verifyUrl = URL(string: APIRoutes.verifyURL.urlString) else { return }
41 41 let verifyModel = verifyModelFilling()
42   - AuthNetworkManager.share.verifyRequest(verifyUrl, model: verifyModel!) { response in
  42 + AuthService.share.verifyRequest(verifyUrl, model: verifyModel!) { response in
43 43 print("3️⃣✅\(response.data)")
44 44 print("\(response.message)✅")
45 45 self.networkingLogin()
... ...
... ... @@ -11,7 +11,7 @@ class ResidentsViewController: UIViewController {
11 11 var mainView = ResidentsView()
12 12 var myData: [ResidentModel] = []
13 13
14   - let networkManager = AuthNetworkManager()
  14 + let networkManager = AuthService()
15 15
16 16 override func loadView() {
17 17 view = mainView
... ... @@ -19,7 +19,7 @@ class ResidentsViewController: UIViewController {
19 19
20 20 override func viewDidLoad() {
21 21 initViewController()
22   - networking()
  22 + initDevice()
23 23 }
24 24
25 25 func initViewController() {
... ... @@ -46,11 +46,12 @@ class ResidentsViewController: UIViewController {
46 46 appVersion: appVersion)
47 47 }
48 48
49   - func networking() {
50   - guard let initUrl = URL(string: APIRoutes.initURL.urlString) else { return }
51   - guard let model = modelFilling() else { return }
52   - networkManager.initRequest(initUrl, completion: (InitResponseModel) -> Void, model: model) { responseModel in
53   - print("1️⃣✅\(responseModel.message)✅")
  49 + private func initDevice() {
  50 + guard let model = modelFilling() else {
  51 + return
  52 + }
  53 + AuthService.share.initRequest(model) { result in
  54 + print("1️⃣✅\(result.message)✅")
54 55 } fail: { error in
55 56 print("1️⃣\(error)")
56 57 }
... ...
... ... @@ -9,7 +9,7 @@ import UIKit
9 9
10 10 class SettingsViewController: UIViewController {
11 11 var mainView = SettingsView()
12   - var networkManager = AuthNetworkManager()
  12 + var networkManager = AuthService()
13 13
14 14 let settingsModel = SettingsModel.allCases
15 15
... ...
... ... @@ -8,7 +8,7 @@
8 8 import UIKit
9 9
10 10 class VerificationViewController: UIViewController {
11   - var networkManager = AuthNetworkManager()
  11 + var networkManager = AuthService()
12 12 var isKeyboardAppear = false
13 13 private let mainView = VerificationView()
14 14
... ...
... ... @@ -8,9 +8,9 @@
8 8 import Foundation
9 9 import Alamofire
10 10
11   -class AuthNetworkManager {
  11 +class AuthService {
12 12
13   - static let share = AuthNetworkManager()
  13 + static let share = AuthService()
14 14
15 15 var networkToken: String? {
16 16 get {
... ... @@ -28,10 +28,9 @@ class AuthNetworkManager {
28 28 typealias VerifyWebServiceResponse = (VerifyResponseModel) -> Void
29 29 typealias LoginWebServiceResponse = (LoginResponseModel) -> Void
30 30 typealias LogoutWebServiceResponse = (LogoutResponseModel) -> Void
31   -
32 31 typealias FailedHandler = (Error) -> Void
33 32
34   - func initRequest(_ model: InitRequestModel, completion: @escaping (InitResponseModel) -> Void, fail: @escaping FailedHandler) {
  33 + func initRequest(_ model: InitRequestModel, success: @escaping InitWebServiceResponse, fail: @escaping FailedHandler) {
35 34
36 35 let params = ["device_uuid": model.deviceUUID,
37 36 "manufacturer": model.manufacturer,
... ... @@ -41,13 +40,11 @@ class AuthNetworkManager {
41 40 "app_version": model.appVersion] as [String: Any]
42 41
43 42 AF.request(Constants.baseURL + APIRoutes.initURL.urlString, method: .post, parameters: params, encoding: JSONEncoding.default).responseDecodable(of: InitResponseModel.self ) { response in
44   -
45   - if let error = response.error {
  43 + switch response.result {
  44 + case .failure(let error) :
46 45 fail(error)
47   - } else {
48   - if let res = response.value {
49   - completion(res)
50   - }
  46 + case .success(let res) :
  47 + success(res)
51 48 }
52 49 }
53 50 }
... ...
Please register or login to post a comment