diff --git a/AlamoRecord.podspec b/AlamoRecord.podspec index 7cc72d5..eb77f79 100644 --- a/AlamoRecord.podspec +++ b/AlamoRecord.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'AlamoRecord' - s.version = '1.3.0' + s.version = '1.3.1' s.summary = 'An elegant Alamofire wrapper inspired by ActiveRecord.' s.description = <<-DESC AlamoRecord is a powerful yet simple framework that eliminates the often complex networking layer that exists between your networking framework and your application. AlamoRecord uses the power of AlamoFire, AlamofireObjectMapper and the concepts behind the ActiveRecord pattern to create a networking layer that makes interacting with your API easier than ever. diff --git a/AlamoRecord/Classes/AlamoRecordObject.swift b/AlamoRecord/Classes/AlamoRecordObject.swift index e7b952b..ba1695f 100644 --- a/AlamoRecord/Classes/AlamoRecordObject.swift +++ b/AlamoRecord/Classes/AlamoRecordObject.swift @@ -20,7 +20,7 @@ import Alamofire import AlamofireObjectMapper import ObjectMapper -open class AlamoRecordObject: NSObject, Mappable { +open class AlamoRecordObject: NSObject, Mappable { /// Key to encode/decode the id variable private let idKey: String = "id" diff --git a/AlamoRecord/Classes/URLProtocol.swift b/AlamoRecord/Classes/AlamoRecordURL.swift similarity index 94% rename from AlamoRecord/Classes/URLProtocol.swift rename to AlamoRecord/Classes/AlamoRecordURL.swift index da0d102..e240193 100644 --- a/AlamoRecord/Classes/URLProtocol.swift +++ b/AlamoRecord/Classes/AlamoRecordURL.swift @@ -16,10 +16,11 @@ */ -public protocol URLProtocol { +public protocol AlamoRecordURL { /// The entire url of a particular instance. Example: https://www.domain.com/objects/id var absolute: String { get } init(url: String) + init(url: String, isCompletePath: Bool) } diff --git a/AlamoRecord/Classes/RequestManager.swift b/AlamoRecord/Classes/RequestManager.swift index c76d73d..606e137 100644 --- a/AlamoRecord/Classes/RequestManager.swift +++ b/AlamoRecord/Classes/RequestManager.swift @@ -20,7 +20,7 @@ import Alamofire import AlamofireObjectMapper import ObjectMapper -open class RequestManager: NSObject { +open class RequestManager: NSObject { public typealias Parameters = [String: Any] @@ -48,7 +48,7 @@ open class RequestManager: NSObject /** Makes a request to the given URL. Each request goes through this method first. - parameter method: The HTTP method - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter encoding: The parameter encoding. `URLEncoding.default` by default - parameter headers: The HTTP headers. `nil` by default @@ -72,7 +72,7 @@ open class RequestManager: NSObject /** Makes a request to the given URL - parameter method: The HTTP method - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter encoding: The parameter encoding. `URLEncoding.default` by default - parameter headers: The HTTP headers. `nil` by default @@ -121,7 +121,7 @@ open class RequestManager: NSObject /** Makes a request and maps an object that conforms to the Mappable protocol - parameter method: The HTTP method - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter encoding: The parameter encoding. `URLEncoding.default` by default. @@ -159,7 +159,7 @@ open class RequestManager: NSObject /** Makes a request and maps an array of objects that conform to the Mappable protocol - parameter method: The HTTP method - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter encoding: The parameter encoding. `URLEncoding.default` by default. @@ -224,7 +224,7 @@ open class RequestManager: NSObject /** Makes a request and maps an AlamoRecordObject - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter encoding: The parameter encoding. `URLEncoding.default` by default. @@ -253,7 +253,7 @@ open class RequestManager: NSObject /** Makes a request and maps an array of AlamoRecordObjects - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter encoding: The parameter encoding. `URLEncoding.default` by default. @@ -308,7 +308,7 @@ open class RequestManager: NSObject /** Makes a request and creates an AlamoRecordObject - - paramter url: The URL that conforms to URLProtocol + - paramter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter encoding: The parameter encoding. `URLEncoding.default` by default. @@ -390,7 +390,7 @@ open class RequestManager: NSObject /** Makes a request and updates an AlamoRecordObject - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter encoding: The parameter encoding. `URLEncoding.default` by default. @@ -419,7 +419,7 @@ open class RequestManager: NSObject /** Makes a request and updates an AlamoRecordObject - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter encoding: The parameter encoding. `URLEncoding.default` by default. @@ -446,7 +446,7 @@ open class RequestManager: NSObject /** Makes a request and destroys an AlamoRecordObject - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter parameters: The parameters. `nil` by default - parameter encoding: The parameter encoding. `URLEncoding.default` by default. - parameter headers: The HTTP headers. `nil` by default. @@ -473,7 +473,7 @@ open class RequestManager: NSObject /** Makes an upload request - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter keyPath: The keyPath to use when deserializing the JSON. `nil` by default. - parameter headers: The HTTP headers. `nil` by default. - parameter multipartFormData: The data to append @@ -511,7 +511,7 @@ open class RequestManager: NSObject /** Makes a download request - - parameter url: The URL that conforms to URLProtocol + - parameter url: The URL that conforms to AlamoRecordURL - parameter destination: The destination to download the file to. If it is nil, then a default one will be assigned. - parameter progress: The progress handler of the download request - parameter success: The block to execute if the request succeeds diff --git a/Example/AlamoRecord.xcodeproj/project.pbxproj b/Example/AlamoRecord.xcodeproj/project.pbxproj index 19f1e28..e30fb27 100644 --- a/Example/AlamoRecord.xcodeproj/project.pbxproj +++ b/Example/AlamoRecord.xcodeproj/project.pbxproj @@ -28,13 +28,14 @@ 5C94C3061F08707F00762CFC /* RequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2F81F08707F00762CFC /* RequestManager.swift */; }; 5C94C3081F08707F00762CFC /* RequestObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2F91F08707F00762CFC /* RequestObserver.swift */; }; 5C94C30A1F08707F00762CFC /* StatusCodeObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2FA1F08707F00762CFC /* StatusCodeObserver.swift */; }; - 5C94C30C1F08707F00762CFC /* URLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2FB1F08707F00762CFC /* URLProtocol.swift */; }; 5C96D98D1F0ECC39005FF25E /* PostsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C96D98C1F0ECC39005FF25E /* PostsModel.swift */; }; 5C96D98F1F0ECC43005FF25E /* PostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C96D98E1F0ECC43005FF25E /* PostsView.swift */; }; 5C96D9911F0ECC4E005FF25E /* PostsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C96D9901F0ECC4E005FF25E /* PostsViewController.swift */; }; 5C96D9931F0ED260005FF25E /* PostCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C96D9921F0ED260005FF25E /* PostCell.swift */; }; 5C96D9951F0ED316005FF25E /* BaseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C96D9941F0ED316005FF25E /* BaseTableViewCell.swift */; }; 5C96D9971F0EDB71005FF25E /* ColorsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C96D9961F0EDB71005FF25E /* ColorsExtension.swift */; }; + 5CA0A94F21825DA3002BA69A /* AlamoRecordURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CA0A94E21825DA3002BA69A /* AlamoRecordURL.swift */; }; + 5CA0A95021825DA3002BA69A /* AlamoRecordURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CA0A94E21825DA3002BA69A /* AlamoRecordURL.swift */; }; 5CCB20951F17064E0027BA56 /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CE6C8151F102C5200965235 /* Comment.swift */; }; 5CCB20961F1706880027BA56 /* AlamoRecordError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C86407E1F09D5E6001E8320 /* AlamoRecordError.swift */; }; 5CCB20971F1706880027BA56 /* AlamoRecordObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2F31F08707F00762CFC /* AlamoRecordObject.swift */; }; @@ -44,7 +45,6 @@ 5CCB209B1F1706880027BA56 /* RequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2F81F08707F00762CFC /* RequestManager.swift */; }; 5CCB209C1F1706880027BA56 /* RequestObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2F91F08707F00762CFC /* RequestObserver.swift */; }; 5CCB209D1F1706880027BA56 /* StatusCodeObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2FA1F08707F00762CFC /* StatusCodeObserver.swift */; }; - 5CCB209E1F1706880027BA56 /* URLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C94C2FB1F08707F00762CFC /* URLProtocol.swift */; }; 5CE6C8101F102B6900965235 /* CommentsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CE6C80F1F102B6900965235 /* CommentsModel.swift */; }; 5CE6C8121F102B7E00965235 /* CommentsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CE6C8111F102B7E00965235 /* CommentsViewController.swift */; }; 5CE6C8141F102B8F00965235 /* CommentsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CE6C8131F102B8F00965235 /* CommentsView.swift */; }; @@ -90,13 +90,13 @@ 5C94C2F81F08707F00762CFC /* RequestManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RequestManager.swift; path = ../../AlamoRecord/Classes/RequestManager.swift; sourceTree = ""; }; 5C94C2F91F08707F00762CFC /* RequestObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RequestObserver.swift; path = ../../AlamoRecord/Classes/RequestObserver.swift; sourceTree = ""; }; 5C94C2FA1F08707F00762CFC /* StatusCodeObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StatusCodeObserver.swift; path = ../../AlamoRecord/Classes/StatusCodeObserver.swift; sourceTree = ""; }; - 5C94C2FB1F08707F00762CFC /* URLProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = URLProtocol.swift; path = ../../AlamoRecord/Classes/URLProtocol.swift; sourceTree = ""; }; 5C96D98C1F0ECC39005FF25E /* PostsModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostsModel.swift; sourceTree = ""; }; 5C96D98E1F0ECC43005FF25E /* PostsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostsView.swift; sourceTree = ""; }; 5C96D9901F0ECC4E005FF25E /* PostsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostsViewController.swift; sourceTree = ""; }; 5C96D9921F0ED260005FF25E /* PostCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostCell.swift; sourceTree = ""; }; 5C96D9941F0ED316005FF25E /* BaseTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTableViewCell.swift; sourceTree = ""; }; 5C96D9961F0EDB71005FF25E /* ColorsExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorsExtension.swift; sourceTree = ""; }; + 5CA0A94E21825DA3002BA69A /* AlamoRecordURL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AlamoRecordURL.swift; path = ../../AlamoRecord/Classes/AlamoRecordURL.swift; sourceTree = ""; }; 5CE6C80F1F102B6900965235 /* CommentsModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentsModel.swift; sourceTree = ""; }; 5CE6C8111F102B7E00965235 /* CommentsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentsViewController.swift; sourceTree = ""; }; 5CE6C8131F102B8F00965235 /* CommentsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommentsView.swift; sourceTree = ""; }; @@ -207,13 +207,13 @@ children = ( 5C86407E1F09D5E6001E8320 /* AlamoRecordError.swift */, 5C94C2F31F08707F00762CFC /* AlamoRecordObject.swift */, + 5CA0A94E21825DA3002BA69A /* AlamoRecordURL.swift */, 5C94C2F41F08707F00762CFC /* Configuration.swift */, 5C94C2F51F08707F00762CFC /* ErrorParser.swift */, 5C94C2F71F08707F00762CFC /* Logger.swift */, 5C94C2F81F08707F00762CFC /* RequestManager.swift */, 5C94C2F91F08707F00762CFC /* RequestObserver.swift */, 5C94C2FA1F08707F00762CFC /* StatusCodeObserver.swift */, - 5C94C2FB1F08707F00762CFC /* URLProtocol.swift */, ); name = Source; sourceTree = ""; @@ -499,8 +499,8 @@ 5C6347081F0B088200158A80 /* AlamoRecordTests.swift in Sources */, 5CCB20991F1706880027BA56 /* ErrorParser.swift in Sources */, 5C63470D1F0B09B900158A80 /* ApplicationRequestManager.swift in Sources */, + 5CA0A95021825DA3002BA69A /* AlamoRecordURL.swift in Sources */, 5CCB20961F1706880027BA56 /* AlamoRecordError.swift in Sources */, - 5CCB209E1F1706880027BA56 /* URLProtocol.swift in Sources */, 5C6347091F0B088200158A80 /* Post.swift in Sources */, 5C63470A1F0B088200158A80 /* ApplicationURL.swift in Sources */, ); @@ -510,7 +510,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5C94C30C1F08707F00762CFC /* URLProtocol.swift in Sources */, 5C94C2FE1F08707F00762CFC /* Configuration.swift in Sources */, 5CE6C8121F102B7E00965235 /* CommentsViewController.swift in Sources */, 5C6347161F0B3D3E00158A80 /* ApplicationRequestManager.swift in Sources */, @@ -522,6 +521,7 @@ 5C94C3041F08707F00762CFC /* Logger.swift in Sources */, 5C96D98D1F0ECC39005FF25E /* PostsModel.swift in Sources */, 5C6347151F0B3D3E00158A80 /* ApplicationError.swift in Sources */, + 5CA0A94F21825DA3002BA69A /* AlamoRecordURL.swift in Sources */, 5C6347141F0B3D3E00158A80 /* Post.swift in Sources */, 5CE6C8141F102B8F00965235 /* CommentsView.swift in Sources */, 5C4141961F12CE7800A18674 /* CreatePostView.swift in Sources */, diff --git a/Example/AlamoRecord/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/AlamoRecord/Images.xcassets/AppIcon.appiconset/Contents.json index b8236c6..19882d5 100644 --- a/Example/AlamoRecord/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/AlamoRecord/Images.xcassets/AppIcon.appiconset/Contents.json @@ -39,6 +39,11 @@ "idiom" : "iphone", "size" : "60x60", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 0d37dc2..3cc5164 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 560FE660E022A6A604F1669E682E7523 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = B71C28959052B200D595739E30D99849 /* Logger.swift */; }; 58BC968278BF35B00F9A574D79D2B8CD /* ConstraintRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6152E6D6C5FF74D399E8E49ADD6EA4D /* ConstraintRelation.swift */; }; 5BEC65F1E64F4BC3B0AD838E60E1C4A9 /* ToJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = E779B8F35A77DC1ED97CCCCE8620957D /* ToJSON.swift */; }; + 5CA0A94D21825D53002BA69A /* AlamoRecordURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CA0A94C21825D53002BA69A /* AlamoRecordURL.swift */; }; 5CB6F6D84ABC9285380AED9DB4B14CE7 /* BannerColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 100781A01F52C8868DE7952995131BF4 /* BannerColors.swift */; }; 61200D01A1855D7920CEF835C8BE00B0 /* DispatchQueue+Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61650354959EE750270139458CDF37DB /* DispatchQueue+Alamofire.swift */; }; 6131918F7D68D9CF4F7F72C2EECB4FB0 /* BannerHapticGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F94AE28DD94B3DE6CAD1887DCD735BA /* BannerHapticGenerator.swift */; }; @@ -83,7 +84,6 @@ 8F46A5E6F7671EA5EA201315E3A799E6 /* IntegerOperators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1402D22515B1A5B72F549846B2547567 /* IntegerOperators.swift */; }; 90DC4D46F4E5E867A701C90B7D57F11D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 903792A39ABAEB50B0993AE5D86A4D36 /* UIKit.framework */; }; 90F438528619977EE54D93F123FAAB85 /* ConstraintLayoutSupportDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94CDFBC04E6E7BD3489A3DFA01950B3 /* ConstraintLayoutSupportDSL.swift */; }; - 91BA18956F6AA6D48D76E2EB0DEAD801 /* URLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = E009C0BAAACADEBE37B49BCDC337EF49 /* URLProtocol.swift */; }; 923214FFA0FDFEE4156C940898DC7015 /* ConstraintConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98FCD404051D6CD9860C37A64A0E2A0B /* ConstraintConfig.swift */; }; 974CF452F9D3FE6FF3E697DD864EBD13 /* UILayoutSupport+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC45D38FB076F604D9E399A564B21C1 /* UILayoutSupport+Extensions.swift */; }; 9934F16C237A1A16241E331B0BB9342D /* BannerPositionFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8883A7B2FFADD8D29C76B43CBC4A26D4 /* BannerPositionFrame.swift */; }; @@ -346,6 +346,7 @@ 5A4E71F4F3512AE7E0D80A3FA3E96B45 /* DateTransform.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DateTransform.swift; path = Sources/DateTransform.swift; sourceTree = ""; }; 5C50DE45B27658F07368C610BAE9ECC6 /* ISO8601DateTransform.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ISO8601DateTransform.swift; path = Sources/ISO8601DateTransform.swift; sourceTree = ""; }; 5C6DCE9ED4F6DFCD70692F23B768FE33 /* StatusCodeObserver.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = StatusCodeObserver.swift; path = AlamoRecord/Classes/StatusCodeObserver.swift; sourceTree = ""; }; + 5CA0A94C21825D53002BA69A /* AlamoRecordURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AlamoRecordURL.swift; path = AlamoRecord/Classes/AlamoRecordURL.swift; sourceTree = ""; }; 5E2ED35068719A85E9E81FD92D99F4B1 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60AA063532BA145F6B1BB670C33D7FA1 /* BannerStyle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BannerStyle.swift; path = NotificationBanner/Classes/BannerStyle.swift; sourceTree = ""; }; 61650354959EE750270139458CDF37DB /* DispatchQueue+Alamofire.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "DispatchQueue+Alamofire.swift"; path = "Source/DispatchQueue+Alamofire.swift"; sourceTree = ""; }; @@ -449,7 +450,6 @@ DAC45D38FB076F604D9E399A564B21C1 /* UILayoutSupport+Extensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "UILayoutSupport+Extensions.swift"; path = "Source/UILayoutSupport+Extensions.swift"; sourceTree = ""; }; DB43758BD56B1AF5062D21D807B0C4B3 /* ResponseSerialization.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ResponseSerialization.swift; path = Source/ResponseSerialization.swift; sourceTree = ""; }; DF79FD79AB36BA7231551F24ED27180C /* MarqueeLabel.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MarqueeLabel.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - E009C0BAAACADEBE37B49BCDC337EF49 /* URLProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = URLProtocol.swift; path = AlamoRecord/Classes/URLProtocol.swift; sourceTree = ""; }; E39880455947C02895E53D5A0159D2E2 /* Pods-AlamoRecord_Example-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-AlamoRecord_Example-acknowledgements.plist"; sourceTree = ""; }; E707476DC4388F90BB603482213C55ED /* ConstraintView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintView.swift; path = Source/ConstraintView.swift; sourceTree = ""; }; E71159F241F5C486241C8D49F00A78F7 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -658,14 +658,14 @@ children = ( 8C601D08C7752A1E05169407D4EFF164 /* AlamoRecordError.swift */, 1F3DCEBA12954C262BF014F141AE6E3E /* AlamoRecordObject.swift */, + 5CA0A94C21825D53002BA69A /* AlamoRecordURL.swift */, 91DE1A6992E3185A0BFC1A6AB2D1F40C /* Configuration.swift */, 38F0AEBEBC05B0E366BC95D29032B09D /* ErrorParser.swift */, B71C28959052B200D595739E30D99849 /* Logger.swift */, + 4E3CE92014CF3E189F346DADD0D163D7 /* Pod */, 3345B9C9DAC4112679C63BB8E06C84B8 /* RequestManager.swift */, 36862C0E12ECB8957D399E439394663E /* RequestObserver.swift */, 5C6DCE9ED4F6DFCD70692F23B768FE33 /* StatusCodeObserver.swift */, - E009C0BAAACADEBE37B49BCDC337EF49 /* URLProtocol.swift */, - 4E3CE92014CF3E189F346DADD0D163D7 /* Pod */, 3A97D4D3F0623AD578A47E743CD62656 /* Support Files */, ); name = AlamoRecord; @@ -1427,6 +1427,7 @@ buildActionMask = 2147483647; files = ( 2B8A5BFFADF158FD5A7760A6308D2F35 /* AlamoRecord-dummy.m in Sources */, + 5CA0A94D21825D53002BA69A /* AlamoRecordURL.swift in Sources */, 6AACEFD12135C9DEA33E55F29E135047 /* AlamoRecordError.swift in Sources */, 3AF81E39DB87065BBF28C375A5D63EB3 /* AlamoRecordObject.swift in Sources */, 7D0BBDC4A313D29872DBC771864C1EA9 /* Configuration.swift in Sources */, @@ -1435,7 +1436,6 @@ 4EEB11FBC1DFADD32142D7F2CFDA95CD /* RequestManager.swift in Sources */, 04E60488FC2739F1F05F5C62033523AE /* RequestObserver.swift in Sources */, 3F007A9D204D7A452AB345815E3B8D76 /* StatusCodeObserver.swift in Sources */, - 91BA18956F6AA6D48D76E2EB0DEAD801 /* URLProtocol.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/Tests/ApplicationURL.swift b/Example/Tests/ApplicationURL.swift index 1f7ffc8..26a93f5 100644 --- a/Example/Tests/ApplicationURL.swift +++ b/Example/Tests/ApplicationURL.swift @@ -8,15 +8,22 @@ import AlamoRecord -class ApplicationURL: URLProtocol { +class ApplicationURL: AlamoRecordURL { var absolute: String { - return "https://jsonplaceholder.typicode.com/\(url)" + return isCompletePath ? url : "https://jsonplaceholder.typicode.com/\(url)" } private var url: String + private var isCompletePath: Bool required init(url: String) { self.url = url + self.isCompletePath = false + } + + required init(url: String, isCompletePath: Bool) { + self.url = url + self.isCompletePath = isCompletePath } } diff --git a/README.md b/README.md index d05c4a0..b0e7c19 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ These are data objects that are retrieved from an API. All data objects that inh ### `RequestManager` These are the work horses of AlamoRecord. They contain all of the networking helpers that AlamoRecord needs in order to create your application's networking layer. They are responsible for each request that your `AlamoRecordObject`'s make. They also contain upload and download helpers. -### `URLProtocol` +### `AlamoRecordURL` These store all of the information needed in order to make a proper request through instances of `RequestManager`'s. ### `AlamoRecordError` @@ -46,12 +46,12 @@ These are errors that are returned from an API. On a failed request, the JSON re Let's assume we are developing an application that allows user's to interact with each other via posts. ### Step 1 -We first need to create a class that conforms to `URLProtocol`. Let's name it `ApplicationURL`: +We first need to create a class that conforms to `AlamoRecordURL`. Let's name it `ApplicationURL`: #### `ApplicationURL` ```swift -class ApplicationURL: AlamoRecord.URLProtocol { +class ApplicationURL: AlamoRecordURL { var absolute: String { return "https://jsonplaceholder.typicode.com/\(url)" @@ -65,7 +65,7 @@ class ApplicationURL: AlamoRecord.URLProtocol { } ``` -Notice how you only need to pass the path and not the domain to each instance that conforms to `URLProtocol`. That's because you set the domain of each instance in the `absolute` variable. +Notice how you only need to pass the path and not the domain to each instance that conforms to `AlamoRecordURL`. That's because you set the domain of each instance in the `absolute` variable. ### Step 2