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
import Foundation | |
import UIKit | |
enum WidgetType { | |
case search | |
case banner | |
} | |
class Interactor { | |
func buildWidgets() { |
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
import Foundation | |
class Model { | |
let id: String | |
let link: String | |
let resizedLink: String | |
func toDao() -> ModelDAO { | |
let dao: ModelDAO = .init() | |
// properties injection |
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
import Foundation | |
// MARK: - Date Format & Components | |
extension Date { | |
// MARK: - Helper types | |
enum Format: String, CaseIterable { | |
/// 15/03/2022, 11:02 AM | |
case ddMMyyyyHHmmA = "dd/MM/yyyy, HH:mm a" | |
/// "18/10/1993" | |
case ddMMyyyySlashed = "dd/MM/yyyy" |
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
UserRouter.login(email: "[email protected]", password: "test12345").send(SwiftCairoUser.self) {[weak self] (response) in | |
switch response { | |
case .failure(let error): | |
// TODO: - Handle error as you want, printing isn't handling. | |
print(error) |
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
protocol HandleAlamoResponse { | |
/// Handles request response, never called anywhere but APIRequestHandler | |
/// | |
/// - Parameters: | |
/// - response: response from network request, for now alamofire Data response | |
/// - completion: completing processing the json response, and delivering it in the completion handler | |
func handleResponse<T: CodableInit>(_ response: DataResponse<Data>, completion: CallResponse<T>) | |
} | |
extension HandleAlamoResponse { |
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
protocol CodableInit { | |
init(data: Data) throws | |
} | |
extension CodableInit where Self: Codable { | |
init(data: Data) throws { |
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
/// Response completion handler beautified. | |
typealias CallResponse<T> = ((ServerResponse<T>) -> Void)? | |
/// API protocol, The alamofire wrapper | |
protocol APIRequestHandler: HandleAlamoResponse { | |
/// Calling network layer via (Alamofire), this implementation can be replaced anytime in one place which is the protocol itself, applied anywhere. |
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
enum UserRequest: URLRequestBuilder { | |
// 1 | |
case login(email: String, password: String) | |
case register(name: String, email: String, password: String, phone: String) | |
case userInfo | |
// MARK: - Path | |
internal var path: ServerPaths { | |
// 2 |
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
enum UserRequest: URLRequestBuilder { | |
case login(email: String, password: String) | |
case register(name: String, email: String, password: String, phone: String) | |
case userInfo | |
// MARK: - Path | |
internal var path: ServerPaths { | |
switch self { | |
case .login: |
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
enum ServerPaths: String { | |
case login | |
case register | |
case phoneActivation = "phone_activation" | |
case resendPhoneActivation = "resend_phone_activation_code" | |
case resendEmailLink = "send_reset_link_email" | |
case resetPassword = "reset_password" | |
case userInfo = "get_account_info" | |
case updateInfo = "update_account_info" | |
case userBalance = "get_user_internal_balance" |
NewerOlder