diff --git a/2 b/2 new file mode 100644 index 00000000..f7effbe5 --- /dev/null +++ b/2 @@ -0,0 +1,18 @@ +Allow overridden parameter types on GET/DELETE + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# Date: Fri Aug 6 10:54:16 2021 +0800 +# +# On branch master +# Your branch and 'origin/master' have diverged, +# and have 1 and 1 different commits each, respectively. +# (use "git pull" to merge the remote branch into yours) +# +# Changes to be committed: +# modified: Sources/Networking+HTTPRequests.swift +# +# Untracked files: +# .idea/ +# diff --git a/Sources/Networking+HTTPRequests.swift b/Sources/Networking+HTTPRequests.swift index 6a759eec..c47b16fe 100644 --- a/Sources/Networking+HTTPRequests.swift +++ b/Sources/Networking+HTTPRequests.swift @@ -16,6 +16,21 @@ public extension Networking { return handleJSONRequest(.get, path: path, cacheName: nil, parameterType: parameterType, parameters: parameters, responseType: .json, cachingLevel: cachingLevel, completion: completion) } + /// GET request to the specified path, allowing overridden parameter types + /// + /// Overridden parameter types can be useful, for example some REST-ful APIs do not strictly adhere to spec. + /// + /// - Parameters: + /// - path: The path for the GET request. + /// - parameterType: The parameters type to be used. + /// - parameters: The parameters to be used, they will be serialized using Percent-encoding and appended to the URL. + /// - completion: The result of the operation, it's an enum with two cases: success and failure. + /// - Returns: The request identifier. + @discardableResult + func get(_ path: String, parameterType: ParameterType, parameters: Any? = nil, completion: @escaping (_ result: JSONResult) -> Void) -> String { + handleJSONRequest(.get, path: path, cacheName: nil, parameterType: parameterType, parameters: parameters, responseType: .json, cachingLevel: .none, completion: completion) + } + /// Registers a fake GET request for the specified path. After registering this, every GET request to the path, will return the registered response. /// /// - Parameters: @@ -205,6 +220,21 @@ public extension Networking { return handleJSONRequest(.delete, path: path, cacheName: nil, parameterType: parameterType, parameters: parameters, responseType: .json, cachingLevel: .none, completion: completion) } + /// DELETE request to the specified path, allowing overridden parameter types + /// + /// Overridden parameter types can be useful, for example some REST-ful APIs do not strictly adhere to spec. + /// + /// - Parameters: + /// - path: The path for the DELETE request. + /// - parameterType: The parameters type to be used. + /// - parameters: The parameters to be used, they will be serialized using Percent-encoding and appended to the URL. + /// - completion: The result of the operation, it's an enum with two cases: success and failure. + /// - Returns: The request identifier. + @discardableResult + func delete(_ path: String, parameterType: ParameterType, parameters: Any? = nil, completion: @escaping (_ result: JSONResult) -> Void) -> String { + handleJSONRequest(.delete, path: path, cacheName: nil, parameterType: parameterType, parameters: parameters, responseType: .json, cachingLevel: .none, completion: completion) + } + /// Registers a fake DELETE request for the specified path. After registering this, every DELETE request to the path, will return the registered response. /// /// - Parameters: