Skip to content

Instantly share code, notes, and snippets.

@agiguere
Last active August 24, 2020 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agiguere/00733bf45458b815e1b58a5926cdaa9f to your computer and use it in GitHub Desktop.
Save agiguere/00733bf45458b815e1b58a5926cdaa9f to your computer and use it in GitHub Desktop.
SAP OData Error Payload
import Foundation
// MARK: - ODataErrorPayload
public struct ODataErrorPayload: Decodable {
private enum CodingKeys: String, CodingKey {
case error
}
public let error: ODataError
}
// MARK: - ODataError
public struct ODataError: Decodable {
private enum CodingKeys: String, CodingKey {
case code
case message
case inner = "innererror"
}
public let code: String
public let message: ODataErrorMessage
public let inner: ODataInnerError
}
// MARK: - ODataErrorMessage
public struct ODataErrorMessage: Decodable {
private enum CodingKeys: String, CodingKey {
case language = "lang"
case value
}
public let language: String
public let value: String
}
// MARK: - ODataInnerError
public struct ODataInnerError: Decodable {
private enum CodingKeys: String, CodingKey {
case application
case transactionId = "transactionid"
case timestamp
case resolution = "Error_Resolution"
case details = "errordetails"
}
public let application: ODataErrorApplication
public let transactionId: String
public let timestamp: String
public let resolution: ODataErrorResolution
public let details: [ODataErrorDetails]
}
// MARK: - ODataErrorApplication
public struct ODataErrorApplication: Decodable {
private enum CodingKeys: String, CodingKey {
case componentId = "component_id"
case serviceNamespace = "service_namespace"
case serviceId = "service_id"
case serviceVersion = "service_version"
}
public let componentId: String
public let serviceNamespace: String
public let serviceId: String
public let serviceVersion: String
}
// MARK: - ODataErrorResolution
public struct ODataErrorResolution: Decodable {
private enum CodingKeys: String, CodingKey {
case transaction = "SAP_Transaction"
case note = "SAP_Note"
}
public let transaction: String
public let note: String
}
// MARK: - ODataErrorDetails
public struct ODataErrorDetails: Decodable {
private enum CodingKeys: String, CodingKey {
case code
case message
case propertyRef = "propertyref"
case severity
case transition
case target
}
public let code: String
public let message: String
public let propertyRef: String
public let severity: String
public let transition: Bool
public let target: String
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment