Skip to content

Commit 9413892

Browse files
committed
Update WebServiceProxy.
1 parent c3f21b5 commit 9413892

File tree

4 files changed

+102
-16
lines changed

4 files changed

+102
-16
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "2600"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "Echo"
19+
BuildableName = "Echo"
20+
BlueprintName = "Echo"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
<Testables>
33+
<TestableReference
34+
skipped = "NO">
35+
<BuildableReference
36+
BuildableIdentifier = "primary"
37+
BlueprintIdentifier = "EchoTests"
38+
BuildableName = "EchoTests"
39+
BlueprintName = "EchoTests"
40+
ReferencedContainer = "container:">
41+
</BuildableReference>
42+
<SkippedTests>
43+
<Test
44+
Identifier = "EchoTests/testGetFibonacci()">
45+
</Test>
46+
</SkippedTests>
47+
</TestableReference>
48+
</Testables>
49+
</TestAction>
50+
<LaunchAction
51+
buildConfiguration = "Debug"
52+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
53+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
54+
launchStyle = "0"
55+
useCustomWorkingDirectory = "NO"
56+
ignoresPersistentStateOnLaunch = "NO"
57+
debugDocumentVersioning = "YES"
58+
debugServiceExtension = "internal"
59+
allowLocationSimulation = "YES">
60+
</LaunchAction>
61+
<ProfileAction
62+
buildConfiguration = "Release"
63+
shouldUseLaunchSchemeArgsEnv = "YES"
64+
savedToolIdentifier = ""
65+
useCustomWorkingDirectory = "NO"
66+
debugDocumentVersioning = "YES">
67+
<MacroExpansion>
68+
<BuildableReference
69+
BuildableIdentifier = "primary"
70+
BlueprintIdentifier = "Echo"
71+
BuildableName = "Echo"
72+
BlueprintName = "Echo"
73+
ReferencedContainer = "container:">
74+
</BuildableReference>
75+
</MacroExpansion>
76+
</ProfileAction>
77+
<AnalyzeAction
78+
buildConfiguration = "Debug">
79+
</AnalyzeAction>
80+
<ArchiveAction
81+
buildConfiguration = "Release"
82+
revealArchiveInOrganizer = "YES">
83+
</ArchiveAction>
84+
</Scheme>

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ Service operations are initiated via one of the following methods:
3434

3535
```swift
3636
public func invoke(_ method: Method, path: String,
37-
arguments: [String: Any] = [:],
37+
arguments: [String: Sendable] = [:],
3838
content: Data? = nil,
3939
contentType: String? = nil) async throws { ... }
4040

4141
public func invoke<B: Encodable>(_ method: Method, path: String,
42-
arguments: [String: Any] = [:],
42+
arguments: [String: Sendable] = [:],
4343
body: B) async throws { ... }
4444

4545
public func invoke<T: Decodable>(_ method: Method, path: String,
46-
arguments: [String: Any] = [:],
46+
arguments: [String: Sendable] = [:],
4747
content: Data? = nil,
4848
contentType: String? = nil) async throws -> T { ... }
4949

5050
public func invoke<B: Encodable, T: Decodable>(_ method: Method, path: String,
51-
arguments: [String: Any] = [:],
51+
arguments: [String: Sendable] = [:],
5252
body: B) async throws -> T { ... }
5353

5454
public func invoke<T>(_ method: Method, path: String,
55-
arguments: [String: Any] = [:],
55+
arguments: [String: Sendable] = [:],
5656
content: Data? = nil,
5757
contentType: String? = nil,
5858
responseHandler: @escaping ResponseHandler<T>) async throws -> T { ... }
@@ -78,7 +78,7 @@ Three of the methods accept the following arguments for specifying custom reques
7878
The other two methods accept a `body` argument of type `B` that is serialized using `JSONEncoder`. JSON data is encoded and decoded using a date strategy of `millisecondsSince1970`.
7979

8080
## Query Arguments
81-
Any value may be used as a query argument and will generally be encoded using its string representation. However, `Date` instances are first converted to a 64-bit integer value representing epoch time. Additionally, array instances represent multi-value parameters and behave similarly to `<select multiple>` tags in HTML forms.
81+
Any sendable value may be used as a query argument and will generally be encoded using its string representation. However, `Date` instances are first converted to a 64-bit integer value representing epoch time. Additionally, array instances represent multi-value parameters and behave similarly to `<select multiple>` tags in HTML forms.
8282

8383
The `undefined` property of the `WebServiceProxy` class can be used to represent unspecified or unknown argument values.
8484

Sources/Echo/WebServiceProxy.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public class WebServiceProxy {
6363
/**
6464
* Constant representing an unspecified value.
6565
*/
66-
public static let undefined = NSNull()
67-
66+
public static let undefined: Void = ()
67+
6868
// JSON encoder
6969
private static let jsonEncoder: JSONEncoder = {
7070
let jsonEncoder = JSONEncoder()
@@ -95,7 +95,7 @@ public class WebServiceProxy {
9595
- parameter contentType: The request content type, or `nil` for no content type.
9696
*/
9797
public func invoke(_ method: Method, path: String,
98-
arguments: [String: Any] = [:],
98+
arguments: [String: Sendable] = [:],
9999
content: Data? = nil,
100100
contentType: String? = nil) async throws {
101101
try await invoke(method, path: path,
@@ -112,7 +112,7 @@ public class WebServiceProxy {
112112
- parameter body: The request body.
113113
*/
114114
public func invoke<B: Encodable>(_ method: Method, path: String,
115-
arguments: [String: Any] = [:],
115+
arguments: [String: Sendable] = [:],
116116
body: B) async throws {
117117
try await invoke(method, path: path,
118118
arguments: arguments,
@@ -130,7 +130,7 @@ public class WebServiceProxy {
130130
- returns The response body.
131131
*/
132132
public func invoke<T: Decodable>(_ method: Method, path: String,
133-
arguments: [String: Any] = [:],
133+
arguments: [String: Sendable] = [:],
134134
content: Data? = nil,
135135
contentType: String? = nil) async throws -> T {
136136
return try await invoke(method, path: path,
@@ -148,7 +148,7 @@ public class WebServiceProxy {
148148
- returns The response body.
149149
*/
150150
public func invoke<B: Encodable, T: Decodable>(_ method: Method, path: String,
151-
arguments: [String: Any] = [:],
151+
arguments: [String: Sendable] = [:],
152152
body: B) async throws -> T {
153153
return try await invoke(method, path: path,
154154
arguments: arguments,
@@ -167,7 +167,7 @@ public class WebServiceProxy {
167167
- returns The response body.
168168
*/
169169
public func invoke<T>(_ method: Method, path: String,
170-
arguments: [String: Any] = [:],
170+
arguments: [String: Sendable] = [:],
171171
content: Data? = nil,
172172
contentType: String? = nil,
173173
responseHandler: @escaping ResponseHandler<T>) async throws -> T {
@@ -178,8 +178,8 @@ public class WebServiceProxy {
178178
throw WebServiceError(errorDescription: "Invalid key.", statusCode: 0)
179179
}
180180

181-
for element in argument.value as? [Any] ?? [argument.value] {
182-
if (element is NSNull) {
181+
for element in argument.value as? [Sendable] ?? [argument.value] {
182+
if (element is Void) {
183183
continue
184184
}
185185

Tests/EchoTests/EchoTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ final class EchoTests: XCTestCase {
2626
let flag: Bool
2727
let date: Date
2828
let dates: [Date]
29+
let instant: String?
2930
}
3031

3132
struct Body: Codable {
@@ -66,7 +67,8 @@ final class EchoTests: XCTestCase {
6667
"flag": true,
6768
"dayOfWeek": DayOfWeek.monday,
6869
"date": now,
69-
"dates": [now]
70+
"dates": [now],
71+
"instant": WebServiceProxy.undefined
7072
])
7173

7274
XCTAssert(result.string == "héllo&gøod+bye?")

0 commit comments

Comments
 (0)