Skip to content

Lets Customize LetSee 🎉🎉

Compare
Choose a tag to compare
@valentinjahanmanesh valentinjahanmanesh released this 18 Jan 19:07
· 20 commits to main since this release

We made it public, all the protocols can be implemented to customize LetSee

struct JsonFileParser: FileNameParsing {
   func parse(_ filePath: FileInformation) throws -> MockFileInformation {
       let fileName = filePath.name.hasSuffix(".json") ? String(filePath.name.dropLast(5)) : filePath.name
       let type: MockFileInformation.MockStatus = fileName.hasPrefix("error_") ? .failure : .success
       let fileInformation = MockFileInformation(fileInformation: filePath,
                                                 statusCode: nil,
                                                 delay: nil,
                                                 status: type,
                                                 displayName: fileName)
       return fileInformation
   }
}
// injects LetSee, this object will be replaced by the default implementation. 
// no need to store this object, LetSee will keep it strongly itself and it is accessible by LetSee.shared
let letSee = LetSee(jsonFileParser: JsonFileParser())
LetSee.injectLetSee(letSee)