diff --git a/Packages/AccountUpdate/Sources/AccountUpdateNetworkService/AccountUpdateNetworkService.swift b/Packages/AccountUpdate/Sources/AccountUpdateNetworkService/AccountUpdateNetworkService.swift index 78fd1a6..bdcfb44 100644 --- a/Packages/AccountUpdate/Sources/AccountUpdateNetworkService/AccountUpdateNetworkService.swift +++ b/Packages/AccountUpdate/Sources/AccountUpdateNetworkService/AccountUpdateNetworkService.swift @@ -76,11 +76,19 @@ private extension AccountResponse { /// Initializes the `AccountResponse` model from the network response /// model, so that the client doesn't depend on network models. + /// + /// If the name from the API response is `nil` or empty, it defaults to "Anonymous" + /// to ensure all layers of the application work with a non-optional name value. + /// /// - Parameter response: The network model to be mapped. init( response: AccountInformationResponse.Response ) { - name = response.name + if let responseName = response.name, !responseName.isEmpty { + name = responseName + } else { + name = "Anonymous" + } email = response.email unixEpochTime = response.created.unixEpochTime } diff --git a/Packages/OMGAPI/Sources/OMGAPI/Responses/AccountInformationResponse.swift b/Packages/OMGAPI/Sources/OMGAPI/Responses/AccountInformationResponse.swift index e01d0bc..1f75ab3 100644 --- a/Packages/OMGAPI/Sources/OMGAPI/Responses/AccountInformationResponse.swift +++ b/Packages/OMGAPI/Sources/OMGAPI/Responses/AccountInformationResponse.swift @@ -16,7 +16,7 @@ public extension AccountInformationResponse { public let message: String public let email: String - public let name: String + public let name: String? public let created: Created } }