- Migrate to Swift 5
- Add
ServicePassthroughDelegat.validateResponsee
to enable validating responses and throwing errors for invalid responses that can be handled by response handlers.
- Add
ServiceTask.setBody()
andServiceTask.setJSONData()
APIs for encoding body data on a background queue.
- Add support for percent-encoding the body while specifying allowed characters.
- Add
setJSONData()
API - Add ability to set custom content-type header
- Add a target that builds a static framework for iOS platform.
- Update to Xcode 9.3 recommended project settings
- Expose
ServiceTask
'smetrics
property - Add
updateUITime
andresponseJSON
time toServiceTaskMetrics
- Added
metricsCollected
handler API for setting a callback to read response time for an individual service task response.
- Migrate to Swift 4
- Added
data: Data?
parameter todidFinishCollectingTaskMetrics
in theServicePassthroughDelegate
protocol. This is useful for components that need to monitor the data firehose from web service responses.
- Add
setShouldHandleCookies
API for configuring the default cookie behavior of the request
- Make the default
URLSession
modifiable within the app instead of relying on the system level shared instance
- Use default settings for bitcode
- Make the
WebService
's'request
method public so external interfaces can more dynamically createServiceTask
instances
- Add
ServiceTaskMetrics
API to enableServiceTask
to collect performance metrics during execution - Make
passthroughDelegate
property public
- Avoid encoding
URLRequest
multiple times inServiceTask
- Added
QueryParameterEncoder
API for defining a custom encoding for query parameters
- Cache JSON deserialization so it can be reused in other handlers Previously if there were multiple
responseJSON
handlers in a service task chain, the response body would be deserialized for eachresponseJSON
call. This change allows multiple calls to reuse the same deserialized payload.
- Resolved various Xcode 8.3 warnings
- Fixed build errors in example project
- Added
@discardableResult
in Obj-C APIs to resolve unused value warning
WebService
can now be initialized with a URL
type for the baseURL along with the existing baseURLString
. Example:
let url = URL(string: "http://httpbin.org")
let service = WebService(baseURL: url)
- Added
baseURL: URL?
property toWebService
- Added an initializer to
WebService
for initializing with aURL
. - Enabled runtime overriding of
absoluteURLString(_:)
- Remove
lazy
var for Carthage compatibility.
- Update to Xcode 8.1 recommended project settings.
- Added support for Swift 3
- API naming changes for Swift 3
- Removed
SessionDataTaskDataSource
API
- Merge support for PATCH HTTP requests
- Added support for Xcode 8, Swift 2.3, and iOS SDK 10
- Added support for PATCH HTTP requests.
- Deprecated
ServiceTaskResult.Failure
. Usethrow
to propagate errors instead. - Deprecated
setParameters(parameters:encoding:)
andsetParameterEncoding(encoding:)
methods ofServiceTask
. UsesetQueryParameters(parameters:)
andsetFormParameters(parameters:)
instead.
- Added
setQueryParameters(parameters:)
method toServiceTask
for setting key/value pairs in the URL query string. Fixes #40. - Added
setFormParameters(parameters:)
method toServiceTask
for setting key/value pairs in the request body as form encoded data. Fixes #40. - Response handler closures can throw errors to propagate errors instead of return
.Failure(error)
.
- Make
updateUI()
andupdateErrorUI
handlers block handler chain execution. Fixes #38.
Previously, response handlers returned a.Failure(error)
value to indiciate that a handler failed.
.responseJSON { json, response in
if let models: [Brewer] = JSONDecoder<Brewer>.decode(json) {
return .Value(models)
} else {
// any value conforming to ErrorType
return .Failure(JSONDecoderError.FailedToDecodeBrewer)
}
}
Response handlers should now use Swift's throw
keyword to propagate errors.
.responseJSON { json, response in
guard let models: [Brewer] = JSONDecoder<Brewer>.decode(json) {
throw JSONDecoderError.FailedToDecodeBrewer
}
return .Value(models)
}
GET, DELETE, or HEAD request that use setParameters(parameters:encoding:)
to encode parameter data in the URL query string should move to using setQueryParameters(parameters:)
to set parameter data instead.
POST and PUT requests that use setParameters(parameters:encoding:)
to send form data, not JSON, in the request body should instead use setFormParameters(parameters:)
.
- Force-downcast
updateUIObjC
handler's value to avoid silent failure. Fixes #34. - Introduced
transform()
andrecover()
response handler API. See the Composing Response Handlers section of programming guide for more info on how to use the new API.
- Removed the
SessionDataTaskDataSource
deprecation warnings that were declared with the@available
attribute. The@available
attribute was causing warnings to surface in Xcode projects that contained the ELWebService Xcode project as a subproject even when the deprecated API was not being called from the parent project. Due to Walmart's internal workflow being dependant on including ELWebService as a subproject, a decision was made to remove the@avaiable
deprecation warnings in a patch release.
- Resolved Swift 3 deprecation warnings.
- Updated the Objective-C request API to return
self
instance for API consistency - Simplified query parameter encoding with
NSURLQueryItem
Previously, query parameters were encoded manually by piecing together string values withstringByAddingPercentEncodingWithAllowedCharacters
. This change allowsNSURLQueryItem
to handle the percent encoding and usesNSURLComponents
to produce the encoded query string. - Updated ELWebService unit tests to use mock sessions instead of sending requests over the network.
- Added more unit tests, increasing code coverage to 99%
- Added unit tests to example project to demonstrate session and response mocking
- Added
NSURLResponse
parameter toJSONHandler
closure to enable JSON response handler to access response meta data. (24d7d5a) - Deployment target turned down to 8.0. (c4b9b6e)
- Deprecated
SessionDataTaskDataSource
protocol in favor ofSession
. - Deprecated WebService's
dataTaskSource
property. UseSession
protocol and set thesession
property instead. - Deprecated WebService's
dataTaskWithRequest(request:completionHandler)
method. UsedataTask(request:completion:)
instead.
- Added
Session
andDataTask
protocols to decoupleNSURLSession
andNSURLSessionDataTask
fromServiceTask
andWebService
. These new protocols enable code to mock the session and data task objects so that unit tests can be performed without sending requests over the network. The framework provides implementations that makeNSURLSession
conform toSession
andNSURLSessionDataTask
conform toDataTask
- Added Mocking API. See the mocking API documentation for usage information.
- Added
MockSession
andMockDataTask
protocols as a mocking interface forSession
andDataTask
types. - Added
MockResponse
for easier response mocking
- Added
- Changed deployment target to 8.0
- Replaced ServiceTask's GCD queue with NSOperationQueue so queued blocks can be cancelled in deinit
- Added
ServicePassthroughDelegate
protocol for handling raw request and response events
- Added
dataTaskWithRequest
method low-level WebService API for creatingNSURLSessionDataTask
fromNSURLRequest
objects
- Added better support for Objective-C interoperability by introducing a special request API for Obj-C. See Objective-C ServiceTask Request API section in the programming guide for more information.
- Added support for Objective-C interoperability. Fixes #21. For information on usage from Obj-C see the Objective-C Interoperability section in the ELWebService Programming Guide. Several changes were made to support Obj-C interop:
- Made
WebService
inherit from NSObject - Made
ServiceTask
inherit from NSObject - Added
ObjCHandlerResult
class to encapsulate result data from Obj-C handlers - Added
ObjCResponseHandler
closure type to support adding response handlers that work with Obj-C - Extended
ServiceTask
to add specially-named response handler methods to support adding handlers from Obj-C - Added a
ServiceTaskResult
initializer so that a service task result value can be initialized from anObjCHandlerResult
value
- Made
- Enabled testability for release builds. Fixes #19.
- Encode request parameters only when parameters are non empty. Fixes an issue where request URLs would end with a
?
character when sending GET requests with empty parameters.
- Changed
ServiceTaskResult.Value
to useAny
instead ofAnyObject
in order to support value types. fixes #15.
- Changed response handlers that are set with
response()
,responseJSON
, andresponseError()
to run on a background queue. fixes #7. - Added
updateErrorUI()
to set error handlers that run on the main queue. fixes #8 - Added
updateUI()
to set response handlers that run on the main queue. - Added
ServiceTaskResult
to allow response handlers to control flow through the chain. - Added
SessionDataTaskDataSource
conformance toNSURLSession
- Removed request option API in favor of
ServiceTask
methods for setting request details. - Added
ServiceTask
methods for configuring the request details.
- Added
body
parameter toRequest
for storing HTTP body data - Added
.Body
and.BodyJSON
request options to allow raw HTTP body contents to be defined - Updated example project to provide a better example of ELWebService usage
- Change
WebService
to a final class
- Various updates for Swift 2 support based on Xcode 7 migration tool
- Enable testability for debug builds only
- Add
percentEncodeURLQueryCharacters
to encode params now thatstringByAddingPercentEscapesUsingEncoding
is deprecated in iOS 9 - Clean up unit tests to fix Xcode 7 warnings
- Audit access control and update tests based on new
@testability
Xcode 7 support - Use Swift 2's new
ErrorType
as the error parameter type for error handlers
- Update example web service project to use
throwError()
- Refactor error handling to utilize
Result
enum
- Added Travis CI support