Skip to content

Latest commit

 

History

History
207 lines (141 loc) · 3.69 KB

File metadata and controls

207 lines (141 loc) · 3.69 KB

CLASS

StorageManager

Contents

  • Properties
    • knownDocTypes
    • docTypes
    • mdocModels
    • documentIds
    • hasData
    • hasWellKnownData
    • docCount
    • mdlModel
    • pidModel
    • otherModels
    • uiError
  • Methods
    • init(storageService:)
    • loadDocuments()
    • getDocumentModel(index:)
    • getDocumentModel(docType:)
    • deleteDocument(docType:)
    • deleteDocument(index:)
    • deleteDocuments()
public class StorageManager: ObservableObject

Storage manager. Provides services and view models

Properties

knownDocTypes

public static let knownDocTypes = [EuPidModel.euPidDocType, IsoMdlModel.isoDocType]

docTypes

public var docTypes: [String?] = []

Array of doc.types of documents loaded in the wallet

mdocModels

@Published public var mdocModels: [MdocDecodable?] = []

Array of document models loaded in the wallet

documentIds

public var documentIds: [String?] = []

Array of document identifiers loaded in the wallet

hasData

@Published public var hasData: Bool = false

Whether wallet currently has loaded data

hasWellKnownData

@Published public var hasWellKnownData: Bool = false

Whether wallet currently has loaded a document with doc.type included in the knownDocTypes array

docCount

@Published public var docCount: Int = 0

Count of documents loaded in the wallet

mdlModel

@Published public var mdlModel: IsoMdlModel?

The driver license model loaded in the wallet

pidModel

@Published public var pidModel: EuPidModel?

The PID model loaded in the wallet

otherModels

@Published public var otherModels: [GenericMdocModel] = []

Other document models loaded in the wallet

uiError

@Published public var uiError: WalletError?

Error object with localized message

Methods

init(storageService:)

public init(storageService: any DataStorageService)

loadDocuments()

@discardableResult public func loadDocuments() async throws -> [WalletStorage.Document]?

Load documents from storage

Internally sets the docTypes, mdocModels, documentIds, mdocModels, mdlModel, pidModel variables

  • Returns: An array of WalletStorage.Document objects

getDocumentModel(index:)

public func getDocumentModel(index: Int) -> MdocDecodable?

Get document model by index

  • Parameter index: Index in array of loaded models
  • Returns: The MdocDecodable model

Parameters

Name Description
index Index in array of loaded models

getDocumentModel(docType:)

public func getDocumentModel(docType: String) -> MdocDecodable?

Get document model by docType

  • Parameter docType: The docType of the document model to return
  • Returns: The MdocDecodable model

Parameters

Name Description
docType The docType of the document model to return

deleteDocument(docType:)

public func deleteDocument(docType: String) async throws

Delete document by docType

  • Parameter docType: Document type

Parameters

Name Description
docType Document type

deleteDocument(index:)

public func deleteDocument(index: Int) async throws

Delete document by Index

  • Parameter index: Index in array of loaded models

Parameters

Name Description
index Index in array of loaded models

deleteDocuments()

public func deleteDocuments() async throws

Delete documenmts