Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.

Commit eca2616

Browse files
committed
Release 0.4.4
1 parent 292d0c0 commit eca2616

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

Core/NetResponse+Build.swift

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,56 @@ extension NetResponse {
103103
return self
104104
}
105105

106+
@discardableResult public func setString(_ string: String?, encoding: String.Encoding = .utf8, allowLossyConversion: Bool = false) -> Self {
107+
guard let string = string,
108+
let data = string.data(using: encoding, allowLossyConversion: allowLossyConversion) else {
109+
return self
110+
}
111+
setObject(data)
112+
setContentLength(Int64(data.count))
113+
return self
114+
}
115+
116+
@discardableResult public func setJSON<T: Encodable>(_ encodable: T?) throws -> Self {
117+
guard let encodable = encodable else {
118+
return self
119+
}
120+
let data = try JSONEncoder().encode(encodable)
121+
setObject(data)
122+
setContentLength(Int64(data.count))
123+
return self
124+
}
125+
126+
@discardableResult public func setJSON(_ object: Any?, options: JSONSerialization.WritingOptions = .prettyPrinted) throws -> Self {
127+
guard let jsonObject = object else {
128+
return self
129+
}
130+
let data = try JSONSerialization.data(withJSONObject: jsonObject, options: options)
131+
setObject(data)
132+
setContentLength(Int64(data.count))
133+
return self
134+
}
135+
136+
@discardableResult public func setPlist<T: Encodable>(_ encodable: T?) throws -> Self {
137+
guard let encodable = encodable else {
138+
return self
139+
}
140+
let data = try PropertyListEncoder().encode(encodable)
141+
setObject(data)
142+
setContentLength(Int64(data.count))
143+
return self
144+
}
145+
146+
@discardableResult public func setPlist(_ object: Any?, format: PropertyListSerialization.PropertyListFormat = .xml, options: PropertyListSerialization.WriteOptions = 0) throws -> Self {
147+
guard let plistBody = object else {
148+
return self
149+
}
150+
let data = try PropertyListSerialization.data(fromPropertyList: plistBody, format: format, options: options)
151+
setObject(data)
152+
setContentLength(Int64(data.count))
153+
return self
154+
}
155+
106156
public func build() -> NetResponse {
107157
return NetResponse(self)
108158
}

Net.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@
15671567
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
15681568
DEVELOPMENT_TEAM = 3VW789WSMP;
15691569
DYLIB_COMPATIBILITY_VERSION = 0.4.0;
1570-
DYLIB_CURRENT_VERSION = 0.4.3;
1570+
DYLIB_CURRENT_VERSION = 0.4.4;
15711571
ENABLE_STRICT_OBJC_MSGSEND = YES;
15721572
ENABLE_TESTABILITY = YES;
15731573
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -1621,7 +1621,7 @@
16211621
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
16221622
DEVELOPMENT_TEAM = 3VW789WSMP;
16231623
DYLIB_COMPATIBILITY_VERSION = 0.4.0;
1624-
DYLIB_CURRENT_VERSION = 0.4.3;
1624+
DYLIB_CURRENT_VERSION = 0.4.4;
16251625
ENABLE_STRICT_OBJC_MSGSEND = YES;
16261626
GCC_C_LANGUAGE_STANDARD = gnu99;
16271627
GCC_NO_COMMON_BLOCKS = YES;

NetClient.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'NetClient'
3-
s.version = '0.4.3'
3+
s.version = '0.4.4'
44
s.summary = 'Versatile HTTP networking library written in Swift.'
55

66
s.homepage = 'https://github.com/intelygenz/NetClient-iOS'

0 commit comments

Comments
 (0)