Skip to content

Commit f0fdd5b

Browse files
authored
Functions Cleanup (#13449)
1 parent a3254ff commit f0fdd5b

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

FirebaseFunctions/Sources/Functions.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,16 +440,12 @@ enum FunctionsConstants {
440440
cachePolicy: .useProtocolCachePolicy,
441441
timeoutInterval: timeout)
442442
let fetcher = fetcherService.fetcher(with: request)
443-
let body = NSMutableDictionary()
444443

445444
// Encode the data in the body.
446-
var localData = data
447-
if data == nil {
448-
localData = NSNull()
449-
}
445+
let data = data ?? NSNull()
450446
// Force unwrap to match the old invalid argument thrown.
451-
let encoded = try! serializer.encode(localData!)
452-
body["data"] = encoded
447+
let encoded = try! serializer.encode(data)
448+
let body = ["data": encoded]
453449

454450
do {
455451
let payload = try JSONSerialization.data(withJSONObject: body)

FirebaseFunctions/Sources/Internal/FunctionsSerializer.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,7 @@ extension FunctionsSerializer {
2828
}
2929
}
3030

31-
class FunctionsSerializer: NSObject {
32-
private let dateFormatter: DateFormatter = {
33-
let formatter = DateFormatter()
34-
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
35-
formatter.timeZone = TimeZone(identifier: "UTC")
36-
return formatter
37-
}()
38-
31+
final class FunctionsSerializer {
3932
// MARK: - Internal APIs
4033

4134
func encode(_ object: Any) throws -> AnyObject {

0 commit comments

Comments
 (0)