Created
March 29, 2021 12:40
-
-
Save Rashidium/383f9d3eef4011c305928075a39d96d0 to your computer and use it in GitHub Desktop.
CustomerDetailLink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public struct CustomerLink: AppLinkable { | |
| public var customerNo: Int64! | |
| init() { | |
| } | |
| init(customerNo: Int64) { | |
| self.customerNo = customerNo | |
| } | |
| public func getLinkable(_ url: URL) -> Self? { | |
| let string = url.path | |
| guard string.hasPrefix("/customer") else { return nil } | |
| let customerNoString = string | |
| .replacingOccurrences(of: "/customer", with: "") | |
| .replacingOccurrences(of: "/", with: "") | |
| guard let customerNo = Int64(customerNoString) else { return nil } | |
| return Self.init(customerNo: customerNo) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment