Skip to content

Commit

Permalink
Updated project for Swift 5. Extended header which now are also [Stri…
Browse files Browse the repository at this point in the history
…ng: Any?]. Updated RxSwift.
  • Loading branch information
gotev committed Apr 18, 2019
1 parent 70ad3ac commit 5bc193d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ReactiveX/RxSwift" "4.4.0"
github "ReactiveX/RxSwift" "4.5.0"
6 changes: 3 additions & 3 deletions ReactiveAPI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
TargetAttributes = {
D195F1C722086C8200530339 = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
};
};
Expand Down Expand Up @@ -361,7 +361,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -391,7 +391,7 @@
PRODUCT_BUNDLE_IDENTIFIER = it.sky.ReactiveAPI;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion ReactiveAPI/Extensions/Encodable+Dictionary.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public extension Encodable {
public var dictionary: [String: Any]? {
var dictionary: [String: Any]? {
guard let data = try? JSONEncoder().encode(self) else { return nil }
return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments))
.flatMap { $0 as? [String: Any] }
Expand Down
2 changes: 1 addition & 1 deletion ReactiveAPI/Extensions/URLRequest+ReactiveAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension URLRequest {

public static func createForJSON(with url: URL,
method: ReactiveAPIHTTPMethod = .get,
headers: [String: String?]? = nil,
headers: [String: Any?]? = nil,
queryParams: [String: Any?]? = nil,
body: Encodable? = nil) throws -> URLRequest {
return try createForJSON(with: url,
Expand Down
2 changes: 1 addition & 1 deletion ReactiveAPI/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
60 changes: 30 additions & 30 deletions ReactiveAPI/JSONReactiveAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ open class JSONReactiveAPI: ReactiveAPI {

public extension JSONReactiveAPI {
// body params as dictionary and generic response type
public func request<D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: String?]? = nil,
queryParams: [String: Any?]? = nil,
bodyParams: [String: Any?]? = nil) -> Single<D> {
func request<D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: Any?]? = nil,
queryParams: [String: Any?]? = nil,
bodyParams: [String: Any?]? = nil) -> Single<D> {
do {
let request = try URLRequest.createForJSON(with: url,
method: method,
Expand All @@ -112,11 +112,11 @@ public extension JSONReactiveAPI {
}

// body params as encodable and generic response type
public func request<E: Encodable, D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: String?]? = nil,
queryParams: [String: Any?]? = nil,
body: E? = nil) -> Single<D> {
func request<E: Encodable, D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: Any?]? = nil,
queryParams: [String: Any?]? = nil,
body: E? = nil) -> Single<D> {
do {
let request = try URLRequest.createForJSON(with: url,
method: method,
Expand All @@ -130,11 +130,11 @@ public extension JSONReactiveAPI {
}

// body params as dictionary and void response type
public func request(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: String?]? = nil,
queryParams: [String: Any?]? = nil,
bodyParams: [String: Any?]? = nil) -> Single<Void> {
func request(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: Any?]? = nil,
queryParams: [String: Any?]? = nil,
bodyParams: [String: Any?]? = nil) -> Single<Void> {
do {
let request = try URLRequest.createForJSON(with: url,
method: method,
Expand All @@ -148,11 +148,11 @@ public extension JSONReactiveAPI {
}

// body params as encodable and void response type
public func request<E: Encodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: String?]? = nil,
queryParams: [String: Any?]? = nil,
body: E? = nil) -> Single<Void> {
func request<E: Encodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: Any?]? = nil,
queryParams: [String: Any?]? = nil,
body: E? = nil) -> Single<Void> {
do {
let request = try URLRequest.createForJSON(with: url,
method: method,
Expand All @@ -166,11 +166,11 @@ public extension JSONReactiveAPI {
}

// body params as dictionary and array response type
public func request<D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: String?]? = nil,
queryParams: [String: Any?]? = nil,
bodyParams: [String: Any?]? = nil) -> Single<[D]> {
func request<D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: Any?]? = nil,
queryParams: [String: Any?]? = nil,
bodyParams: [String: Any?]? = nil) -> Single<[D]> {
do {
let request = try URLRequest.createForJSON(with: url,
method: method,
Expand All @@ -184,11 +184,11 @@ public extension JSONReactiveAPI {
}

// body params as encodable and array response type
public func request<E: Encodable, D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: String?]? = nil,
queryParams: [String: Any?]? = nil,
body: E? = nil) -> Single<[D]> {
func request<E: Encodable, D: Decodable>(_ method: ReactiveAPIHTTPMethod = .get,
url: URL,
headers: [String: Any?]? = nil,
queryParams: [String: Any?]? = nil,
body: E? = nil) -> Single<[D]> {
do {
let request = try URLRequest.createForJSON(with: url,
method: method,
Expand Down

0 comments on commit 5bc193d

Please sign in to comment.