Untitled
unknown
swift
a year ago
3.3 kB
2
Indexable
Never
public typealias MvnoAPICompletion<Model: Decodable, ErrorPayload: Decodable> = (MvnoAPIResult<Model, ErrorPayload>) -> Void /// Represents a MVNO API result. public typealias MvnoAPIResult<Model: Decodable, ErrorPayload: Decodable> = APIProcessingResult<MvnoResponse<Model>, MvnoErrorResponse<ErrorPayload>> public protocol IMvnoRequest: IAPIRequest where Error == MvnoErrorResponse<ErrorPayload>, Response == MvnoResponse<Payload> { /// Response payload type. associatedtype Payload: Decodable /// Error response payload type. associatedtype ErrorPayload: Decodable } public protocol IMvnoAPI: AnyObject { /// Gets mvno session holder func execute<Request: IMvnoRequest>( request: Request, completion: @escaping MvnoAPICompletion<Request.Payload, Request.ErrorPayload>) } public struct MvnoErrorResponse<Payload: Decodable>: LocalizedError, Decodable { /// Gets the response result code. public let resultCode: ResultCode /// Gets the error code. public let code: MvnoErrorCode /// Gets the error message. public let message: String? /// Gets the error payload. public let payload: Payload? /// Gets the error details. public let error: Details? /// Gets the response tracking identifier. public let trackingId: String public var errorDescription: String? { message } } public extension MvnoErrorResponse { /// Represents a MVNO error result code. enum ResultCode { /// The error occured. case error } /// Represents a MVNO TARS error details. struct Details: Decodable { /// Gets the error message. let message: String /// gets the error code. let code: String } } /// Represents a MVNO TAPI error code. public enum MvnoErrorCode { /// The server internal error. case internalError /// The lifetime of session expired. case sessionIsAbsent /// Not enough privileges case insufficientPrivileges /// Already signed error case alreadySigned /// Contact not found case siebelIdNotFound /// eSim out of stock case eSimSoldOut /// eSim unavailable case eSimUnavailable /// User is under 18 or backend doesn't know user's age case invalidAge /// The error code does not exists. /// - Important: This is an application error. case codeDoesNotExists /// введен неверный код, ошибка case confirmationFailed /// код просрочен, необходимо запросить новый case confirmationExpired /// превышено количество ошибок case requestRateLimitExceeded /// заявка не найдена case applicationNotFound /// для аккаунта не была пройдена верификация в Госуслугах case unverifiedAccount /// несовпадении ПД, полученных из Госуслуг и из ТСРМ case wrongEsiaUser /// аккаунт на Госуслугах удален case deletedAccount /// не найден параметер case parameterMissing /// The unknown error occured. /// - Important: This is an application error. case unknown(code: String) }