remove network and object mapper stuff

This commit is contained in:
Madhas 2018-05-25 17:59:41 +03:00
parent 6f7c4f27e1
commit 29ce2bc74b
10 changed files with 0 additions and 477 deletions

View File

@ -28,8 +28,6 @@
A6CFB8D91F5024A500A42CC2 /* Error+NetworkingExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6CFB8D81F5024A500A42CC2 /* Error+NetworkingExtensions.swift */; };
B326804BA6CC8B8BB136A46A /* Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CFD5627139CAB27705F75C07 /* Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework */; };
CAE698E81E968820000394B0 /* LeadKitAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE698E61E968820000394B0 /* LeadKitAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
ED0C34031F2906EC00FAE9FD /* ApiResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33D31F2906EC00FAE9FD /* ApiResponse.swift */; };
ED0C34041F2906EC00FAE9FD /* ApiResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33D31F2906EC00FAE9FD /* ApiResponse.swift */; };
ED0C34051F2906EC00FAE9FD /* BaseDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33D41F2906EC00FAE9FD /* BaseDateFormatter.swift */; };
ED0C34061F2906EC00FAE9FD /* BaseDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33D41F2906EC00FAE9FD /* BaseDateFormatter.swift */; };
ED0C34071F2906EC00FAE9FD /* LoadingBarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33D51F2906EC00FAE9FD /* LoadingBarButton.swift */; };
@ -48,12 +46,6 @@
ED0C34141F2906EC00FAE9FD /* BasePassCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33DF1F2906EC00FAE9FD /* BasePassCodeViewController.swift */; };
ED0C34151F2906EC00FAE9FD /* BasePassCodeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E11F2906EC00FAE9FD /* BasePassCodeViewModel.swift */; };
ED0C34161F2906EC00FAE9FD /* BasePassCodeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E11F2906EC00FAE9FD /* BasePassCodeViewModel.swift */; };
ED0C34171F2906EC00FAE9FD /* ApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E31F2906EC00FAE9FD /* ApiError.swift */; };
ED0C34181F2906EC00FAE9FD /* ApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E31F2906EC00FAE9FD /* ApiError.swift */; };
ED0C34191F2906EC00FAE9FD /* ApiErrorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E41F2906EC00FAE9FD /* ApiErrorProtocol.swift */; };
ED0C341A1F2906EC00FAE9FD /* ApiErrorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E41F2906EC00FAE9FD /* ApiErrorProtocol.swift */; };
ED0C341D1F2906EC00FAE9FD /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E71F2906EC00FAE9FD /* Observable+Extensions.swift */; };
ED0C341E1F2906EC00FAE9FD /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E71F2906EC00FAE9FD /* Observable+Extensions.swift */; };
ED0C341F1F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E81F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift */; };
ED0C34201F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E81F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift */; };
ED0C34211F2906EC00FAE9FD /* UserDefaults+UserService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33E91F2906EC00FAE9FD /* UserDefaults+UserService.swift */; };
@ -62,12 +54,6 @@
ED0C342E1F2906EC00FAE9FD /* BasePassCodeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F11F2906EC00FAE9FD /* BasePassCodeService.swift */; };
ED0C342F1F2906EC00FAE9FD /* BaseUserService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */; };
ED0C34301F2906EC00FAE9FD /* BaseUserService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */; };
ED0C34351F2906EC00FAE9FD /* ApiNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F61F2906EC00FAE9FD /* ApiNetworkService.swift */; };
ED0C34361F2906EC00FAE9FD /* ApiNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F61F2906EC00FAE9FD /* ApiNetworkService.swift */; };
ED0C34381F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F71F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift */; };
ED0C34391F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F81F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator.swift */; };
ED0C343B1F2906EC00FAE9FD /* DefaultNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F91F2906EC00FAE9FD /* DefaultNetworkService.swift */; };
ED0C343C1F2906EC00FAE9FD /* DefaultNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33F91F2906EC00FAE9FD /* DefaultNetworkService.swift */; };
ED0C343F1F2906EC00FAE9FD /* ValidationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33FC1F2906EC00FAE9FD /* ValidationError.swift */; };
ED0C34401F2906EC00FAE9FD /* ValidationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33FC1F2906EC00FAE9FD /* ValidationError.swift */; };
ED0C34411F2906EC00FAE9FD /* ValidationItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0C33FD1F2906EC00FAE9FD /* ValidationItem.swift */; };
@ -103,7 +89,6 @@
CAE698E61E968820000394B0 /* LeadKitAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LeadKitAdditions.h; sourceTree = "<group>"; };
CFD5627139CAB27705F75C07 /* Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKitAdditions_LeadKitAdditions_iOS_Extensions.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D0AB283D10B2175EFDBF7924 /* Pods-LeadKitAdditions-LeadKitAdditions iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKitAdditions-LeadKitAdditions iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKitAdditions-LeadKitAdditions iOS/Pods-LeadKitAdditions-LeadKitAdditions iOS.release.xcconfig"; sourceTree = "<group>"; };
ED0C33D31F2906EC00FAE9FD /* ApiResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiResponse.swift; sourceTree = "<group>"; };
ED0C33D41F2906EC00FAE9FD /* BaseDateFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseDateFormatter.swift; sourceTree = "<group>"; };
ED0C33D51F2906EC00FAE9FD /* LoadingBarButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingBarButton.swift; sourceTree = "<group>"; };
ED0C33D91F2906EC00FAE9FD /* PassCodeConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PassCodeConfiguration.swift; sourceTree = "<group>"; };
@ -113,17 +98,10 @@
ED0C33DD1F2906EC00FAE9FD /* PassCodeValidationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PassCodeValidationResult.swift; sourceTree = "<group>"; };
ED0C33DF1F2906EC00FAE9FD /* BasePassCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasePassCodeViewController.swift; sourceTree = "<group>"; };
ED0C33E11F2906EC00FAE9FD /* BasePassCodeViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasePassCodeViewModel.swift; sourceTree = "<group>"; };
ED0C33E31F2906EC00FAE9FD /* ApiError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiError.swift; sourceTree = "<group>"; };
ED0C33E41F2906EC00FAE9FD /* ApiErrorProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiErrorProtocol.swift; sourceTree = "<group>"; };
ED0C33E71F2906EC00FAE9FD /* Observable+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+Extensions.swift"; sourceTree = "<group>"; };
ED0C33E81F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Extensions.swift"; sourceTree = "<group>"; };
ED0C33E91F2906EC00FAE9FD /* UserDefaults+UserService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UserDefaults+UserService.swift"; sourceTree = "<group>"; };
ED0C33F11F2906EC00FAE9FD /* BasePassCodeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasePassCodeService.swift; sourceTree = "<group>"; };
ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseUserService.swift; sourceTree = "<group>"; };
ED0C33F61F2906EC00FAE9FD /* ApiNetworkService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiNetworkService.swift; sourceTree = "<group>"; };
ED0C33F71F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DefaultNetworkService+ActivityIndicator+Extension.swift"; sourceTree = "<group>"; };
ED0C33F81F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DefaultNetworkService+ActivityIndicator.swift"; sourceTree = "<group>"; };
ED0C33F91F2906EC00FAE9FD /* DefaultNetworkService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultNetworkService.swift; sourceTree = "<group>"; };
ED0C33FC1F2906EC00FAE9FD /* ValidationError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidationError.swift; sourceTree = "<group>"; };
ED0C33FD1F2906EC00FAE9FD /* ValidationItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidationItem.swift; sourceTree = "<group>"; };
ED0C33FE1F2906EC00FAE9FD /* ValidationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidationService.swift; sourceTree = "<group>"; };
@ -240,7 +218,6 @@
children = (
ED0C33D21F2906EC00FAE9FD /* Classes */,
ED0C33D61F2906EC00FAE9FD /* Controllers */,
ED0C33E21F2906EC00FAE9FD /* Enums */,
ED0C33E61F2906EC00FAE9FD /* Extensions */,
ED0C33EA1F2906EC00FAE9FD /* Protocols */,
ED0C33F01F2906EC00FAE9FD /* Services */,
@ -256,7 +233,6 @@
children = (
67528BCB206E3C12009F2525 /* Cells */,
67B4E6F0206945D200E233EA /* BaseTextFieldViewModel */,
ED0C33D31F2906EC00FAE9FD /* ApiResponse.swift */,
ED0C33D41F2906EC00FAE9FD /* BaseDateFormatter.swift */,
ED0C33D51F2906EC00FAE9FD /* LoadingBarButton.swift */,
);
@ -310,20 +286,10 @@
path = ViewModel;
sourceTree = "<group>";
};
ED0C33E21F2906EC00FAE9FD /* Enums */ = {
isa = PBXGroup;
children = (
ED0C33E31F2906EC00FAE9FD /* ApiError.swift */,
ED0C33E41F2906EC00FAE9FD /* ApiErrorProtocol.swift */,
);
path = Enums;
sourceTree = "<group>";
};
ED0C33E61F2906EC00FAE9FD /* Extensions */ = {
isa = PBXGroup;
children = (
67CF05AC206E9931009A2AB9 /* Cells */,
ED0C33E71F2906EC00FAE9FD /* Observable+Extensions.swift */,
ED0C33E81F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift */,
ED0C33E91F2906EC00FAE9FD /* UserDefaults+UserService.swift */,
A6CFB8D81F5024A500A42CC2 /* Error+NetworkingExtensions.swift */,
@ -344,7 +310,6 @@
ED0C33F01F2906EC00FAE9FD /* Services */ = {
isa = PBXGroup;
children = (
ED0C33F51F2906EC00FAE9FD /* Network */,
ED0C33FB1F2906EC00FAE9FD /* ValidationService */,
ED0C33F11F2906EC00FAE9FD /* BasePassCodeService.swift */,
ED0C33F21F2906EC00FAE9FD /* BaseUserService.swift */,
@ -353,17 +318,6 @@
path = Services;
sourceTree = "<group>";
};
ED0C33F51F2906EC00FAE9FD /* Network */ = {
isa = PBXGroup;
children = (
ED0C33F61F2906EC00FAE9FD /* ApiNetworkService.swift */,
ED0C33F71F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift */,
ED0C33F81F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator.swift */,
ED0C33F91F2906EC00FAE9FD /* DefaultNetworkService.swift */,
);
path = Network;
sourceTree = "<group>";
};
ED0C33FB1F2906EC00FAE9FD /* ValidationService */ = {
isa = PBXGroup;
children = (
@ -607,10 +561,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ED0C34171F2906EC00FAE9FD /* ApiError.swift in Sources */,
67B4E6FB20694A4200E233EA /* BaseTextFieldViewModel.swift in Sources */,
ED0C343B1F2906EC00FAE9FD /* DefaultNetworkService.swift in Sources */,
ED0C34351F2906EC00FAE9FD /* ApiNetworkService.swift in Sources */,
ED0C340F1F2906EC00FAE9FD /* PassCodeHolderProtocol.swift in Sources */,
ED0C343F1F2906EC00FAE9FD /* ValidationError.swift in Sources */,
ED0C342F1F2906EC00FAE9FD /* BaseUserService.swift in Sources */,
@ -621,9 +572,7 @@
67C2A41820724EA0000A5682 /* LabelTableViewCell.swift in Sources */,
ED0C34091F2906EC00FAE9FD /* PassCodeConfiguration.swift in Sources */,
EF5A43B1206E7A67003CED07 /* PassCodeDelayedDescription.swift in Sources */,
ED0C341D1F2906EC00FAE9FD /* Observable+Extensions.swift in Sources */,
67CF05B0206E99DF009A2AB9 /* PinLayoutTableViewCell.swift in Sources */,
ED0C34191F2906EC00FAE9FD /* ApiErrorProtocol.swift in Sources */,
ED0C34131F2906EC00FAE9FD /* BasePassCodeViewController.swift in Sources */,
67C2A41620724BBA000A5682 /* SeparatorTableViewCell.swift in Sources */,
ED0C342D1F2906EC00FAE9FD /* BasePassCodeService.swift in Sources */,
@ -631,12 +580,10 @@
67779CBC206986390098F024 /* BaseTextFieldViewEvents+Extensions.swift in Sources */,
ED0C340D1F2906EC00FAE9FD /* PassCodeHolder.swift in Sources */,
67CF05AA206E9880009A2AB9 /* PinLayoutCell.swift in Sources */,
ED0C34031F2906EC00FAE9FD /* ApiResponse.swift in Sources */,
A6CFB8D91F5024A500A42CC2 /* Error+NetworkingExtensions.swift in Sources */,
ED0C34071F2906EC00FAE9FD /* LoadingBarButton.swift in Sources */,
6760AF1A207268EC00C2BB7E /* PinLayoutCell+DefaultImplementation.swift in Sources */,
ED0C34211F2906EC00FAE9FD /* UserDefaults+UserService.swift in Sources */,
ED0C34391F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator.swift in Sources */,
ED0C34111F2906EC00FAE9FD /* PassCodeValidationResult.swift in Sources */,
ED0C34051F2906EC00FAE9FD /* BaseDateFormatter.swift in Sources */,
ED0C34431F2906EC00FAE9FD /* ValidationService.swift in Sources */,
@ -651,10 +598,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ED0C34181F2906EC00FAE9FD /* ApiError.swift in Sources */,
ED0C343C1F2906EC00FAE9FD /* DefaultNetworkService.swift in Sources */,
67779CBD206986390098F024 /* BaseTextFieldViewEvents+Extensions.swift in Sources */,
ED0C34361F2906EC00FAE9FD /* ApiNetworkService.swift in Sources */,
ED0C34101F2906EC00FAE9FD /* PassCodeHolderProtocol.swift in Sources */,
ED0C34401F2906EC00FAE9FD /* ValidationError.swift in Sources */,
ED0C34301F2906EC00FAE9FD /* BaseUserService.swift in Sources */,
@ -662,16 +606,12 @@
ED0C34201F2906EC00FAE9FD /* UIBarButtonItem+Extensions.swift in Sources */,
ED0C340A1F2906EC00FAE9FD /* PassCodeConfiguration.swift in Sources */,
67B4E6FA206945F900E233EA /* OnlineValidationState.swift in Sources */,
ED0C34381F2906EC00FAE9FD /* DefaultNetworkService+ActivityIndicator+Extension.swift in Sources */,
ED0C341E1F2906EC00FAE9FD /* Observable+Extensions.swift in Sources */,
67B4E6EB206941CE00E233EA /* BiometricsService.swift in Sources */,
ED0C341A1F2906EC00FAE9FD /* ApiErrorProtocol.swift in Sources */,
ED0C34141F2906EC00FAE9FD /* BasePassCodeViewController.swift in Sources */,
ED0C342E1F2906EC00FAE9FD /* BasePassCodeService.swift in Sources */,
67B4E6F7206945DD00E233EA /* OnlineValidationResult.swift in Sources */,
ED0C340E1F2906EC00FAE9FD /* PassCodeHolder.swift in Sources */,
67B4E6F3206945D200E233EA /* BaseTextFieldViewModel.swift in Sources */,
ED0C34041F2906EC00FAE9FD /* ApiResponse.swift in Sources */,
ED0C34081F2906EC00FAE9FD /* LoadingBarButton.swift in Sources */,
ED0C34221F2906EC00FAE9FD /* UserDefaults+UserService.swift in Sources */,
ED0C34121F2906EC00FAE9FD /* PassCodeValidationResult.swift in Sources */,

View File

@ -1,51 +0,0 @@
//
// Copyright (c) 2018 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import ObjectMapper
/// Class describes typical response from server, which designed by TouchInstinct
public class ApiResponse: ApiResponseProtocol, ImmutableMappable {
/// nil in case of error, result of request otherwise
public let result: Any?
/// In case of error contains error code, 0 (zero) otherwise
public let errorCode: Int
/// nil in case of success, error description otherwise
public let errorMessage: String?
public required init(map: Map) throws {
result = try? map.value("result")
errorCode = try map.value("errorCode")
errorMessage = try? map.value("errorMessage")
}
}
/// Describes error, which received from server designed by TouchInstinct
public protocol ApiResponseProtocol: ImmutableMappable {
/// Error code
var errorCode: Int { get }
/// Error description
var errorMessage: String? { get }
}

View File

@ -21,7 +21,6 @@
//
import Foundation
import ObjectMapper
/// Base date formatter class, contains most frequently used formats, including RFC3339
open class BaseDateFormatter {
@ -105,23 +104,4 @@ open class BaseDateFormatter {
return dayMonthYearFormatter.string(from: date)
}
// MARK: - Transformers
/// Transformer to workaround with dates in Mappable (ObjectMapper) objects
public static var transformFromStringToDate: TransformOf<Date, String> {
return TransformOf<Date, String>(fromJSON: { stringValue -> Date? in
if let stringValue = stringValue {
return backendDate(fromStrDate: stringValue)
} else {
return nil
}
}, toJSON: { dateValue -> String? in
if let dateValue = dateValue {
return backendStrDate(withDate: dateValue)
} else {
return nil
}
})
}
}

View File

@ -1,51 +0,0 @@
//
// Copyright (c) 2018 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
/// Describes possible error, received from back-end
public enum ApiError: Error {
case error(code: Int, message: String)
case none
}
// MARK: - LocalizedError
extension ApiError: LocalizedError {
public init(apiResponse: ApiResponseProtocol) {
if apiResponse.errorCode != 0, let message = apiResponse.errorMessage {
self = ApiError.error(code: apiResponse.errorCode, message: message)
} else {
self = ApiError.none
}
}
public var errorDescription: String? {
switch self {
case .error(_, let message):
return message
case .none:
return nil
}
}
}

View File

@ -1,39 +0,0 @@
//
// Copyright (c) 2018 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
/// Describes error by raw value (more likely - Int code), received from back-end
public protocol ApiErrorProtocol: RawRepresentable {}
public extension Error {
/// Method indicates that error is back-end error
func isApiError<T: ApiErrorProtocol>(_ apiErrorType: T) -> Bool where T.RawValue == Int {
if let error = self as? ApiError,
case let .error(code: code, message: _) = error,
code == apiErrorType.rawValue {
return true
} else {
return false
}
}
}

View File

@ -1,87 +0,0 @@
//
// Copyright (c) 2018 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import RxSwift
import Alamofire
import LeadKit
public typealias VoidBlock = () -> Void
public extension Observable {
/// A closure that checks for "retryable" error
typealias CanRetryClosure = (Error) -> Bool
/// Allow to configure request to restart if error occured
///
/// - Parameters:
/// - retryLimit: how many times request can restarts
/// - canRetryClosure: a closure that checks for "retryable" error
/// - Returns: An observable sequence producing the elements of the given sequence repeatedly
/// until it terminates successfully or is notified to error or complete.
func retry(retryLimit: UInt = DefaultNetworkService.retryLimit,
canRetryClosure: @escaping CanRetryClosure) -> Observable<Observable.E> {
return observeOn(CurrentThreadScheduler.instance)
.retryWhen { errorsObservable -> Observable<Observable.E> in
errorsObservable.enumerated().flatMap {
(canRetryClosure($1) && $0 < retryLimit - 1) ? self : .error($1)
}
}
}
/**
Add block that executes, when error, described by ApiErrorProtocol, occured during request
- parameters:
- apiErrorType: type of errors, received frim server
- handler: block, that executes, when error occured
*/
func handleApiError<T: ApiErrorProtocol>(_ apiErrorType: T,
handler: @escaping () -> Void) -> Observable<Observable.E>
where T.RawValue == Int {
return observeOn(CurrentThreadScheduler.instance)
.do(onError: { error in
if error.isApiError(apiErrorType) {
handler()
}
})
}
/**
Add ability to monitor request status
- parameter isLoading: subject, request state bind to
*/
func changeLoadingBehaviour(isLoading: PublishSubject<Bool>) -> Observable<Observable.E> {
return observeOn(CurrentThreadScheduler.instance)
.do(onNext: { _ in
isLoading.onNext(false)
}, onError: { _ in
isLoading.onNext(false)
}, onSubscribe: {
isLoading.onNext(true)
})
}
}

View File

@ -1,60 +0,0 @@
//
// Copyright (c) 2018 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import LeadKit
import Alamofire
import ObjectMapper
import RxSwift
/// Base network service implementation for back-end designed by TouchInstinct
open class ApiNetworkService: DefaultNetworkService {
/// Returns observable for ImmutableMappable response model by parameters
open func request<T: ImmutableMappable>(with parameters: ApiRequestParameters) -> Observable<T> {
let apiResponseRequest = rxRequest(with: parameters) as Observable<(response: HTTPURLResponse, model: ApiResponse)>
return apiResponseRequest
.map {
if $0.model.errorCode == 0 {
return try T(JSON: try cast($0.model.result) as [String: Any])
} else {
throw ApiError(apiResponse: $0.model)
}
}
}
/// Returns observable for boolean response by parameters
open func requestForResult(with parameters: ApiRequestParameters) -> Observable<Bool> {
let apiResponseRequest = rxRequest(with: parameters) as Observable<(response: HTTPURLResponse, model: ApiResponse)>
return apiResponseRequest
.map {
if $0.model.errorCode == 0,
let result = $0.model.result as? Bool {
return result
} else {
throw ApiError(apiResponse: $0.model)
}
}
}
}

View File

@ -1,31 +0,0 @@
//
// Copyright (c) 2017 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import RxSwift
extension DefaultNetworkService {
func activityIndicatorBinding() -> Disposable? {
return nil
}
}

View File

@ -1,32 +0,0 @@
//
// Copyright (c) 2018 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import RxSwift
import LeadKit
extension DefaultNetworkService {
func activityIndicatorBinding() -> Disposable? {
return bindActivityIndicator()
}
}

View File

@ -1,46 +0,0 @@
//
// Copyright (c) 2018 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import Alamofire
import LeadKit
import RxSwift
/// Default implementation of network service, which trust any server and use default timeout interval
@available(*, deprecated, message: "Use NetworkService from LeadKit.")
open class DefaultNetworkService: NetworkService {
open class var retryLimit: UInt {
return 3
}
private let disposeBag = DisposeBag()
public override init(configuration: NetworkServiceConfiguration) {
super.init(configuration: configuration)
// Fatal error: `drive*` family of methods can be only called from `MainThread`
DispatchQueue.main.async {
self.activityIndicatorBinding()?.disposed(by: self.disposeBag)
}
}
}