Merge pull request #125 from TouchInstinct/feature/networkConfiguration
NetworkServiceConfiguration added
This commit is contained in:
commit
14e793cf09
|
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
### 0.7.6
|
||||
|
||||
- **Add**: `NetworkServiceConfiguration` to configure NetworkService instance
|
||||
- **Remove**: `ConfigurableNetworkSevice` protocol
|
||||
- **Update**: Acceptable status codes in SessionManager become `Set<Int>`
|
||||
|
||||
### 0.7.5
|
||||
- **Add**: `topConfiguration` and `bottomConfiguration` properties, methods to configure top and bottom separators in `CellSeparatorType` extension.
|
||||
- **Add**: `totalHeight` property in `SeparatorConfiguration` extension.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "LeadKit"
|
||||
s.version = "0.7.5"
|
||||
s.version = "0.7.6"
|
||||
s.summary = "iOS framework with a bunch of tools for rapid development"
|
||||
s.homepage = "https://github.com/TouchInstinct/LeadKit"
|
||||
s.license = "Apache License, Version 2.0"
|
||||
|
|
|
|||
|
|
@ -452,14 +452,6 @@
|
|||
67CAF8AC2065189C00527085 /* NetworkService+ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8AB2065189C00527085 /* NetworkService+ActivityIndicator.swift */; };
|
||||
67CAF8AD2065189C00527085 /* NetworkService+ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8AB2065189C00527085 /* NetworkService+ActivityIndicator.swift */; };
|
||||
67CAF8AE2065189C00527085 /* NetworkService+ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8AB2065189C00527085 /* NetworkService+ActivityIndicator.swift */; };
|
||||
67CAF8B120651E1E00527085 /* ConfigurableNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B020651E1E00527085 /* ConfigurableNetworkService.swift */; };
|
||||
67CAF8B220651E1E00527085 /* ConfigurableNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B020651E1E00527085 /* ConfigurableNetworkService.swift */; };
|
||||
67CAF8B320651E1E00527085 /* ConfigurableNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B020651E1E00527085 /* ConfigurableNetworkService.swift */; };
|
||||
67CAF8B420651E1E00527085 /* ConfigurableNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B020651E1E00527085 /* ConfigurableNetworkService.swift */; };
|
||||
67CAF8B620651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B520651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift */; };
|
||||
67CAF8B720651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B520651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift */; };
|
||||
67CAF8B820651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B520651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift */; };
|
||||
67CAF8B920651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8B520651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift */; };
|
||||
67CAF8C620652E2A00527085 /* TextFieldViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8C520652E2A00527085 /* TextFieldViewModel.swift */; };
|
||||
67CAF8C720652E2A00527085 /* TextFieldViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8C520652E2A00527085 /* TextFieldViewModel.swift */; };
|
||||
67CAF8C820652E2A00527085 /* TextFieldViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CAF8C520652E2A00527085 /* TextFieldViewModel.swift */; };
|
||||
|
|
@ -555,6 +547,10 @@
|
|||
BA6C6DB45950382041948FC5 /* Pods_LeadKit_LeadKit_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CFE9323150A9760008093F73 /* Pods_LeadKit_LeadKit_iOS.framework */; };
|
||||
D6EE55093E404DEA62B03DDF /* Pods_LeadKit_LeadKit_watchOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8590CA7831555C295C5DC572 /* Pods_LeadKit_LeadKit_watchOS.framework */; };
|
||||
DEE25FE98D40ED1C168F384A /* Pods_LeadKit_LeadKit_iOS_Extensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 887F99C5326BD220C2811BD6 /* Pods_LeadKit_LeadKit_iOS_Extensions.framework */; };
|
||||
EF24213A2076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */; };
|
||||
EF24213B2076D5C700FA9BE6 /* NetworkServiceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */; };
|
||||
EF24213C2076D5C900FA9BE6 /* NetworkServiceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */; };
|
||||
EF24213D2076D5CA00FA9BE6 /* NetworkServiceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */; };
|
||||
EFBE57D01EC35EF20040E00A /* Array+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFBE57CF1EC35EF20040E00A /* Array+Extensions.swift */; };
|
||||
EFBE57D11EC35EF20040E00A /* Array+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFBE57CF1EC35EF20040E00A /* Array+Extensions.swift */; };
|
||||
EFBE57D21EC35EF20040E00A /* Array+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EFBE57CF1EC35EF20040E00A /* Array+Extensions.swift */; };
|
||||
|
|
@ -746,8 +742,6 @@
|
|||
67A1FF931EBCA65E00D6C89F /* CABasicAnimation+Rotation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CABasicAnimation+Rotation.swift"; sourceTree = "<group>"; };
|
||||
67C7B1782068BB1C00C9EDA3 /* NumberFormattingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberFormattingService.swift; sourceTree = "<group>"; };
|
||||
67CAF8AB2065189C00527085 /* NetworkService+ActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NetworkService+ActivityIndicator.swift"; sourceTree = "<group>"; };
|
||||
67CAF8B020651E1E00527085 /* ConfigurableNetworkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurableNetworkService.swift; sourceTree = "<group>"; };
|
||||
67CAF8B520651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConfigurableNetworkService+DefaultImplementation.swift"; sourceTree = "<group>"; };
|
||||
67CAF8C520652E2A00527085 /* TextFieldViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldViewModel.swift; sourceTree = "<group>"; };
|
||||
67E6C2341EBB32F5007842A6 /* SingleLoadCursor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleLoadCursor.swift; sourceTree = "<group>"; };
|
||||
67EB7FBF206140E600BDD9FB /* TotalCountCursor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TotalCountCursor.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -790,6 +784,7 @@
|
|||
D0F8D0002B21A4F31981F1ED /* Pods_LeadKit_LeadKit_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_LeadKit_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D840E55867DC9BB63460B856 /* Pods-LeadKit tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKit tvOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKit tvOSTests/Pods-LeadKit tvOSTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
DF1148A279C7AC7A42B0A0F8 /* Pods_LeadKit_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkServiceConfiguration.swift; sourceTree = "<group>"; };
|
||||
EFBE57CF1EC35EF20040E00A /* Array+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+Extensions.swift"; sourceTree = "<group>"; };
|
||||
EFBE57DA1EC361620040E00A /* UIView+Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Layout.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
|
@ -1146,7 +1141,6 @@
|
|||
67EB7FC5206148C400BDD9FB /* DataLoading */,
|
||||
67274783206CD7E500725163 /* DateFormatingService */,
|
||||
672947E3206EA63200AC6B6B /* Drawing */,
|
||||
67CAF8AF20651E0F00527085 /* NetworkService */,
|
||||
67C7B1772068BADA00C9EDA3 /* NumberFormattingService */,
|
||||
673CF4202063D8EB00C329F6 /* Rx */,
|
||||
678D269C20692BFF00B05B93 /* Views */,
|
||||
|
|
@ -1173,9 +1167,10 @@
|
|||
671462351EB3396E00EAB194 /* Structures */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
677452B620627F9E0024EEEF /* DataLoading */,
|
||||
671462361EB3396E00EAB194 /* Api */,
|
||||
677452B620627F9E0024EEEF /* DataLoading */,
|
||||
671462381EB3396E00EAB194 /* DrawingOperations */,
|
||||
EF2421382076D5BD00FA9BE6 /* NetworkService */,
|
||||
671462421EB3396E00EAB194 /* Views */,
|
||||
);
|
||||
path = Structures;
|
||||
|
|
@ -1215,7 +1210,6 @@
|
|||
6714639C1EB33AC200EAB194 /* NetworkService */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
67CAF8B520651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift */,
|
||||
6714639D1EB33AEB00EAB194 /* NetworkService+ActivityIndicator-UIApplication.swift */,
|
||||
67CAF8AB2065189C00527085 /* NetworkService+ActivityIndicator.swift */,
|
||||
);
|
||||
|
|
@ -1254,13 +1248,13 @@
|
|||
671461D61EB3396E00EAB194 /* Enums */,
|
||||
671461DA1EB3396E00EAB194 /* Extensions */,
|
||||
6714621F1EB3396E00EAB194 /* Functions */,
|
||||
671462221EB3396E00EAB194 /* Protocols */,
|
||||
671462351EB3396E00EAB194 /* Structures */,
|
||||
67952DDC1EB3280900B3BA1A /* Info-iOS-Extensions.plist */,
|
||||
67952C391EB3203F00B3BA1A /* Info-iOS.plist */,
|
||||
67952C3B1EB3208000B3BA1A /* Info-tvOS.plist */,
|
||||
67952C3A1EB3205D00B3BA1A /* Info-watchOS.plist */,
|
||||
67186B201EB247A200CFAFFB /* LeadKit.h */,
|
||||
671462221EB3396E00EAB194 /* Protocols */,
|
||||
671462351EB3396E00EAB194 /* Structures */,
|
||||
);
|
||||
path = Sources;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -1592,14 +1586,6 @@
|
|||
path = NumberFormattingService;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
67CAF8AF20651E0F00527085 /* NetworkService */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
67CAF8B020651E1E00527085 /* ConfigurableNetworkService.swift */,
|
||||
);
|
||||
path = NetworkService;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
67EB7FC5206148C400BDD9FB /* DataLoading */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -1783,6 +1769,14 @@
|
|||
name = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EF2421382076D5BD00FA9BE6 /* NetworkService */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */,
|
||||
);
|
||||
path = NetworkService;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EFBE57CE1EC35ED90040E00A /* Array */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -2572,7 +2566,6 @@
|
|||
673CF42C2063DE5900C329F6 /* TextPlaceholderView.swift in Sources */,
|
||||
671463601EB3396E00EAB194 /* SupportProtocol.swift in Sources */,
|
||||
671462841EB3396E00EAB194 /* CGContext+Initializers.swift in Sources */,
|
||||
67CAF8B120651E1E00527085 /* ConfigurableNetworkService.swift in Sources */,
|
||||
EFBE57DB1EC361620040E00A /* UIView+Layout.swift in Sources */,
|
||||
6714639E1EB33AEB00EAB194 /* NetworkService+ActivityIndicator-UIApplication.swift in Sources */,
|
||||
6714634C1EB3396E00EAB194 /* ReuseIdentifierProtocol.swift in Sources */,
|
||||
|
|
@ -2620,7 +2613,6 @@
|
|||
671462581EB3396E00EAB194 /* Log.swift in Sources */,
|
||||
671462781EB3396E00EAB194 /* ResizeMode.swift in Sources */,
|
||||
A676AE551F98112E001F9214 /* ObservableMappable.swift in Sources */,
|
||||
67CAF8B620651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */,
|
||||
A6E0DDE11F8A696F002CA74E /* SeparatorRowBox.swift in Sources */,
|
||||
A6E0DDDE1F8A696F002CA74E /* EmptyCellRow.swift in Sources */,
|
||||
67EB7FFD206176C900BDD9FB /* AnyPaginationWrappable.swift in Sources */,
|
||||
|
|
@ -2654,6 +2646,7 @@
|
|||
671463341EB3396E00EAB194 /* DrawingOperation.swift in Sources */,
|
||||
673CF4182063D50700C329F6 /* GeneralDataLoadingController.swift in Sources */,
|
||||
671462701EB3396E00EAB194 /* CursorError.swift in Sources */,
|
||||
EF24213A2076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift in Sources */,
|
||||
671463981EB3396E00EAB194 /* AnyLoadingIndicator.swift in Sources */,
|
||||
671463A71EB340C000EAB194 /* UIViewController+ConfigurableController.swift in Sources */,
|
||||
671463141EB3396E00EAB194 /* UIViewController+TopVisibleViewController.swift in Sources */,
|
||||
|
|
@ -2740,8 +2733,6 @@
|
|||
671462821EB3396E00EAB194 /* AlamofireRequest+Extensions.swift in Sources */,
|
||||
67745288206259CF0024EEEF /* Rx+RxDataSourceProtocol.swift in Sources */,
|
||||
67E6C2371EBB32F5007842A6 /* SingleLoadCursor.swift in Sources */,
|
||||
67CAF8B320651E1E00527085 /* ConfigurableNetworkService.swift in Sources */,
|
||||
67CAF8B820651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */,
|
||||
67274781206CD3BD00725163 /* ViewText+Extensions.swift in Sources */,
|
||||
671463561EB3396E00EAB194 /* StaticViewHeightProtocol.swift in Sources */,
|
||||
671463621EB3396E00EAB194 /* SupportProtocol.swift in Sources */,
|
||||
|
|
@ -2762,6 +2753,7 @@
|
|||
671463321EB3396E00EAB194 /* CursorType.swift in Sources */,
|
||||
6714624E1EB3396E00EAB194 /* MapCursor.swift in Sources */,
|
||||
A676AE571F981130001F9214 /* ObservableMappable.swift in Sources */,
|
||||
EF24213C2076D5C900FA9BE6 /* NetworkServiceConfiguration.swift in Sources */,
|
||||
6774528F20625C9E0024EEEF /* GeneralDataLoadingState.swift in Sources */,
|
||||
671463261EB3396E00EAB194 /* Any+TypeName.swift in Sources */,
|
||||
6714638A1EB3396E00EAB194 /* RoundDrawingOperation.swift in Sources */,
|
||||
|
|
@ -2944,7 +2936,6 @@
|
|||
675C1FB41F97CA32007D5249 /* AppearanceConfigurable.swift in Sources */,
|
||||
6714631B1EB3396E00EAB194 /* UIWindow+Extensions.swift in Sources */,
|
||||
671462571EB3396E00EAB194 /* App.swift in Sources */,
|
||||
67CAF8B420651E1E00527085 /* ConfigurableNetworkService.swift in Sources */,
|
||||
673CF4252063D90600C329F6 /* DisposeBagHolder.swift in Sources */,
|
||||
6714637B1EB3396E00EAB194 /* CALayerDrawingOperation.swift in Sources */,
|
||||
6774529520625D170024EEEF /* GeneralDataLoadingModel.swift in Sources */,
|
||||
|
|
@ -2959,8 +2950,8 @@
|
|||
671462DB1EB3396E00EAB194 /* TimeInterval+DateComponents.swift in Sources */,
|
||||
6774529020625C9E0024EEEF /* GeneralDataLoadingState.swift in Sources */,
|
||||
67EB7FC3206140E600BDD9FB /* TotalCountCursor.swift in Sources */,
|
||||
EF24213D2076D5CA00FA9BE6 /* NetworkServiceConfiguration.swift in Sources */,
|
||||
6714638F1EB3396E00EAB194 /* SolidFillDrawingOperation.swift in Sources */,
|
||||
67CAF8B920651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */,
|
||||
67E6C2381EBB32F5007842A6 /* SingleLoadCursor.swift in Sources */,
|
||||
67C7B17C2068BB1C00C9EDA3 /* NumberFormattingService.swift in Sources */,
|
||||
671462531EB3396E00EAB194 /* StaticCursor.swift in Sources */,
|
||||
|
|
@ -3016,6 +3007,7 @@
|
|||
671462911EB3396E00EAB194 /* CGImage+Crop.swift in Sources */,
|
||||
673564F72068C68D00F0CBED /* NumberFormat.swift in Sources */,
|
||||
67051ADC1EBC7C36008EADC0 /* SpinnerView.swift in Sources */,
|
||||
EF24213B2076D5C700FA9BE6 /* NetworkServiceConfiguration.swift in Sources */,
|
||||
671462FD1EB3396E00EAB194 /* UIView+XibNameProtocol.swift in Sources */,
|
||||
671463851EB3396E00EAB194 /* ResizeDrawingOperation.swift in Sources */,
|
||||
673564F22068C2AD00F0CBED /* NumberFormattingService+DefaultImplementation.swift in Sources */,
|
||||
|
|
@ -3094,7 +3086,6 @@
|
|||
671462551EB3396E00EAB194 /* App.swift in Sources */,
|
||||
67A1FF901EBCA09B00D6C89F /* UIImage+Spinner.swift in Sources */,
|
||||
6774529B20625E5B0024EEEF /* PaginationDataLoadingState.swift in Sources */,
|
||||
67CAF8B220651E1E00527085 /* ConfigurableNetworkService.swift in Sources */,
|
||||
671463791EB3396E00EAB194 /* CALayerDrawingOperation.swift in Sources */,
|
||||
6727476A206CCCA300725163 /* ViewBackground.swift in Sources */,
|
||||
6714632D1EB3396E00EAB194 /* ConfigurableController.swift in Sources */,
|
||||
|
|
@ -3115,7 +3106,6 @@
|
|||
671463A31EB33FF600EAB194 /* Animatable.swift in Sources */,
|
||||
678D26A120692BFF00B05B93 /* TextFieldViewEvents.swift in Sources */,
|
||||
671462511EB3396E00EAB194 /* StaticCursor.swift in Sources */,
|
||||
67CAF8B720651E4F00527085 /* ConfigurableNetworkService+DefaultImplementation.swift in Sources */,
|
||||
6714629D1EB3396E00EAB194 /* CursorType+Slice.swift in Sources */,
|
||||
671463691EB3396E00EAB194 /* ConfigurableView.swift in Sources */,
|
||||
67EB7FD020615B8900BDD9FB /* TotalCountCursorConfiguration.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ open class NetworkService {
|
|||
private let requestCountVariable = Variable<Int>(0)
|
||||
private var disposeBag = DisposeBag()
|
||||
|
||||
private let acceptableStatusCodes: [Int]
|
||||
public let configuration: NetworkServiceConfiguration
|
||||
public let sessionManager: Alamofire.SessionManager
|
||||
|
||||
var requestCount: Driver<Int> {
|
||||
|
|
@ -47,14 +47,11 @@ open class NetworkService {
|
|||
/// Creates new instance of NetworkService with given Alamofire session manager
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - sessionManager: Alamofire.SessionManager to use for requests.
|
||||
/// - acceptableStatusCodes: Validates that the response has a status code in the specified sequence.
|
||||
public init(sessionManager: Alamofire.SessionManager,
|
||||
acceptableStatusCodes: [Int] = Alamofire.SessionManager.defaultAcceptableStatusCodes) {
|
||||
|
||||
self.sessionManager = sessionManager
|
||||
self.acceptableStatusCodes = acceptableStatusCodes
|
||||
/// - configuration: instance of NetworkServiceConfiguration to configure network service.
|
||||
public init(configuration: NetworkServiceConfiguration) {
|
||||
|
||||
self.configuration = configuration
|
||||
self.sessionManager = configuration.sessionManager
|
||||
bindToApplicationActivityIndicator()
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +63,7 @@ open class NetworkService {
|
|||
-> Observable<(response: HTTPURLResponse, model: T)> where T.ModelType == T {
|
||||
|
||||
return sessionManager.rx.responseObservableModel(requestParameters: parameters,
|
||||
acceptableStatusCodes: acceptableStatusCodes)
|
||||
acceptableStatusCodes: configuration.acceptableStatusCodes)
|
||||
.counterTracking(for: self)
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +75,7 @@ open class NetworkService {
|
|||
-> Observable<(response: HTTPURLResponse, model: T)> {
|
||||
|
||||
return sessionManager.rx.responseModel(requestParameters: parameters,
|
||||
acceptableStatusCodes: acceptableStatusCodes)
|
||||
acceptableStatusCodes: configuration.acceptableStatusCodes)
|
||||
.counterTracking(for: self)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import ObjectMapper
|
|||
public extension Alamofire.SessionManager {
|
||||
|
||||
/// The default acceptable range 200...299
|
||||
static let defaultAcceptableStatusCodes = Array(200..<300)
|
||||
static let defaultAcceptableStatusCodes = Set(200..<300)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ public extension Reactive where Base: Alamofire.SessionManager {
|
|||
/// - Parameter requestParameters: api parameters to pass Alamofire
|
||||
/// - Returns: Observable with request
|
||||
func apiRequest(requestParameters: ApiRequestParameters,
|
||||
acceptableStatusCodes: [Int] = Base.defaultAcceptableStatusCodes)
|
||||
acceptableStatusCodes: Set<Int> = Base.defaultAcceptableStatusCodes)
|
||||
-> Observable<DataRequest> {
|
||||
|
||||
return request(requestParameters.method,
|
||||
|
|
@ -57,7 +57,7 @@ public extension Reactive where Base: Alamofire.SessionManager {
|
|||
/// - Returns: Observable with HTTP URL Response and target object
|
||||
func responseModel<T: ImmutableMappable>(requestParameters: ApiRequestParameters,
|
||||
mappingQueue: DispatchQueue = .global(),
|
||||
acceptableStatusCodes: [Int] = Base.defaultAcceptableStatusCodes)
|
||||
acceptableStatusCodes: Set<Int> = Base.defaultAcceptableStatusCodes)
|
||||
-> Observable<(response: HTTPURLResponse, model: T)> {
|
||||
|
||||
return apiRequest(requestParameters: requestParameters, acceptableStatusCodes: acceptableStatusCodes)
|
||||
|
|
@ -71,7 +71,7 @@ public extension Reactive where Base: Alamofire.SessionManager {
|
|||
/// - Returns: Observable with HTTP URL Response and array of target objects
|
||||
func responseModel<T: ImmutableMappable>(requestParameters: ApiRequestParameters,
|
||||
mappingQueue: DispatchQueue = .global(),
|
||||
acceptableStatusCodes: [Int] = Base.defaultAcceptableStatusCodes)
|
||||
acceptableStatusCodes: Set<Int> = Base.defaultAcceptableStatusCodes)
|
||||
-> Observable<(response: HTTPURLResponse, models: [T])> {
|
||||
|
||||
return apiRequest(requestParameters: requestParameters, acceptableStatusCodes: acceptableStatusCodes)
|
||||
|
|
@ -85,7 +85,7 @@ public extension Reactive where Base: Alamofire.SessionManager {
|
|||
/// - Returns: Observable with HTTP URL Response and target object
|
||||
func responseObject<T>(requestParameters: ApiRequestParameters,
|
||||
mappingQueue: DispatchQueue = .global(),
|
||||
acceptableStatusCodes: [Int] = Base.defaultAcceptableStatusCodes)
|
||||
acceptableStatusCodes: Set<Int> = Base.defaultAcceptableStatusCodes)
|
||||
-> Observable<(response: HTTPURLResponse, object: T)> {
|
||||
|
||||
return apiRequest(requestParameters: requestParameters, acceptableStatusCodes: acceptableStatusCodes)
|
||||
|
|
@ -99,7 +99,7 @@ public extension Reactive where Base: Alamofire.SessionManager {
|
|||
/// - Returns: Observable with HTTP URL Response and target object
|
||||
func responseObservableModel<T: ObservableMappable>(requestParameters: ApiRequestParameters,
|
||||
mappingQueue: DispatchQueue = .global(),
|
||||
acceptableStatusCodes: [Int] = Base.defaultAcceptableStatusCodes)
|
||||
acceptableStatusCodes: Set<Int> = Base.defaultAcceptableStatusCodes)
|
||||
-> Observable<(response: HTTPURLResponse, model: T)> where T.ModelType == T {
|
||||
|
||||
return apiRequest(requestParameters: requestParameters, acceptableStatusCodes: acceptableStatusCodes)
|
||||
|
|
@ -113,7 +113,7 @@ public extension Reactive where Base: Alamofire.SessionManager {
|
|||
/// - Returns: Observable with HTTP URL Response and array of target objects
|
||||
func responseObservableModel<T: ObservableMappable>(requestParameters: ApiRequestParameters,
|
||||
mappingQueue: DispatchQueue = .global(),
|
||||
acceptableStatusCodes: [Int] = Base.defaultAcceptableStatusCodes)
|
||||
acceptableStatusCodes: Set<Int> = Base.defaultAcceptableStatusCodes)
|
||||
-> Observable<(response: HTTPURLResponse, models: [T])> where T.ModelType == T {
|
||||
|
||||
return apiRequest(requestParameters: requestParameters, acceptableStatusCodes: acceptableStatusCodes)
|
||||
|
|
|
|||
|
|
@ -1,54 +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
|
||||
|
||||
public extension ConfigurableNetworkService {
|
||||
|
||||
static var timeoutInterval: TimeInterval {
|
||||
return 20
|
||||
}
|
||||
|
||||
static var serverTrustPolicies: [String: ServerTrustPolicy] {
|
||||
return [
|
||||
baseUrl: .disableEvaluation
|
||||
]
|
||||
}
|
||||
|
||||
static var additionalHttpHeaders: HTTPHeaders {
|
||||
return SessionManager.defaultHTTPHeaders
|
||||
}
|
||||
|
||||
static var sessionConfiguration: URLSessionConfiguration {
|
||||
let configuration = URLSessionConfiguration.default
|
||||
configuration.timeoutIntervalForRequest = timeoutInterval
|
||||
configuration.httpAdditionalHeaders = additionalHttpHeaders
|
||||
|
||||
return configuration
|
||||
}
|
||||
|
||||
static var sessionManager: SessionManager {
|
||||
return SessionManager(configuration: sessionConfiguration,
|
||||
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
/// Protocol with some basic settings for network service configuration.
|
||||
public protocol ConfigurableNetworkService {
|
||||
|
||||
/// Base api url string.
|
||||
static var baseUrl: String { get }
|
||||
|
||||
/// Timeout interval for requests.
|
||||
static var timeoutInterval: TimeInterval { get }
|
||||
|
||||
/// Server trust policies.
|
||||
static var serverTrustPolicies: [String: ServerTrustPolicy] { get }
|
||||
|
||||
/// A dictionary of additional headers to send with requests.
|
||||
static var additionalHttpHeaders: HTTPHeaders { get }
|
||||
|
||||
/// Session configuration to use in SessionManager.
|
||||
static var sessionConfiguration: URLSessionConfiguration { get }
|
||||
|
||||
/// Session manager.
|
||||
static var sessionManager: SessionManager { get }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
//
|
||||
// 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
|
||||
|
||||
public struct NetworkServiceConfiguration {
|
||||
|
||||
/// Base api url string.
|
||||
public let baseUrl: String
|
||||
|
||||
/// Timeout interval for requests.
|
||||
public let timeoutInterval: TimeInterval
|
||||
|
||||
/// Default parameters encoding
|
||||
public let encoding: ParameterEncoding
|
||||
|
||||
/// A dictionary of additional headers to send with requests.
|
||||
public let additionalHttpHeaders: HTTPHeaders
|
||||
|
||||
/// Server trust policies.
|
||||
public var serverTrustPolicies: [String: ServerTrustPolicy]
|
||||
|
||||
/// Acceptable status codes for validation
|
||||
public var acceptableStatusCodes: Set<Int> = Alamofire.SessionManager.defaultAcceptableStatusCodes
|
||||
|
||||
/// Session configuration for potential fine tuning
|
||||
public var sessionConfiguration: URLSessionConfiguration
|
||||
|
||||
public init(baseUrl: String,
|
||||
timeoutInterval: TimeInterval = 20,
|
||||
encoding: ParameterEncoding = URLEncoding.default,
|
||||
additionalHttpHeaders: HTTPHeaders = SessionManager.defaultHTTPHeaders) {
|
||||
|
||||
self.baseUrl = baseUrl
|
||||
self.timeoutInterval = timeoutInterval
|
||||
self.encoding = encoding
|
||||
self.additionalHttpHeaders = additionalHttpHeaders
|
||||
|
||||
sessionConfiguration = URLSessionConfiguration.default
|
||||
sessionConfiguration.timeoutIntervalForRequest = timeoutInterval
|
||||
sessionConfiguration.httpAdditionalHeaders = additionalHttpHeaders
|
||||
|
||||
serverTrustPolicies = [baseUrl: .disableEvaluation]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension NetworkServiceConfiguration {
|
||||
|
||||
/// SessionManager constructed with given parameters (session configuration and trust policies)
|
||||
var sessionManager: SessionManager {
|
||||
return SessionManager(configuration: sessionConfiguration,
|
||||
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies))
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue