├── .DS_Store ├── Network ├── ArrayResponseMapper.swift ├── BackendAPIRequest.swift ├── BackendConfiguration.swift ├── BackendService.swift ├── Info.plist ├── NSError+Failure.swift ├── Network.h ├── NetworkOperation.swift ├── NetworkQueue.swift ├── NetworkService.swift ├── ParsedItem.swift ├── ResponseMapper.swift ├── ServiceOperation.swift ├── SignInItem.swift ├── SignInOperation.swift ├── SignInRequest.swift ├── SignInResponseMapper.swift ├── SignUpOperation.swift ├── SignUpRequest.swift ├── UserItem.swift └── UserResponseMapping.swift ├── NetworkLayerExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── chrisbyatt.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── tomkowz.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── alessioroberto.xcuserdatad │ └── xcschemes │ │ ├── Network.xcscheme │ │ └── NetworkLayerExample.xcscheme │ ├── chrisbyatt.xcuserdatad │ └── xcschemes │ │ ├── Network.xcscheme │ │ ├── NetworkLayerExample.xcscheme │ │ └── xcschememanagement.plist │ └── tomkowz.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── Network.xcscheme │ ├── NetworkLayerExample.xcscheme │ └── xcschememanagement.plist ├── NetworkLayerExample ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── NetworkLayerConfiguration.swift └── ViewController.swift └── Templates └── Network ├── .DS_Store ├── Network Operation.xctemplate ├── .DS_Store ├── TemplateIcon.png ├── TemplateIcon@2x.png ├── TemplateInfo.plist └── ___FILEBASENAME___.swift ├── Network Request.xctemplate ├── .DS_Store ├── TemplateIcon.png ├── TemplateIcon@2x.png ├── TemplateInfo.plist └── ___FILEBASENAME___.swift └── Response Mapper.xctemplate ├── .DS_Store ├── TemplateIcon.png ├── TemplateIcon@2x.png ├── TemplateInfo.plist └── ___FILEBASENAME___.swift /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/.DS_Store -------------------------------------------------------------------------------- /Network/ArrayResponseMapper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | final class ArrayResponseMapper { 4 | 5 | static func process(_ obj: AnyObject?, mapper: ((Any?) throws -> A)) throws -> [A] { 6 | guard let json = obj as? [[String: AnyObject]] else { throw ResponseMapperError.invalid } 7 | 8 | var items = [A]() 9 | for jsonNode in json { 10 | let item = try mapper(jsonNode) 11 | items.append(item) 12 | } 13 | return items 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Network/BackendAPIRequest.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol BackendAPIRequest { 4 | var endpoint: String { get } 5 | var method: NetworkService.Method { get } 6 | var query: NetworkService.QueryType { get } 7 | var parameters: [String: Any]? { get } 8 | var headers: [String: String]? { get } 9 | } 10 | 11 | extension BackendAPIRequest { 12 | 13 | func defaultJSONHeaders() -> [String: String] { 14 | return ["Content-Type": "application/json"] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Network/BackendConfiguration.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public final class BackendConfiguration { 4 | 5 | let baseURL: URL 6 | 7 | public init(baseURL: URL) { 8 | self.baseURL = baseURL 9 | } 10 | 11 | public static var shared: BackendConfiguration! 12 | } 13 | -------------------------------------------------------------------------------- /Network/BackendService.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public let DidPerformUnauthorizedOperation = "DidPerformUnauthorizedOperation" 4 | 5 | class BackendService { 6 | 7 | private let conf: BackendConfiguration 8 | private let service = NetworkService() 9 | 10 | init(_ conf: BackendConfiguration) { 11 | self.conf = conf 12 | } 13 | 14 | func request(_ request: BackendAPIRequest, 15 | success: ((AnyObject?) -> Void)? = nil, 16 | failure: ((NSError) -> Void)? = nil) { 17 | 18 | let url = conf.baseURL.appendingPathComponent(request.endpoint) 19 | 20 | var headers = request.headers 21 | // Set authentication token if available. 22 | // headers?["X-Api-Auth-Token"] = BackendAuth.shared.token 23 | 24 | service.makeRequest(for: url, method: request.method, query: request.query, params: request.parameters, headers: headers, success: { data in 25 | var json: AnyObject? = nil 26 | if let data = data { 27 | json = try? JSONSerialization.jsonObject(with: data as Data, options: []) as AnyObject 28 | } 29 | success?(json) 30 | 31 | }, failure: { data, error, statusCode in 32 | if statusCode == 401 { 33 | // Operation not authorized 34 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: DidPerformUnauthorizedOperation), object: nil) 35 | return 36 | } 37 | 38 | if let data = data { 39 | let json = try? JSONSerialization.jsonObject(with: data as Data, options: []) as AnyObject 40 | let info = [ 41 | NSLocalizedDescriptionKey: json?["error"] as? String ?? "", 42 | NSLocalizedFailureReasonErrorKey: "Probably not allowed action." 43 | ] 44 | let error = NSError(domain: "BackendService", code: 0, userInfo: info) 45 | failure?(error) 46 | } else { 47 | failure?(error ?? NSError(domain: "BackendService", code: 0, userInfo: nil)) 48 | } 49 | }) 50 | } 51 | 52 | func cancel() { 53 | service.cancel() 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Network/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Network/NSError+Failure.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension NSError { 4 | class func cannotParseResponse() -> NSError { 5 | let info = [NSLocalizedDescriptionKey: "Can't parse response. Please report a bug."] 6 | return NSError(domain: String(describing: self), code: 0, userInfo: info) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Network/Network.h: -------------------------------------------------------------------------------- 1 | // 2 | // Network.h 3 | // Network 4 | // 5 | // Created by Tomasz Szulc on 07/08/16. 6 | // Copyright © 2016 Tomasz Szulc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Network. 12 | FOUNDATION_EXPORT double NetworkVersionNumber; 13 | 14 | //! Project version string for Network. 15 | FOUNDATION_EXPORT const unsigned char NetworkVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Network/NetworkOperation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class NetworkOperation: Operation { 4 | 5 | private var _isReady: Bool 6 | public override var isReady: Bool { 7 | get { return _isReady } 8 | set { update( 9 | { self._isReady = newValue }, key: "isReady") } 10 | } 11 | 12 | private var _isExecuting: Bool 13 | public override var isExecuting: Bool { 14 | get { return _isExecuting } 15 | set { update({ self._isExecuting = newValue }, key: "isExecuting") } 16 | } 17 | 18 | private var _isFinished: Bool 19 | public override var isFinished: Bool { 20 | get { return _isFinished } 21 | set { update({ self._isFinished = newValue }, key: "isFinished") } 22 | } 23 | 24 | private var _isCancelled: Bool 25 | public override var isCancelled: Bool { 26 | get { return _isCancelled } 27 | set { update({ self._isCancelled = newValue }, key: "isCancelled") } 28 | } 29 | 30 | private func update(_ change: (Void) -> Void, key: String) { 31 | willChangeValue(forKey: key) 32 | change() 33 | didChangeValue(forKey: key) 34 | } 35 | 36 | override init() { 37 | _isReady = true 38 | _isExecuting = false 39 | _isFinished = false 40 | _isCancelled = false 41 | super.init() 42 | name = "Network Operation" 43 | } 44 | 45 | public override var isAsynchronous: Bool { 46 | return true 47 | } 48 | 49 | public override func start() { 50 | if self.isExecuting == false { 51 | self.isReady = false 52 | self.isExecuting = true 53 | self.isFinished = false 54 | self.isCancelled = false 55 | print("\(self.name!) operation started.") 56 | } 57 | } 58 | 59 | /// Used only by subclasses. Externally you should use `cancel`. 60 | func finish() { 61 | print("\(self.name!) operation finished.") 62 | self.isExecuting = false 63 | self.isFinished = true 64 | } 65 | 66 | public override func cancel() { 67 | print("\(self.name!) operation cancelled.") 68 | self.isExecuting = false 69 | self.isCancelled = true 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Network/NetworkQueue.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class NetworkQueue { 4 | 5 | public static var shared: NetworkQueue! 6 | 7 | let queue = OperationQueue() 8 | 9 | public init() {} 10 | 11 | public func addOperation(_ op: Operation) { 12 | queue.addOperation(op) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Network/NetworkService.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class NetworkService { 4 | 5 | private var task: URLSessionDataTask? 6 | private var successCodes: CountableRange = 200..<299 7 | private var failureCodes: CountableRange = 400..<499 8 | 9 | enum Method: String { 10 | case get, post, put, delete 11 | } 12 | 13 | enum QueryType { 14 | case json, path 15 | } 16 | 17 | func makeRequest(for url: URL, method: Method, query type: QueryType, 18 | params: [String: Any]? = nil, 19 | headers: [String: String]? = nil, 20 | success: ((Data?) -> Void)? = nil, 21 | failure: ((_ data: Data?, _ error: NSError?, _ responseCode: Int) -> Void)? = nil) { 22 | 23 | 24 | var mutableRequest = makeQuery(for: url, params: params, type: type) 25 | 26 | mutableRequest.allHTTPHeaderFields = headers 27 | mutableRequest.httpMethod = method.rawValue 28 | 29 | let session = URLSession.shared 30 | 31 | task = session.dataTask(with: mutableRequest as URLRequest, completionHandler: { (data, response, error) in 32 | guard let httpResponse = response as? HTTPURLResponse else { 33 | failure?(data, error as? NSError, 0) 34 | return 35 | } 36 | 37 | if let error = error { 38 | // Request failed, might be internet connection issue 39 | failure?(data, error as NSError, httpResponse.statusCode) 40 | return 41 | } 42 | 43 | if self.successCodes.contains(httpResponse.statusCode) { 44 | print("Request finished with success.") 45 | success?(data) 46 | } else if self.failureCodes.contains(httpResponse.statusCode) { 47 | print("Request finished with failure.") 48 | failure?(data, error as NSError?, httpResponse.statusCode) 49 | } else { 50 | print("Request finished with serious failure.") 51 | // Server returned response with status code different than 52 | // expected `successCodes`. 53 | let info = [ 54 | NSLocalizedDescriptionKey: "Request failed with code \(httpResponse.statusCode)", 55 | NSLocalizedFailureReasonErrorKey: "Wrong handling logic, wrong endpoing mapping or backend bug." 56 | ] 57 | let error = NSError(domain: "NetworkService", code: 0, userInfo: info) 58 | failure?(data, error, httpResponse.statusCode) 59 | } 60 | }) 61 | 62 | task?.resume() 63 | } 64 | 65 | func cancel() { 66 | task?.cancel() 67 | } 68 | 69 | 70 | //MARK: Private 71 | private func makeQuery(for url: URL, params: [String: Any]?, type: QueryType) -> URLRequest { 72 | switch type { 73 | case .json: 74 | var mutableRequest = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, 75 | timeoutInterval: 10.0) 76 | if let params = params { 77 | mutableRequest.httpBody = try! JSONSerialization.data(withJSONObject: params, options: []) 78 | } 79 | 80 | return mutableRequest 81 | case .path: 82 | var query = "" 83 | 84 | params?.forEach { key, value in 85 | query = query + "\(key)=\(value)&" 86 | } 87 | 88 | var components = URLComponents(url: url, resolvingAgainstBaseURL: true)! 89 | components.query = query 90 | 91 | return URLRequest(url: components.url!, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 10.0) 92 | } 93 | 94 | } 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /Network/ParsedItem.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public protocol ParsedItem {} -------------------------------------------------------------------------------- /Network/ResponseMapper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol ResponseMapperProtocol { 4 | associatedtype Item 5 | static func process(_ obj: AnyObject?) throws -> Item 6 | } 7 | 8 | internal enum ResponseMapperError: Error { 9 | case invalid 10 | case missingAttribute 11 | } 12 | 13 | class ResponseMapper { 14 | 15 | static func process(_ obj: AnyObject?, parse: (_ json: [String: AnyObject]) -> A?) throws -> A { 16 | guard let json = obj as? [String: AnyObject] else { throw ResponseMapperError.invalid } 17 | if let item = parse(json) { 18 | return item 19 | } else { 20 | throw ResponseMapperError.missingAttribute 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Network/ServiceOperation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class ServiceOperation: NetworkOperation { 4 | 5 | let service: BackendService 6 | 7 | public override init() { 8 | self.service = BackendService(BackendConfiguration.shared) 9 | super.init() 10 | } 11 | 12 | public override func cancel() { 13 | service.cancel() 14 | super.cancel() 15 | } 16 | } -------------------------------------------------------------------------------- /Network/SignInItem.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct SignInItem: ParsedItem { 4 | 5 | public let token: String 6 | public let uniqueId: String 7 | } 8 | -------------------------------------------------------------------------------- /Network/SignInOperation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class SignInOperation: ServiceOperation { 4 | 5 | private let request: SignInRequest 6 | 7 | public var success: ((SignInItem) -> Void)? 8 | public var failure: ((NSError) -> Void)? 9 | 10 | public init(email: String, password: String) { 11 | request = SignInRequest(email: email, password: password) 12 | super.init() 13 | } 14 | 15 | public override func start() { 16 | super.start() 17 | service.request(request, success: handleSuccess, failure: handleFailure) 18 | } 19 | 20 | private func handleSuccess(_ response: AnyObject?) { 21 | do { 22 | let item = try SignInResponseMapper.process(response) 23 | self.success?(item) 24 | self.finish() 25 | } catch { 26 | handleFailure(NSError.cannotParseResponse()) 27 | } 28 | } 29 | 30 | private func handleFailure(_ error: NSError) { 31 | self.failure?(error) 32 | self.finish() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Network/SignInRequest.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | final class SignInRequest: BackendAPIRequest { 4 | 5 | private let email: String 6 | private let password: String 7 | 8 | init(email: String, password: String) { 9 | self.email = email 10 | self.password = password 11 | } 12 | 13 | var endpoint: String { 14 | return "/users/sign_in" 15 | } 16 | 17 | var method: NetworkService.Method { 18 | return .post 19 | } 20 | 21 | var query: NetworkService.QueryType { 22 | return .json 23 | } 24 | 25 | var parameters: [String : Any]? { 26 | return [ 27 | "email": email, 28 | "password": password 29 | ] 30 | } 31 | 32 | var headers: [String : String]? { 33 | return defaultJSONHeaders() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Network/SignInResponseMapper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | final class SignInResponseMapper: ResponseMapper, ResponseMapperProtocol { 4 | 5 | static func process(_ obj: AnyObject?) throws -> SignInItem { 6 | return try process(obj, parse: { json in 7 | let token = json["token"] as? String 8 | let uniqueId = json["unique_id"] as? String 9 | if let token = token, let uniqueId = uniqueId { 10 | return SignInItem(token: token, uniqueId: uniqueId) 11 | } 12 | return nil 13 | }) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Network/SignUpOperation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class SignUpOperation: ServiceOperation { 4 | 5 | private let request: SignUpRequest 6 | 7 | public var success: ((UserItem) -> Void)? = nil 8 | public var failure: ((NSError) -> Void)? = nil 9 | 10 | public init(user: UserItem, password: String) { 11 | self.request = SignUpRequest(user: user, password: password) 12 | super.init() 13 | } 14 | 15 | public override func start() { 16 | super.start() 17 | service.request(request, success: handleSuccess, failure: handleFailure) 18 | } 19 | 20 | private func handleSuccess(_ response: AnyObject?) { 21 | do { 22 | let item = try UserResponseMapper.process(response) 23 | self.success?(item) 24 | self.finish() 25 | } catch { 26 | handleFailure(NSError.cannotParseResponse()) 27 | } 28 | } 29 | 30 | private func handleFailure(_ error: NSError) { 31 | self.failure?(error) 32 | self.finish() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Network/SignUpRequest.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | final class SignUpRequest: BackendAPIRequest { 4 | 5 | private let user: UserItem 6 | private let password: String 7 | 8 | init(user: UserItem, password: String) { 9 | self.user = user 10 | self.password = password 11 | } 12 | 13 | var endpoint: String { 14 | return "/users" 15 | } 16 | 17 | var method: NetworkService.Method { 18 | return .post 19 | } 20 | 21 | var query: NetworkService.QueryType { 22 | return .json 23 | } 24 | 25 | var parameters: [String: Any]? { 26 | var params = [String: Any]() 27 | params["first_name"] = user.firstName 28 | params["last_name"] = user.lastName 29 | params["email"] = user.email 30 | params["phone_number"] = user.phoneNumber ?? NSNull() 31 | params["password"] = password 32 | return params 33 | } 34 | 35 | var headers: [String: String]? { 36 | return defaultJSONHeaders() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Network/UserItem.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class UserItem: ParsedItem { 4 | 5 | /// The property is nil when passed for sign in or sign up operations. 6 | public let uniqueId: String! 7 | 8 | public let firstName: String 9 | public let lastName: String 10 | public let email: String 11 | public let phoneNumber: String? 12 | 13 | public init(uniqueId: String! = nil, firstName: String, lastName: String, 14 | email: String, phoneNumber: String?) { 15 | self.uniqueId = uniqueId 16 | self.firstName = firstName 17 | self.lastName = lastName 18 | self.email = email 19 | self.phoneNumber = phoneNumber 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Network/UserResponseMapping.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | final class UserResponseMapper: ResponseMapper, ResponseMapperProtocol { 4 | 5 | static func process(_ obj: AnyObject?) throws -> UserItem { 6 | return try process(obj, parse: { json in 7 | let uniqueId = json["unique_id"] as? String 8 | let firstName = json["first_name"] as? String 9 | let lastName = json["last_name"] as? String 10 | let email = json["email"] as? String 11 | let phoneNumber = json["phone_number"] as? String 12 | 13 | if let uniqueId = uniqueId, let firstName = firstName, 14 | let lastName = lastName, let email = email { 15 | return UserItem(uniqueId: uniqueId, firstName: firstName, 16 | lastName: lastName, email: email, phoneNumber: phoneNumber) 17 | } 18 | return nil 19 | }) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6D02D7471D5730D800CA76B9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7461D5730D800CA76B9 /* AppDelegate.swift */; }; 11 | 6D02D7491D5730D800CA76B9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7481D5730D800CA76B9 /* ViewController.swift */; }; 12 | 6D02D74C1D5730D800CA76B9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D02D74A1D5730D800CA76B9 /* Main.storyboard */; }; 13 | 6D02D74E1D5730D800CA76B9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D02D74D1D5730D800CA76B9 /* Assets.xcassets */; }; 14 | 6D02D7511D5730D800CA76B9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D02D74F1D5730D800CA76B9 /* LaunchScreen.storyboard */; }; 15 | 6D02D7601D5730EE00CA76B9 /* Network.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D02D75F1D5730EE00CA76B9 /* Network.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | 6D02D7641D5730EE00CA76B9 /* Network.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D02D75D1D5730EE00CA76B9 /* Network.framework */; }; 17 | 6D02D7651D5730EE00CA76B9 /* Network.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6D02D75D1D5730EE00CA76B9 /* Network.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 6D02D7721D57317800CA76B9 /* BackendConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7711D57317800CA76B9 /* BackendConfiguration.swift */; }; 19 | 6D02D7741D57318600CA76B9 /* BackendAPIRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7731D57318600CA76B9 /* BackendAPIRequest.swift */; }; 20 | 6D02D7761D57318F00CA76B9 /* BackendService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7751D57318F00CA76B9 /* BackendService.swift */; }; 21 | 6D02D7781D57319400CA76B9 /* ServiceOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7771D57319400CA76B9 /* ServiceOperation.swift */; }; 22 | 6D02D77A1D5731B200CA76B9 /* ArrayResponseMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7791D5731B200CA76B9 /* ArrayResponseMapper.swift */; }; 23 | 6D02D77C1D5731B600CA76B9 /* ResponseMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D77B1D5731B600CA76B9 /* ResponseMapper.swift */; }; 24 | 6D02D7801D5731C500CA76B9 /* NetworkOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D77D1D5731C500CA76B9 /* NetworkOperation.swift */; }; 25 | 6D02D7811D5731C500CA76B9 /* NetworkQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D77E1D5731C500CA76B9 /* NetworkQueue.swift */; }; 26 | 6D02D7821D5731C500CA76B9 /* NetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D77F1D5731C500CA76B9 /* NetworkService.swift */; }; 27 | 6D02D7841D5731D500CA76B9 /* SignInItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7831D5731D500CA76B9 /* SignInItem.swift */; }; 28 | 6D02D7861D5731DA00CA76B9 /* UserItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7851D5731DA00CA76B9 /* UserItem.swift */; }; 29 | 6D02D7891D5731E600CA76B9 /* SignInResponseMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7871D5731E600CA76B9 /* SignInResponseMapper.swift */; }; 30 | 6D02D78A1D5731E600CA76B9 /* UserResponseMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7881D5731E600CA76B9 /* UserResponseMapping.swift */; }; 31 | 6D02D78D1D5731F900CA76B9 /* SignInOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D78B1D5731F900CA76B9 /* SignInOperation.swift */; }; 32 | 6D02D78E1D5731F900CA76B9 /* SignUpOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D78C1D5731F900CA76B9 /* SignUpOperation.swift */; }; 33 | 6D02D7911D57320500CA76B9 /* SignInRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D78F1D57320500CA76B9 /* SignInRequest.swift */; }; 34 | 6D02D7921D57320500CA76B9 /* SignUpRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7901D57320500CA76B9 /* SignUpRequest.swift */; }; 35 | 6D02D7941D57325700CA76B9 /* ParsedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7931D57325700CA76B9 /* ParsedItem.swift */; }; 36 | 6D02D7971D57329600CA76B9 /* NSError+Failure.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7961D57329600CA76B9 /* NSError+Failure.swift */; }; 37 | 6D02D79A1D57346700CA76B9 /* NetworkLayerConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D02D7981D57346300CA76B9 /* NetworkLayerConfiguration.swift */; }; 38 | /* End PBXBuildFile section */ 39 | 40 | /* Begin PBXContainerItemProxy section */ 41 | 6D02D7621D5730EE00CA76B9 /* PBXContainerItemProxy */ = { 42 | isa = PBXContainerItemProxy; 43 | containerPortal = 6D02D73B1D5730D800CA76B9 /* Project object */; 44 | proxyType = 1; 45 | remoteGlobalIDString = 6D02D75C1D5730EE00CA76B9; 46 | remoteInfo = Network; 47 | }; 48 | /* End PBXContainerItemProxy section */ 49 | 50 | /* Begin PBXCopyFilesBuildPhase section */ 51 | 6D02D7691D5730EE00CA76B9 /* Embed Frameworks */ = { 52 | isa = PBXCopyFilesBuildPhase; 53 | buildActionMask = 2147483647; 54 | dstPath = ""; 55 | dstSubfolderSpec = 10; 56 | files = ( 57 | 6D02D7651D5730EE00CA76B9 /* Network.framework in Embed Frameworks */, 58 | ); 59 | name = "Embed Frameworks"; 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXCopyFilesBuildPhase section */ 63 | 64 | /* Begin PBXFileReference section */ 65 | 6D02D7431D5730D800CA76B9 /* NetworkLayerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetworkLayerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | 6D02D7461D5730D800CA76B9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 67 | 6D02D7481D5730D800CA76B9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 68 | 6D02D74B1D5730D800CA76B9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 69 | 6D02D74D1D5730D800CA76B9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 70 | 6D02D7501D5730D800CA76B9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 71 | 6D02D7521D5730D800CA76B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 72 | 6D02D75D1D5730EE00CA76B9 /* Network.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Network.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 73 | 6D02D75F1D5730EE00CA76B9 /* Network.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Network.h; sourceTree = ""; }; 74 | 6D02D7611D5730EE00CA76B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 75 | 6D02D7711D57317800CA76B9 /* BackendConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackendConfiguration.swift; sourceTree = ""; }; 76 | 6D02D7731D57318600CA76B9 /* BackendAPIRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackendAPIRequest.swift; sourceTree = ""; }; 77 | 6D02D7751D57318F00CA76B9 /* BackendService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackendService.swift; sourceTree = ""; }; 78 | 6D02D7771D57319400CA76B9 /* ServiceOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceOperation.swift; sourceTree = ""; }; 79 | 6D02D7791D5731B200CA76B9 /* ArrayResponseMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrayResponseMapper.swift; sourceTree = ""; }; 80 | 6D02D77B1D5731B600CA76B9 /* ResponseMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResponseMapper.swift; sourceTree = ""; }; 81 | 6D02D77D1D5731C500CA76B9 /* NetworkOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkOperation.swift; sourceTree = ""; }; 82 | 6D02D77E1D5731C500CA76B9 /* NetworkQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkQueue.swift; sourceTree = ""; }; 83 | 6D02D77F1D5731C500CA76B9 /* NetworkService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkService.swift; sourceTree = ""; }; 84 | 6D02D7831D5731D500CA76B9 /* SignInItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignInItem.swift; sourceTree = ""; }; 85 | 6D02D7851D5731DA00CA76B9 /* UserItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserItem.swift; sourceTree = ""; }; 86 | 6D02D7871D5731E600CA76B9 /* SignInResponseMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignInResponseMapper.swift; sourceTree = ""; }; 87 | 6D02D7881D5731E600CA76B9 /* UserResponseMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserResponseMapping.swift; sourceTree = ""; }; 88 | 6D02D78B1D5731F900CA76B9 /* SignInOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignInOperation.swift; sourceTree = ""; }; 89 | 6D02D78C1D5731F900CA76B9 /* SignUpOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpOperation.swift; sourceTree = ""; }; 90 | 6D02D78F1D57320500CA76B9 /* SignInRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignInRequest.swift; sourceTree = ""; }; 91 | 6D02D7901D57320500CA76B9 /* SignUpRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpRequest.swift; sourceTree = ""; }; 92 | 6D02D7931D57325700CA76B9 /* ParsedItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParsedItem.swift; sourceTree = ""; }; 93 | 6D02D7961D57329600CA76B9 /* NSError+Failure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSError+Failure.swift"; sourceTree = ""; }; 94 | 6D02D7981D57346300CA76B9 /* NetworkLayerConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkLayerConfiguration.swift; sourceTree = ""; }; 95 | /* End PBXFileReference section */ 96 | 97 | /* Begin PBXFrameworksBuildPhase section */ 98 | 6D02D7401D5730D800CA76B9 /* Frameworks */ = { 99 | isa = PBXFrameworksBuildPhase; 100 | buildActionMask = 2147483647; 101 | files = ( 102 | 6D02D7641D5730EE00CA76B9 /* Network.framework in Frameworks */, 103 | ); 104 | runOnlyForDeploymentPostprocessing = 0; 105 | }; 106 | 6D02D7591D5730EE00CA76B9 /* Frameworks */ = { 107 | isa = PBXFrameworksBuildPhase; 108 | buildActionMask = 2147483647; 109 | files = ( 110 | ); 111 | runOnlyForDeploymentPostprocessing = 0; 112 | }; 113 | /* End PBXFrameworksBuildPhase section */ 114 | 115 | /* Begin PBXGroup section */ 116 | 6D02D73A1D5730D800CA76B9 = { 117 | isa = PBXGroup; 118 | children = ( 119 | 6D02D7451D5730D800CA76B9 /* App */, 120 | 6D02D75E1D5730EE00CA76B9 /* Network */, 121 | 6D02D7441D5730D800CA76B9 /* Products */, 122 | ); 123 | sourceTree = ""; 124 | }; 125 | 6D02D7441D5730D800CA76B9 /* Products */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 6D02D7431D5730D800CA76B9 /* NetworkLayerExample.app */, 129 | 6D02D75D1D5730EE00CA76B9 /* Network.framework */, 130 | ); 131 | name = Products; 132 | sourceTree = ""; 133 | }; 134 | 6D02D7451D5730D800CA76B9 /* App */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 6D02D7461D5730D800CA76B9 /* AppDelegate.swift */, 138 | 6D02D7981D57346300CA76B9 /* NetworkLayerConfiguration.swift */, 139 | 6D02D7481D5730D800CA76B9 /* ViewController.swift */, 140 | 6D02D74A1D5730D800CA76B9 /* Main.storyboard */, 141 | 6D02D74D1D5730D800CA76B9 /* Assets.xcassets */, 142 | 6D02D74F1D5730D800CA76B9 /* LaunchScreen.storyboard */, 143 | 6D02D7521D5730D800CA76B9 /* Info.plist */, 144 | ); 145 | name = App; 146 | path = NetworkLayerExample; 147 | sourceTree = ""; 148 | }; 149 | 6D02D75E1D5730EE00CA76B9 /* Network */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | 6D02D76A1D57311300CA76B9 /* Backend */, 153 | 6D02D76B1D57311800CA76B9 /* Core Mapping */, 154 | 6D02D76C1D57312700CA76B9 /* Core Network */, 155 | 6D02D7951D57328A00CA76B9 /* Helpers */, 156 | 6D02D76D1D57313A00CA76B9 /* Items */, 157 | 6D02D76E1D57314C00CA76B9 /* Mappers */, 158 | 6D02D76F1D57315500CA76B9 /* Operations */, 159 | 6D02D7701D57315F00CA76B9 /* Request */, 160 | 6D02D75F1D5730EE00CA76B9 /* Network.h */, 161 | 6D02D7611D5730EE00CA76B9 /* Info.plist */, 162 | ); 163 | path = Network; 164 | sourceTree = ""; 165 | }; 166 | 6D02D76A1D57311300CA76B9 /* Backend */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | 6D02D7731D57318600CA76B9 /* BackendAPIRequest.swift */, 170 | 6D02D7711D57317800CA76B9 /* BackendConfiguration.swift */, 171 | 6D02D7751D57318F00CA76B9 /* BackendService.swift */, 172 | 6D02D7771D57319400CA76B9 /* ServiceOperation.swift */, 173 | ); 174 | name = Backend; 175 | sourceTree = ""; 176 | }; 177 | 6D02D76B1D57311800CA76B9 /* Core Mapping */ = { 178 | isa = PBXGroup; 179 | children = ( 180 | 6D02D7791D5731B200CA76B9 /* ArrayResponseMapper.swift */, 181 | 6D02D77B1D5731B600CA76B9 /* ResponseMapper.swift */, 182 | ); 183 | name = "Core Mapping"; 184 | sourceTree = ""; 185 | }; 186 | 6D02D76C1D57312700CA76B9 /* Core Network */ = { 187 | isa = PBXGroup; 188 | children = ( 189 | 6D02D77D1D5731C500CA76B9 /* NetworkOperation.swift */, 190 | 6D02D77E1D5731C500CA76B9 /* NetworkQueue.swift */, 191 | 6D02D77F1D5731C500CA76B9 /* NetworkService.swift */, 192 | ); 193 | name = "Core Network"; 194 | sourceTree = ""; 195 | }; 196 | 6D02D76D1D57313A00CA76B9 /* Items */ = { 197 | isa = PBXGroup; 198 | children = ( 199 | 6D02D7931D57325700CA76B9 /* ParsedItem.swift */, 200 | 6D02D7831D5731D500CA76B9 /* SignInItem.swift */, 201 | 6D02D7851D5731DA00CA76B9 /* UserItem.swift */, 202 | ); 203 | name = Items; 204 | sourceTree = ""; 205 | }; 206 | 6D02D76E1D57314C00CA76B9 /* Mappers */ = { 207 | isa = PBXGroup; 208 | children = ( 209 | 6D02D7871D5731E600CA76B9 /* SignInResponseMapper.swift */, 210 | 6D02D7881D5731E600CA76B9 /* UserResponseMapping.swift */, 211 | ); 212 | name = Mappers; 213 | sourceTree = ""; 214 | }; 215 | 6D02D76F1D57315500CA76B9 /* Operations */ = { 216 | isa = PBXGroup; 217 | children = ( 218 | 6D02D78B1D5731F900CA76B9 /* SignInOperation.swift */, 219 | 6D02D78C1D5731F900CA76B9 /* SignUpOperation.swift */, 220 | ); 221 | name = Operations; 222 | sourceTree = ""; 223 | }; 224 | 6D02D7701D57315F00CA76B9 /* Request */ = { 225 | isa = PBXGroup; 226 | children = ( 227 | 6D02D78F1D57320500CA76B9 /* SignInRequest.swift */, 228 | 6D02D7901D57320500CA76B9 /* SignUpRequest.swift */, 229 | ); 230 | name = Request; 231 | sourceTree = ""; 232 | }; 233 | 6D02D7951D57328A00CA76B9 /* Helpers */ = { 234 | isa = PBXGroup; 235 | children = ( 236 | 6D02D7961D57329600CA76B9 /* NSError+Failure.swift */, 237 | ); 238 | name = Helpers; 239 | sourceTree = ""; 240 | }; 241 | /* End PBXGroup section */ 242 | 243 | /* Begin PBXHeadersBuildPhase section */ 244 | 6D02D75A1D5730EE00CA76B9 /* Headers */ = { 245 | isa = PBXHeadersBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | 6D02D7601D5730EE00CA76B9 /* Network.h in Headers */, 249 | ); 250 | runOnlyForDeploymentPostprocessing = 0; 251 | }; 252 | /* End PBXHeadersBuildPhase section */ 253 | 254 | /* Begin PBXNativeTarget section */ 255 | 6D02D7421D5730D800CA76B9 /* NetworkLayerExample */ = { 256 | isa = PBXNativeTarget; 257 | buildConfigurationList = 6D02D7551D5730D800CA76B9 /* Build configuration list for PBXNativeTarget "NetworkLayerExample" */; 258 | buildPhases = ( 259 | 6D02D73F1D5730D800CA76B9 /* Sources */, 260 | 6D02D7401D5730D800CA76B9 /* Frameworks */, 261 | 6D02D7411D5730D800CA76B9 /* Resources */, 262 | 6D02D7691D5730EE00CA76B9 /* Embed Frameworks */, 263 | ); 264 | buildRules = ( 265 | ); 266 | dependencies = ( 267 | 6D02D7631D5730EE00CA76B9 /* PBXTargetDependency */, 268 | ); 269 | name = NetworkLayerExample; 270 | productName = NetworkLayerExample; 271 | productReference = 6D02D7431D5730D800CA76B9 /* NetworkLayerExample.app */; 272 | productType = "com.apple.product-type.application"; 273 | }; 274 | 6D02D75C1D5730EE00CA76B9 /* Network */ = { 275 | isa = PBXNativeTarget; 276 | buildConfigurationList = 6D02D7661D5730EE00CA76B9 /* Build configuration list for PBXNativeTarget "Network" */; 277 | buildPhases = ( 278 | 6D02D7581D5730EE00CA76B9 /* Sources */, 279 | 6D02D7591D5730EE00CA76B9 /* Frameworks */, 280 | 6D02D75A1D5730EE00CA76B9 /* Headers */, 281 | 6D02D75B1D5730EE00CA76B9 /* Resources */, 282 | ); 283 | buildRules = ( 284 | ); 285 | dependencies = ( 286 | ); 287 | name = Network; 288 | productName = Network; 289 | productReference = 6D02D75D1D5730EE00CA76B9 /* Network.framework */; 290 | productType = "com.apple.product-type.framework"; 291 | }; 292 | /* End PBXNativeTarget section */ 293 | 294 | /* Begin PBXProject section */ 295 | 6D02D73B1D5730D800CA76B9 /* Project object */ = { 296 | isa = PBXProject; 297 | attributes = { 298 | LastSwiftUpdateCheck = 0730; 299 | LastUpgradeCheck = 0800; 300 | ORGANIZATIONNAME = "Tomasz Szulc"; 301 | TargetAttributes = { 302 | 6D02D7421D5730D800CA76B9 = { 303 | CreatedOnToolsVersion = 7.3.1; 304 | LastSwiftMigration = 0800; 305 | }; 306 | 6D02D75C1D5730EE00CA76B9 = { 307 | CreatedOnToolsVersion = 7.3.1; 308 | LastSwiftMigration = 0800; 309 | }; 310 | }; 311 | }; 312 | buildConfigurationList = 6D02D73E1D5730D800CA76B9 /* Build configuration list for PBXProject "NetworkLayerExample" */; 313 | compatibilityVersion = "Xcode 3.2"; 314 | developmentRegion = English; 315 | hasScannedForEncodings = 0; 316 | knownRegions = ( 317 | en, 318 | Base, 319 | ); 320 | mainGroup = 6D02D73A1D5730D800CA76B9; 321 | productRefGroup = 6D02D7441D5730D800CA76B9 /* Products */; 322 | projectDirPath = ""; 323 | projectRoot = ""; 324 | targets = ( 325 | 6D02D7421D5730D800CA76B9 /* NetworkLayerExample */, 326 | 6D02D75C1D5730EE00CA76B9 /* Network */, 327 | ); 328 | }; 329 | /* End PBXProject section */ 330 | 331 | /* Begin PBXResourcesBuildPhase section */ 332 | 6D02D7411D5730D800CA76B9 /* Resources */ = { 333 | isa = PBXResourcesBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | 6D02D7511D5730D800CA76B9 /* LaunchScreen.storyboard in Resources */, 337 | 6D02D74E1D5730D800CA76B9 /* Assets.xcassets in Resources */, 338 | 6D02D74C1D5730D800CA76B9 /* Main.storyboard in Resources */, 339 | ); 340 | runOnlyForDeploymentPostprocessing = 0; 341 | }; 342 | 6D02D75B1D5730EE00CA76B9 /* Resources */ = { 343 | isa = PBXResourcesBuildPhase; 344 | buildActionMask = 2147483647; 345 | files = ( 346 | ); 347 | runOnlyForDeploymentPostprocessing = 0; 348 | }; 349 | /* End PBXResourcesBuildPhase section */ 350 | 351 | /* Begin PBXSourcesBuildPhase section */ 352 | 6D02D73F1D5730D800CA76B9 /* Sources */ = { 353 | isa = PBXSourcesBuildPhase; 354 | buildActionMask = 2147483647; 355 | files = ( 356 | 6D02D7491D5730D800CA76B9 /* ViewController.swift in Sources */, 357 | 6D02D7471D5730D800CA76B9 /* AppDelegate.swift in Sources */, 358 | 6D02D79A1D57346700CA76B9 /* NetworkLayerConfiguration.swift in Sources */, 359 | ); 360 | runOnlyForDeploymentPostprocessing = 0; 361 | }; 362 | 6D02D7581D5730EE00CA76B9 /* Sources */ = { 363 | isa = PBXSourcesBuildPhase; 364 | buildActionMask = 2147483647; 365 | files = ( 366 | 6D02D78A1D5731E600CA76B9 /* UserResponseMapping.swift in Sources */, 367 | 6D02D7721D57317800CA76B9 /* BackendConfiguration.swift in Sources */, 368 | 6D02D7891D5731E600CA76B9 /* SignInResponseMapper.swift in Sources */, 369 | 6D02D7761D57318F00CA76B9 /* BackendService.swift in Sources */, 370 | 6D02D7741D57318600CA76B9 /* BackendAPIRequest.swift in Sources */, 371 | 6D02D77C1D5731B600CA76B9 /* ResponseMapper.swift in Sources */, 372 | 6D02D7821D5731C500CA76B9 /* NetworkService.swift in Sources */, 373 | 6D02D78E1D5731F900CA76B9 /* SignUpOperation.swift in Sources */, 374 | 6D02D7921D57320500CA76B9 /* SignUpRequest.swift in Sources */, 375 | 6D02D7811D5731C500CA76B9 /* NetworkQueue.swift in Sources */, 376 | 6D02D7781D57319400CA76B9 /* ServiceOperation.swift in Sources */, 377 | 6D02D78D1D5731F900CA76B9 /* SignInOperation.swift in Sources */, 378 | 6D02D7861D5731DA00CA76B9 /* UserItem.swift in Sources */, 379 | 6D02D77A1D5731B200CA76B9 /* ArrayResponseMapper.swift in Sources */, 380 | 6D02D7841D5731D500CA76B9 /* SignInItem.swift in Sources */, 381 | 6D02D7971D57329600CA76B9 /* NSError+Failure.swift in Sources */, 382 | 6D02D7801D5731C500CA76B9 /* NetworkOperation.swift in Sources */, 383 | 6D02D7911D57320500CA76B9 /* SignInRequest.swift in Sources */, 384 | 6D02D7941D57325700CA76B9 /* ParsedItem.swift in Sources */, 385 | ); 386 | runOnlyForDeploymentPostprocessing = 0; 387 | }; 388 | /* End PBXSourcesBuildPhase section */ 389 | 390 | /* Begin PBXTargetDependency section */ 391 | 6D02D7631D5730EE00CA76B9 /* PBXTargetDependency */ = { 392 | isa = PBXTargetDependency; 393 | target = 6D02D75C1D5730EE00CA76B9 /* Network */; 394 | targetProxy = 6D02D7621D5730EE00CA76B9 /* PBXContainerItemProxy */; 395 | }; 396 | /* End PBXTargetDependency section */ 397 | 398 | /* Begin PBXVariantGroup section */ 399 | 6D02D74A1D5730D800CA76B9 /* Main.storyboard */ = { 400 | isa = PBXVariantGroup; 401 | children = ( 402 | 6D02D74B1D5730D800CA76B9 /* Base */, 403 | ); 404 | name = Main.storyboard; 405 | sourceTree = ""; 406 | }; 407 | 6D02D74F1D5730D800CA76B9 /* LaunchScreen.storyboard */ = { 408 | isa = PBXVariantGroup; 409 | children = ( 410 | 6D02D7501D5730D800CA76B9 /* Base */, 411 | ); 412 | name = LaunchScreen.storyboard; 413 | sourceTree = ""; 414 | }; 415 | /* End PBXVariantGroup section */ 416 | 417 | /* Begin XCBuildConfiguration section */ 418 | 6D02D7531D5730D800CA76B9 /* Debug */ = { 419 | isa = XCBuildConfiguration; 420 | buildSettings = { 421 | ALWAYS_SEARCH_USER_PATHS = NO; 422 | CLANG_ANALYZER_NONNULL = YES; 423 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 424 | CLANG_CXX_LIBRARY = "libc++"; 425 | CLANG_ENABLE_MODULES = YES; 426 | CLANG_ENABLE_OBJC_ARC = YES; 427 | CLANG_WARN_BOOL_CONVERSION = YES; 428 | CLANG_WARN_CONSTANT_CONVERSION = YES; 429 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 430 | CLANG_WARN_EMPTY_BODY = YES; 431 | CLANG_WARN_ENUM_CONVERSION = YES; 432 | CLANG_WARN_INFINITE_RECURSION = YES; 433 | CLANG_WARN_INT_CONVERSION = YES; 434 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 435 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 436 | CLANG_WARN_UNREACHABLE_CODE = YES; 437 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 438 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 439 | COPY_PHASE_STRIP = NO; 440 | DEBUG_INFORMATION_FORMAT = dwarf; 441 | ENABLE_STRICT_OBJC_MSGSEND = YES; 442 | ENABLE_TESTABILITY = YES; 443 | GCC_C_LANGUAGE_STANDARD = gnu99; 444 | GCC_DYNAMIC_NO_PIC = NO; 445 | GCC_NO_COMMON_BLOCKS = YES; 446 | GCC_OPTIMIZATION_LEVEL = 0; 447 | GCC_PREPROCESSOR_DEFINITIONS = ( 448 | "DEBUG=1", 449 | "$(inherited)", 450 | ); 451 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 452 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 453 | GCC_WARN_UNDECLARED_SELECTOR = YES; 454 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 455 | GCC_WARN_UNUSED_FUNCTION = YES; 456 | GCC_WARN_UNUSED_VARIABLE = YES; 457 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 458 | MTL_ENABLE_DEBUG_INFO = YES; 459 | ONLY_ACTIVE_ARCH = YES; 460 | SDKROOT = iphoneos; 461 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 462 | }; 463 | name = Debug; 464 | }; 465 | 6D02D7541D5730D800CA76B9 /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | ALWAYS_SEARCH_USER_PATHS = NO; 469 | CLANG_ANALYZER_NONNULL = YES; 470 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 471 | CLANG_CXX_LIBRARY = "libc++"; 472 | CLANG_ENABLE_MODULES = YES; 473 | CLANG_ENABLE_OBJC_ARC = YES; 474 | CLANG_WARN_BOOL_CONVERSION = YES; 475 | CLANG_WARN_CONSTANT_CONVERSION = YES; 476 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 477 | CLANG_WARN_EMPTY_BODY = YES; 478 | CLANG_WARN_ENUM_CONVERSION = YES; 479 | CLANG_WARN_INFINITE_RECURSION = YES; 480 | CLANG_WARN_INT_CONVERSION = YES; 481 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 482 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 483 | CLANG_WARN_UNREACHABLE_CODE = YES; 484 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 485 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 486 | COPY_PHASE_STRIP = NO; 487 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 488 | ENABLE_NS_ASSERTIONS = NO; 489 | ENABLE_STRICT_OBJC_MSGSEND = YES; 490 | GCC_C_LANGUAGE_STANDARD = gnu99; 491 | GCC_NO_COMMON_BLOCKS = YES; 492 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 493 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 494 | GCC_WARN_UNDECLARED_SELECTOR = YES; 495 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 496 | GCC_WARN_UNUSED_FUNCTION = YES; 497 | GCC_WARN_UNUSED_VARIABLE = YES; 498 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 499 | MTL_ENABLE_DEBUG_INFO = NO; 500 | SDKROOT = iphoneos; 501 | VALIDATE_PRODUCT = YES; 502 | }; 503 | name = Release; 504 | }; 505 | 6D02D7561D5730D800CA76B9 /* Debug */ = { 506 | isa = XCBuildConfiguration; 507 | buildSettings = { 508 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 509 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 510 | INFOPLIST_FILE = NetworkLayerExample/Info.plist; 511 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 512 | PRODUCT_BUNDLE_IDENTIFIER = com.tomaszszulc.NetworkLayerExample; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | SWIFT_VERSION = 3.0; 515 | }; 516 | name = Debug; 517 | }; 518 | 6D02D7571D5730D800CA76B9 /* Release */ = { 519 | isa = XCBuildConfiguration; 520 | buildSettings = { 521 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 522 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 523 | INFOPLIST_FILE = NetworkLayerExample/Info.plist; 524 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 525 | PRODUCT_BUNDLE_IDENTIFIER = com.tomaszszulc.NetworkLayerExample; 526 | PRODUCT_NAME = "$(TARGET_NAME)"; 527 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 528 | SWIFT_VERSION = 3.0; 529 | }; 530 | name = Release; 531 | }; 532 | 6D02D7671D5730EE00CA76B9 /* Debug */ = { 533 | isa = XCBuildConfiguration; 534 | buildSettings = { 535 | CLANG_ENABLE_MODULES = YES; 536 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 537 | CURRENT_PROJECT_VERSION = 1; 538 | DEFINES_MODULE = YES; 539 | DYLIB_COMPATIBILITY_VERSION = 1; 540 | DYLIB_CURRENT_VERSION = 1; 541 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 542 | INFOPLIST_FILE = Network/Info.plist; 543 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 544 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 545 | PRODUCT_BUNDLE_IDENTIFIER = com.tomaszszulc.networklayerexample.Network; 546 | PRODUCT_NAME = "$(TARGET_NAME)"; 547 | SKIP_INSTALL = YES; 548 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 549 | SWIFT_VERSION = 3.0; 550 | TARGETED_DEVICE_FAMILY = "1,2"; 551 | VERSIONING_SYSTEM = "apple-generic"; 552 | VERSION_INFO_PREFIX = ""; 553 | }; 554 | name = Debug; 555 | }; 556 | 6D02D7681D5730EE00CA76B9 /* Release */ = { 557 | isa = XCBuildConfiguration; 558 | buildSettings = { 559 | CLANG_ENABLE_MODULES = YES; 560 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 561 | CURRENT_PROJECT_VERSION = 1; 562 | DEFINES_MODULE = YES; 563 | DYLIB_COMPATIBILITY_VERSION = 1; 564 | DYLIB_CURRENT_VERSION = 1; 565 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 566 | INFOPLIST_FILE = Network/Info.plist; 567 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 568 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 569 | PRODUCT_BUNDLE_IDENTIFIER = com.tomaszszulc.networklayerexample.Network; 570 | PRODUCT_NAME = "$(TARGET_NAME)"; 571 | SKIP_INSTALL = YES; 572 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 573 | SWIFT_VERSION = 3.0; 574 | TARGETED_DEVICE_FAMILY = "1,2"; 575 | VERSIONING_SYSTEM = "apple-generic"; 576 | VERSION_INFO_PREFIX = ""; 577 | }; 578 | name = Release; 579 | }; 580 | /* End XCBuildConfiguration section */ 581 | 582 | /* Begin XCConfigurationList section */ 583 | 6D02D73E1D5730D800CA76B9 /* Build configuration list for PBXProject "NetworkLayerExample" */ = { 584 | isa = XCConfigurationList; 585 | buildConfigurations = ( 586 | 6D02D7531D5730D800CA76B9 /* Debug */, 587 | 6D02D7541D5730D800CA76B9 /* Release */, 588 | ); 589 | defaultConfigurationIsVisible = 0; 590 | defaultConfigurationName = Release; 591 | }; 592 | 6D02D7551D5730D800CA76B9 /* Build configuration list for PBXNativeTarget "NetworkLayerExample" */ = { 593 | isa = XCConfigurationList; 594 | buildConfigurations = ( 595 | 6D02D7561D5730D800CA76B9 /* Debug */, 596 | 6D02D7571D5730D800CA76B9 /* Release */, 597 | ); 598 | defaultConfigurationIsVisible = 0; 599 | defaultConfigurationName = Release; 600 | }; 601 | 6D02D7661D5730EE00CA76B9 /* Build configuration list for PBXNativeTarget "Network" */ = { 602 | isa = XCConfigurationList; 603 | buildConfigurations = ( 604 | 6D02D7671D5730EE00CA76B9 /* Debug */, 605 | 6D02D7681D5730EE00CA76B9 /* Release */, 606 | ); 607 | defaultConfigurationIsVisible = 0; 608 | defaultConfigurationName = Release; 609 | }; 610 | /* End XCConfigurationList section */ 611 | }; 612 | rootObject = 6D02D73B1D5730D800CA76B9 /* Project object */; 613 | } 614 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/project.xcworkspace/xcuserdata/chrisbyatt.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/NetworkLayerExample.xcodeproj/project.xcworkspace/xcuserdata/chrisbyatt.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/project.xcworkspace/xcuserdata/tomkowz.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/NetworkLayerExample.xcodeproj/project.xcworkspace/xcuserdata/tomkowz.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/alessioroberto.xcuserdatad/xcschemes/Network.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/alessioroberto.xcuserdatad/xcschemes/NetworkLayerExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/chrisbyatt.xcuserdatad/xcschemes/Network.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/chrisbyatt.xcuserdatad/xcschemes/NetworkLayerExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/chrisbyatt.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Network.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | NetworkLayerExample.xcscheme 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 6D02D7421D5730D800CA76B9 21 | 22 | primary 23 | 24 | 25 | 6D02D75C1D5730EE00CA76B9 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/tomkowz.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/tomkowz.xcuserdatad/xcschemes/Network.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/tomkowz.xcuserdatad/xcschemes/NetworkLayerExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /NetworkLayerExample.xcodeproj/xcuserdata/tomkowz.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Network.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | NetworkLayerExample.xcscheme 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 6D02D7421D5730D800CA76B9 21 | 22 | primary 23 | 24 | 25 | 6D02D75C1D5730EE00CA76B9 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /NetworkLayerExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Network 2 | import UIKit 3 | 4 | @UIApplicationMain 5 | class AppDelegate: UIResponder, UIApplicationDelegate { 6 | 7 | var window: UIWindow? 8 | 9 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { 10 | NetworkLayerConfiguration.setup() 11 | Demo.performSignUp() 12 | return true 13 | } 14 | } 15 | 16 | // Not working because there is no real server configured in 17 | // `NetworkLayerConfiguration` class. 18 | class Demo { 19 | 20 | class func performSignUp() { 21 | let user = UserItem(firstName: "Tomasz", lastName: "Szulc", 22 | email: "mail@szulctomasz.com", 23 | phoneNumber: "+48788434094") 24 | let signUpOp = SignUpOperation(user: user, password: "?8TMx6avi6}2xw&7") 25 | signUpOp.success = { item in 26 | print("User id is \(item.uniqueId)") 27 | } 28 | 29 | signUpOp.failure = { error in print(error.localizedDescription) } 30 | NetworkQueue.shared.addOperation(signUpOp) 31 | } 32 | 33 | class func performSignIn() { 34 | let signInOp = SignInOperation(email: "mail@szulctomasz.com", password: "?8TMx6avi6}2xw&7") 35 | signInOp.success = { item in 36 | print("token = \(item.token)") 37 | print("user id = \(item.uniqueId)") 38 | } 39 | 40 | signInOp.failure = { error in print(error.localizedDescription) } 41 | NetworkQueue.shared.addOperation(signInOp) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /NetworkLayerExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /NetworkLayerExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NetworkLayerExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /NetworkLayerExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /NetworkLayerExample/NetworkLayerConfiguration.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Network 3 | 4 | class NetworkLayerConfiguration { 5 | 6 | class func setup() { 7 | // Backend Configuration 8 | let url = URL(string: "https://fake.url")! 9 | let conf = BackendConfiguration(baseURL: url) 10 | BackendConfiguration.shared = conf 11 | 12 | // Network Queue 13 | NetworkQueue.shared = NetworkQueue() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NetworkLayerExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class ViewController: UIViewController {} 4 | 5 | -------------------------------------------------------------------------------- /Templates/Network/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/.DS_Store -------------------------------------------------------------------------------- /Templates/Network/Network Operation.xctemplate/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Network Operation.xctemplate/.DS_Store -------------------------------------------------------------------------------- /Templates/Network/Network Operation.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Network Operation.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/Network/Network Operation.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Network Operation.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/Network/Network Operation.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Platforms 6 | 7 | com.apple.platform.iphoneos 8 | 9 | Kind 10 | Xcode.IDEFoundation.TextSubstitutionFileTemplateKind 11 | Description 12 | A template for a network request. 13 | Summary 14 | A template for a network request. 15 | SortOrder 16 | 11 17 | DefaultCompletionName 18 | Operation 19 | MainTemplateFile 20 | ___FILEBASENAME___.swift 21 | 22 | 23 | -------------------------------------------------------------------------------- /Templates/Network/Network Operation.xctemplate/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import Foundation 10 | 11 | public class ___FILEBASENAMEASIDENTIFIER___: ServiceOperation { 12 | 13 | private let request: <#BackendAPIRequest#> 14 | 15 | public var success: ((UserItem) -> Void)? 16 | public var failure: ((NSError) -> Void)? 17 | 18 | // public init(email: String, password: String) { 19 | // request = <#BackendAPIRequest()#> 20 | // super.init() 21 | // } 22 | 23 | public override func start() { 24 | super.start() 25 | service.request(request, success: handleSuccess, failure: handleFailure) 26 | } 27 | 28 | private func handleSuccess(_ response: AnyObject?) { 29 | do { 30 | let item = try SignInResponseMapper.process(response) 31 | self.success?(item) 32 | self.finish() 33 | } catch { 34 | handleFailure(NSError.cannotParseResponse()) 35 | } 36 | } 37 | 38 | private func handleFailure(_ error: NSError) { 39 | self.failure?(error) 40 | self.finish() 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Templates/Network/Network Request.xctemplate/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Network Request.xctemplate/.DS_Store -------------------------------------------------------------------------------- /Templates/Network/Network Request.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Network Request.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/Network/Network Request.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Network Request.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/Network/Network Request.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Platforms 6 | 7 | com.apple.platform.iphoneos 8 | 9 | Kind 10 | Xcode.IDEFoundation.TextSubstitutionFileTemplateKind 11 | Description 12 | A template for a network request. 13 | Summary 14 | A template for a network request. 15 | SortOrder 16 | 11 17 | DefaultCompletionName 18 | Request 19 | MainTemplateFile 20 | ___FILEBASENAME___.swift 21 | 22 | 23 | -------------------------------------------------------------------------------- /Templates/Network/Network Request.xctemplate/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import Foundation 10 | 11 | class ___FILEBASENAMEASIDENTIFIER___: BackendAPIRequest { 12 | 13 | // Create private variables for parameters required for request 14 | // private let email: String 15 | // private let password: String 16 | 17 | // init(email: String, password: String) { 18 | // self.email = email 19 | // self.password = password 20 | // } 21 | 22 | var endpoint: String { 23 | return <#String#> 24 | } 25 | 26 | var method: NetworkService.Method { 27 | return <#NetworkService.Method#> 28 | } 29 | 30 | var query: NetworkService.QueryType { 31 | return <#NetworkService.QueryType#> 32 | } 33 | 34 | var parameters: [String : Any]? { 35 | return [ 36 | // "email": email, 37 | // "password": password 38 | ] 39 | } 40 | 41 | var headers: [String : String]? { 42 | return defaultJSONHeaders() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Templates/Network/Response Mapper.xctemplate/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Response Mapper.xctemplate/.DS_Store -------------------------------------------------------------------------------- /Templates/Network/Response Mapper.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Response Mapper.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Templates/Network/Response Mapper.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomkowz/NetworkLayerExample/f31e35e8def9a724db5ec81c90ad35638e899410/Templates/Network/Response Mapper.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Templates/Network/Response Mapper.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Platforms 6 | 7 | com.apple.platform.iphoneos 8 | 9 | Kind 10 | Xcode.IDEFoundation.TextSubstitutionFileTemplateKind 11 | Description 12 | A template for a response mapper. 13 | Summary 14 | A template for a response mapper. 15 | SortOrder 16 | 11 17 | DefaultCompletionName 18 | ResponseMapper 19 | MainTemplateFile 20 | ___FILEBASENAME___.swift 21 | 22 | 23 | -------------------------------------------------------------------------------- /Templates/Network/Response Mapper.xctemplate/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | //___COPYRIGHT___ 7 | // 8 | 9 | import Foundation 10 | 11 | final class ___FILEBASENAMEASIDENTIFIER___: ResponseMapper<<#ParsedItem#>>, ResponseMapperProtocol { 12 | 13 | static func process(_ obj: AnyObject?) throws -> UserItem { 14 | return try process(obj, parse: { json in 15 | let object = json["object"] as? String 16 | 17 | if let object = object { 18 | return <#ParsedItem()#> 19 | } 20 | return nil 21 | }) 22 | } 23 | } 24 | --------------------------------------------------------------------------------