networkmanagertype

mail@pastecode.io avatar
unknown
swift
2 years ago
13 kB
1
Indexable
Never
//
//  NetworkManagerType.swift
//  eToto
//
//  Created by Hristo Hristov on 30.09.20.
//  Copyright © 2020 Mobile Wave Solutions. All rights reserved.
//

import UIKit

protocol NetworkManagerType {
    func invalidateTimers()
    func initializeTimers()
    typealias GetLiveOddsCompletion = (Result<[[String: Any]], Error>) -> ()
    typealias GetCategoriesCompletion = (Result<[SportCategory]?, Error>) -> ()
    typealias GetPopularCategoriesCompletion = (Result<[PopularCategoryModel], Error>) -> ()
    typealias GetEventCompletion = (Result<Eventful, Error>) -> ()
    typealias GetEventsCompletion<E: Eventful> = (Result<[E]?, Error>) -> ()
    typealias GetOfferEventsCompletion<E: Eventful, LE: Eventful> = (Result<([E]?,[LE]?), Error>) -> ()
    typealias GetUserCompletion = (Result<User, Error>) -> ()
    typealias GetStatScoreEventMappingCompletion = (Result<StatScoreMapping, Error>) -> ()
    typealias GetPotentialWinningCompletion = (Result<[String: Any], Error>) -> ()
    typealias GetTaxFactorCompletion = (Result<Double?, Error>) -> ()
    typealias PlaceBetCompletion = (Result<[String: Any], Error>) -> ()
    typealias FreebetCompletion = (Result<[Freebet], Error>) -> ()
    typealias CancelAllCreditBonusCompletion = (Result<[String: Any], Error>) -> ()
    typealias GetCarouselSegmentsCompletion = (Result<GetCarouselSegmentsModel, Error>) -> ()
    typealias GetActivePaymentProvidersCompletion = (Result<[PaymentProvider]?, Error>) -> ()
    typealias PostInitializePaymentCompletion = (Result<Void, Error>) -> ()
    typealias PostWithdrawalCancelation = (Result<Void, Error>) -> ()
    typealias PostProcessPaymentCompletion = (Result<String?, Error>) -> ()
    typealias GetCustomerBanksDetailCompletion = (Result<[BankDetail]?, Error>) -> ()
    typealias GetVirtualsWebURL = (Result<URL?, ETotoVirtualsBettingAPIError>) -> ()
    typealias ResetPasswordCompletion = (Result<Void, EtotoAPIError>) -> ()
    typealias LimitCompletion = (Result<[LimitRequestResponse], EtotoAPIError>) -> ()
    typealias AcceptRegulationsCompletion = (Result<Void, Error>) -> ()
    typealias GetUserDetailsCompletion = (Result<UserDetails?, Error>) -> ()
    typealias GetDocumentsCompletion = (Result<[ReceivedUserDocument], Error>) -> ()
    typealias CheckTradersDecision = (Result<[String: Any]?, Error>) -> ()
    typealias ApproveTraderChange = (Result<String?, Error>) -> ()
    typealias GetNotificationsSettingsCompletion = (Result<NotificationConfigRequestModel, EtotoAPIError>) -> ()
    typealias PostNotificationsSettingsCompletion = (Result<Void, EtotoAPIError>) -> ()
    typealias GetChatMessages = (Result<[ChatMessage], EtotoAPIError>) -> ()
    typealias GetEventsValidForSubscriptionCompletion = (Result<EventsValidForSubscriptionModel, Error>) -> ()
    typealias GetSubscribedEventsCompletion = (Result<SubscribedEventsModel, Error>) -> ()
    typealias SubscribeToEventCompletion = (Result<SubscribeToEventModel, Error>) -> ()
    typealias GetPaymentMethodsCompletion = (Result<GetPaymentMethodsResponse, EtotoAPIError>) -> ()
    typealias StartPaymentCompletion = (Result<PostStartPaymentResponse, EtotoAPIError>) -> ()
    typealias RemoveCardTokenCompletion = (Result<Void, EtotoAPIError>) -> ()
    typealias GetStatusCompletion = (Result<GetPaymentStatusModel, EtotoAPIError>) -> ()

    var user: Observer<User?> { get }
    var fastBettingImage: Observer<UIImage?> { get }
    var lastUser: User? { get }

    @discardableResult
    func checkTradersDecision(completion: @escaping CheckTradersDecision) -> URLSessionDataTask?

    @discardableResult
    func approveTraderChange(approved: Bool, completion: @escaping ApproveTraderChange) -> URLSessionDataTask?

    @discardableResult
    func getLiveOdds(odds: [String], completion: @escaping GetLiveOddsCompletion) -> URLSessionDataTask?

    @discardableResult
    func resetPassword(email: String, completion: @escaping ResetPasswordCompletion) -> URLSessionDataTask?

    @discardableResult
    func placeBet(body: [String: Any], completion: @escaping PlaceBetCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func notifyTraderForBetWith(body: [String: Any], completion: @escaping PlaceBetCompletion) -> URLSessionDataTask?

    @discardableResult
    func getFreebets(completion: @escaping FreebetCompletion) -> URLSessionDataTask?

    @discardableResult
    func cancelAllCreditBonus(completion: @escaping CancelAllCreditBonusCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func getPotentialWinnings(body: [String: Any], completion: @escaping GetPotentialWinningCompletion) -> URLSessionDataTask?

    @discardableResult
    func getTaxFactor(body: [String: Any], completion: @escaping GetTaxFactorCompletion) -> URLSessionDataTask?

    typealias GetEmptyCompletion = (Result<Void, Error>) -> ()
    typealias GetValidationCompletion = (Result<[String], Error>) -> ()

    @discardableResult
    func getCategories(completion: @escaping GetCategoriesCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func getSubCategories(category: Int16,
                          completion: @escaping GetCategoriesCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func getEvent(eventID: Int,
                  completion: @escaping GetEventCompletion) -> URLSessionDataTask?

    @discardableResult
    func getEvents(category: Int16,
                   completion: @escaping GetEventsCompletion<Event>) -> URLSessionDataTask?
    
    @discardableResult
    func getEvents(categories: [Int16],
                   completion: @escaping GetEventsCompletion<Event>) -> URLSessionDataTask?
    
    @discardableResult
    func getImage(categoryID: String,
                  settings: Settings,
                  completion: @escaping (UIImage?) -> ()) -> URLSessionDataTask?
    
    @discardableResult
    func getEvents(withSearchPattern pattern: String,
                   completion: @escaping GetOfferEventsCompletion<Event,LiveEvent>) -> URLSessionDataTask?

    @discardableResult
    func getLiveSports(completion: @escaping GetCategoriesCompletion) -> URLSessionDataTask?

    @discardableResult
    func getLiveEvents(sportID: Int16,
                       completion: @escaping GetEventsCompletion<LiveEvent>) -> URLSessionDataTask?
    
    @discardableResult
    func getLiveEventsForDate(dateString: String, completion: @escaping GetEventsCompletion<Event>) -> URLSessionDataTask?
    
    @discardableResult
    func getLiveEvent(eventID: Int, completion: @escaping GetEventCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func loginUser(name: String?, password: String?,
                   completion: GetUserCompletion?) -> URLSessionDataTask?
    
    @discardableResult
    func loggedInUser(completion: GetUserCompletion?) -> URLSessionDataTask?
    @discardableResult
    func loggedInUser() -> URLSessionDataTask?
    
    @discardableResult
    func logoutUser(completion: @escaping (Result<Bool, Error>) -> ()) -> URLSessionDataTask?

    @discardableResult
    func changePassword(new: String,
                        old: String,
                        completion: @escaping (Result<Bool, Error>) -> ()) -> URLSessionDataTask?

    @discardableResult
    func getStatScoreEventMapping(completion: @escaping GetStatScoreEventMappingCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func transactions(from: Date, to: Date,
                      pageSize size: Int?, offset: Int?,
                      completion: @escaping (Result<[Transaction]?, Error>) -> Void) -> URLSessionDataTask?
    
    @discardableResult
    func transactionsWithdrawStatus(pageSize size: Int?, offset: Int?,
                      completion: @escaping (Result<[Transaction]?, Error>) -> Void) -> URLSessionDataTask?
    
    @discardableResult
    func cancelTransactionWithdrawal(transactionID: Int?,
                                     completion: @escaping (Result<Void, Error>) -> ()) -> URLSessionDataTask?
    
    @discardableResult
    func placedBets(from: Date, to: Date, size: Int, status: PlacedBet.Status?, offset: Int,
                    completion: @escaping (Result<([PlacedBet]?, Int?), Error>) -> Void) -> URLSessionWork?
    
    @discardableResult
    func checkAndCashout(betWith id: Int, amount: Double, acceptedChanges: Bool,
                    completion: @escaping (Result<Double, CashoutError>) -> ()) -> URLSessionWork?
    
    @discardableResult
    func getActivePaymentProviders(completion: @escaping GetActivePaymentProvidersCompletion) -> URLSessionDataTask?

    @discardableResult
    func baseRegistration(baseRegistration: BaseRegistration, completion: @escaping GetEmptyCompletion) -> URLSessionDataTask?

    @discardableResult
    func detailsRegistration(detailsRegistration: DetailsRegistration, completion: @escaping GetEmptyCompletion) -> URLSessionDataTask?

    @discardableResult
    func personalIDValidation(personalID: String, completion: @escaping GetValidationCompletion) -> URLSessionDataTask?

    @discardableResult
    func dateValidation(date: String, completion: @escaping GetValidationCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func iDNumberValidation(iDNumber: String, completion: @escaping GetValidationCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func bonusValidation(completion: @escaping GetValidationCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func initializePayment(providerId: Int,
                           transactionAmount: Decimal,
                           transactionCurrency:String,
                           completion: @escaping PostInitializePaymentCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func processPayment(providerId: Int,
                        transactionAmount: Double,
                        transactionCurrency: String,
                        callbackUrl: String,
                        bankDetail: BankDetail?,
                        completion: @escaping PostProcessPaymentCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func customerBanksDetail(_ completion: @escaping GetCustomerBanksDetailCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func getVirtualsWebURL(query: [URLQueryItem]?, completion: @escaping GetVirtualsWebURL) -> URLSessionDataTask?
    
    @discardableResult
    func setLimits(limits: [LimitRequestBody], completion: @escaping LimitCompletion) -> URLSessionDataTask?
    @discardableResult
    func limits(completion: @escaping (Result<[Limits]?, Error>) -> Void) -> URLSessionDataTask?
    @discardableResult
    func activate(_ limitation: Limits.Limitation,
                  completion: @escaping (Result<[Limits]?, Error>) -> Void) -> URLSessionDataTask?
    
    @discardableResult
    func acceptRegulations(completion: @escaping AcceptRegulationsCompletion) -> URLSessionDataTask?

    @discardableResult
    func getUserDetails(completion: @escaping GetUserDetailsCompletion) -> URLSessionDataTask?

    @discardableResult
    func postUserDetails(userDetails: UserDetails.User, completion: @escaping GetEmptyCompletion) -> URLSessionDataTask?

    @discardableResult
    func manulalUserConversion(userManualConversion: UserManualConversion, completion: @escaping GetEmptyCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func getDocuments(completion: @escaping GetDocumentsCompletion) -> URLSessionDataTask?

    @discardableResult
    func virtualsHistory(from: Date,
                         to: Date,
                         completion: @escaping (Result<[PlacedBet]?, Error>) -> Void) -> URLSessionWork?

    @discardableResult
    /// This method should be used only upon user actions where balance update should happen immediately
    /// because of high performance usage on server side
        func forceUpdateBalance(force: Bool, completion: (() -> ())?) -> URLSessionDataTask?
    
    /// Use this method for football events. They are cached internally and updated upon every five seconds
    func cachedFootballEvents() -> [Event]?

    @discardableResult
    func refreshChat(channelId: Int, completion: @escaping GetChatMessages) -> URLSessionDataTask?

    @discardableResult
    func refreshChatOnChange(channelId: Int, lastId: Int, completion: @escaping GetChatMessages) -> URLSessionDataTask?

    @discardableResult
    func postChatMessage(messageBody: MessageBody, completion: @escaping GetEmptyCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func getEventsValidForSubscription(completion: @escaping GetEventsValidForSubscriptionCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func getSubscribedEvents(completion: @escaping GetSubscribedEventsCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func subscribeToEvent(eventId:Int,completion: @escaping SubscribeToEventCompletion) -> URLSessionDataTask?
    
    @discardableResult
    func unsubscribeFromEvent(eventId:Int,completion: @escaping SubscribeToEventCompletion) -> URLSessionDataTask?
}