Skip to content

Commit

Permalink
Release 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ProVir authored and Vitalii Korotkii committed May 17, 2019
1 parent f20c95b commit 8c52ec9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire"
github "Alamofire/Alamofire" ~> 4.8
35 changes: 14 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ Network layer as Service. Service as an interface for interacting with your web
- [x] Support NetworkActivityIndicator on iOS.
- [x] Thread safe.
- [x] Responses with concrete type in completion handler closures.
- [x] Providers for requests (have RequestProvider and GroupProvider) for work with only concrete requests. Used to indicate more explicit dependencies (DIP).
- [x] RequestProvider for work with only concrete request. Used to indicate more explicit dependencies (DIP).
- [x] Mock endpoints for temporary or test response data without use real api endpoint.
- [x] Full support Alamofire (include base endpoint).
- [x] Simple HTTP Endpoints (NSURLSession or Alamofire).
- [x] Support as static framework


## Requirements

- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 10.2 and above
- Swift 5.0 and above
- Xcode 9.0 and above
- Swift 4.0 and above


## Communication
Expand All @@ -70,7 +71,7 @@ Network layer as Service. Service as an interface for interacting with your web
$ gem install cocoapods
```

> CocoaPods 1.6.0+ is required to build WebServiceSwift 3.0.0+.
> CocoaPods 1.1.0+ is required to build WebServiceSwift 3.1.0+.
To integrate WebServiceSwift into your Xcode project using CocoaPods, specify it in your `Podfile`:

Expand All @@ -79,18 +80,18 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target '<Your Target Name>' do
pod 'WebServiceSwift', '~> 3.0'
pod 'WebServiceSwift', '~> 3.1'
end
```

Also you can use Alamofire endpoints:
```ruby
pod 'WebServiceSwift/Alamofire', '~> 3.0'
pod 'WebServiceSwift/Alamofire', '~> 3.1'
```

Or only core without simple endpoints and storages:
```ruby
pod 'WebServiceSwift/Core', '~> 3.0'
pod 'WebServiceSwift/Core', '~> 3.1'
```


Expand All @@ -114,7 +115,7 @@ $ brew install carthage
To integrate WebServiceSwift into your Xcode project using Carthage, specify it in your `Cartfile`:

```ogdl
github "ProVir/WebServiceSwift" ~> 3.0
github "ProVir/WebServiceSwift" ~> 3.1
```

Run `carthage update` to build the framework and drag the built `WebServiceSwift.framework` into your Xcode project.
Expand All @@ -127,7 +128,7 @@ Once you have your Swift package set up, adding WebServiceSwift as a dependency

```swift
dependencies: [
.package(url: "https://github.com/ProVir/WebServiceSwift.git", from: "3.0.0")
.package(url: "https://github.com/ProVir/WebServiceSwift.git", from: "3.1.0")
]
```

Expand All @@ -153,7 +154,7 @@ To use the library, you need:

The project has a less abstract example of using the library, which can be downloaded separately. Study the classes `WebServiceSimpleEndpoint` и `WebServiceAlamofireSimpleEndpoint` - they are a good example of its endpoint.

To create non-compliant copies of a service with the same set of endpoints and storages, you can call `WebService.clone ()`. Each copy independently manages its requests and cancels them automatically when an instance of the service is deinited.
To create non-compliant copies of a service with the same set of endpoints and storages, you can call `WebService.clone()`. Each copy independently manages its requests and cancels them automatically when an instance of the service is deinited.

#

Expand Down Expand Up @@ -506,10 +507,7 @@ To add more explicit dependencies to your project, as well as to protect against
#### Example own provider:

```swift
struct SiteWebServiceRequests: WebServiceGroupRequests {
static let requestTypes: [WebServiceBaseRequesting.Type]
= [ExampleRequest.self, GetList.self]

enum SiteWebServiceRequests {
struct Example: WebServiceRequesting, Hashable {
let site: String
let domainRu: Bool
Expand Down Expand Up @@ -541,21 +539,19 @@ class SiteWebProvider: WebServiceProvider {
}
```

You can use two ready-made generic provider classes - `WebServiceRequestProvider` (for one type of request) and `WebServiceGroupProvider` (for a group of requests). To support your set of valid requests, you can use `WebServiceRestrictedProvider` instead of `WebServiceGroupProvider`.
You can use ready-made generic provider class - `WebServiceRequestProvider` for one type of request.

Вы можете использовать два готовых шаблоных класса провайдера - `WebServiceRequestProvider` (для одного типа запроса) и `WebServiceGroupProvider` (для группы запросов). Для поддержки своего набора допустимых запросов вместо `WebServiceGroupProvider` доступен `WebServiceRestrictedProvider`.
Вы можете использовать готовый шаблоны класса провайдера - `WebServiceRequestProvider` для одного типа запроса.

#### Example providers:

```swift
let getListSiteWebProvider: WebServiceRequestProvider<SiteWebServiceRequests.GetList>
let exampleSiteWebProvider: WebServiceRequestProvider<SiteWebServiceRequests.Example>
let siteWebProvider: WebServiceGroupProvider<SiteWebServiceRequests>

init(webService: WebService) {
getListSiteWebProvider = webService.createProvider()
exampleSiteWebProvider = webService.createProvider()
siteWebProvider = webService.createProvider()
}

func performRequests() {
Expand All @@ -575,9 +571,6 @@ func performRequests() {

// RequestProvider for request with params
exampleSiteWebProvider.performRequest(.init(site: "google", domainRu: false)) { _ in }

// GroupProvider, if request don't contains in group - assert (crash in debug, .canceledRequests in release usually).
siteWebProvider.performRequest(SiteWebServiceRequests.Example(site: "yandex", domainRu: true)) { _ in }
}
```

Expand Down
1 change: 1 addition & 0 deletions Source/WebServiceProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public protocol WebServiceEmptyRequesting: WebServiceRequesting {
}

/// Groups requests, protocol use for `WebServiceGroupProvider`.
@available(*, deprecated, message: "Can be removed in next versions")
public protocol WebServiceGroupRequests {
/// List all type requests in group
static var requestTypes: [WebServiceBaseRequesting.Type] { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import WebServiceSwift
import Alamofire

//MARK: Request
struct SiteWebServiceRequests: WebServiceGroupRequests {
static let requestTypes: [WebServiceBaseRequesting.Type]
= [SiteSearch.self, SiteMail.self, SiteYouTube.self]

enum SiteWebServiceRequests {
struct SiteSearch: WebServiceRequesting, Hashable {
let site: Site
let domain: String
Expand Down
3 changes: 1 addition & 2 deletions WebServiceSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WebServiceSwift"
s.version = "3.0.2"
s.version = "3.1.0"
s.summary = "Network layer as Service."
s.description = <<-DESC
Written in Swift.
Expand All @@ -14,7 +14,6 @@ Pod::Spec.new do |s|
s.author = { "ViR (Vitaliy Korotkiy)" => "[email protected]" }
s.source = { :git => "https://github.com/ProVir/WebServiceSwift.git", :tag => "#{s.version}" }

s.swift_version = '5.0'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.tvos.deployment_target = '9.0'
Expand Down

0 comments on commit 8c52ec9

Please sign in to comment.