Skip to content

Latest commit

 

History

History
304 lines (183 loc) · 15.4 KB

CHANGELOG.md

File metadata and controls

304 lines (183 loc) · 15.4 KB
  • 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() and ServiceTask.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's metrics property
  • Add updateUITime and responseJSON time to ServiceTaskMetrics

New Features

  • Added metricsCollected handler API for setting a callback to read response time for an individual service task response.
  • Migrate to Swift 4

New Features

  • Added data: Data? parameter to didFinishCollectingTaskMetrics in the ServicePassthroughDelegate protocol. This is useful for components that need to monitor the data firehose from web service responses.

New Features

New Features

  • Make the default URLSession modifiable within the app instead of relying on the system level shared instance
  • Use default settings for bitcode

New Features

  • Make the WebService's' request method public so external interfaces can more dynamically create ServiceTask instances

New Features

  • Add ServiceTaskMetrics API to enable ServiceTask to collect performance metrics during execution
  • Make passthroughDelegate property public

Fixes

  • Avoid encoding URLRequest multiple times in ServiceTask

New Features

  • Added QueryParameterEncoder API for defining a custom encoding for query parameters

Fixes

  • 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 each responseJSON 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 to WebService
  • Added an initializer to WebService for initializing with a URL.
  • Enabled runtime overriding of absoluteURLString(_:)
  • Remove lazy var for Carthage compatibility.
  • Update to Xcode 8.1 recommended project settings.
  • Added support for Swift 3

Breaking

  • 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.

Deprecations

New Features

  • Added setQueryParameters(parameters:) method to ServiceTask for setting key/value pairs in the URL query string. Fixes #40.
  • Added setFormParameters(parameters:) method to ServiceTask 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).

Fixes

  • Make updateUI() and updateErrorUI handlers block handler chain execution. Fixes #38.
Throwing Errors

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)
}
Request Parameters

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() and recover() 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 with stringByAddingPercentEncodingWithAllowedCharacters. This change allows NSURLQueryItem to handle the percent encoding and uses NSURLComponents 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

Breaking Changes

  • Added NSURLResponse parameter to JSONHandler closure to enable JSON response handler to access response meta data. (24d7d5a)
  • Deployment target turned down to 8.0. (c4b9b6e)

Deprecations

  • Deprecated SessionDataTaskDataSource protocol in favor of Session.
  • Deprecated WebService's dataTaskSource property. Use Session protocol and set the session property instead.
  • Deprecated WebService's dataTaskWithRequest(request:completionHandler) method. Use dataTask(request:completion:) instead.

New Features

  • Added Session and DataTask protocols to decouple NSURLSession and NSURLSessionDataTask from ServiceTask and WebService. 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 make NSURLSession conform to Session and NSURLSessionDataTask conform to DataTask
  • Added Mocking API. See the mocking API documentation for usage information.
    • Added MockSession and MockDataTask protocols as a mocking interface for Session and DataTask types.
    • Added MockResponse for easier response mocking
  • 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 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 an ObjCHandlerResult value
  • 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 use Any instead of AnyObject in order to support value types. fixes #15.
  • Changed response handlers that are set with response(), responseJSON, and responseError() 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 to NSURLSession
  • Removed request option API in favor of ServiceTask methods for setting request details.
  • Added ServiceTask methods for configuring the request details.
  • Added body parameter to Request 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 that stringByAddingPercentEscapesUsingEncoding 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