<commit_before>//
//  AppOpenMockRepository.swift
//  NStackSDK
//
//  Created by <NAME> on 03/07/2019.
//  Copyright © 2019 Nodes ApS. All rights reserved.
//

import Foundation

#if os(iOS)
import UIKit
import TranslationManager
#elseif os(tvOS)
import TranslationManager_tvOS
#elseif os(watchOS)
import TranslationManager_watchOS
#elseif os(macOS)
import TranslationManager_macOS
#endif

class MockConnectionManager: Repository {

    func fetchPreferredLanguages() -> [String] {
        return []
    }

    func getLocalizationBundles() -> [Bundle] {
        return []
    }

    func fetchCurrentPhoneLanguage() -> String? {
        return nil
    }

    func getLocalizationConfig<C>(acceptLanguage: String, lastUpdated: Date?, completion: @escaping (Result<[C]>) -> Void) where C: LocalizationModel {

    }

    func getTranslations<L>(localization: LocalizationModel, acceptLanguage: String, completion: @escaping (Result<TranslationResponse<L>>) -> Void) where L: LanguageModel {
        let translationsResponse: TranslationResponse<Language>? = TranslationResponse(translations: [
            "default": ["successKey": "SuccessUpdated"],
            "otherSection": ["anotherKey": "HeresAValue"]
            ], meta: TranslationMeta(language: Language(id: 1, name: "English",
                                                        direction: "LRM", acceptLanguage: "en-GB",
                                                        isDefault: true, isBestFit: true)))

        let result: Result = .success(translationsResponse!)
        completion(result as! Result<TranslationResponse<L>>)
    }

    func getAvailableLanguages<L>(completion: @escaping (Result<[L]>) -> Void) where L: LanguageModel {

    }

    func fetchUpdates(oldVersion: String, currentVersion: String, completion: @escaping Completion<Update>) {

    }

    func fetchContinents(completion: @escaping Completion<[Continent]>) {

    }

    func fetchCountries(completion: @escaping Completion<[Country]>) {
        let countryArray = [Country(id: 1,
                                               name: "",
                                               code: "",
                                               codeIso: "", native: "", phone: 1, continent: "",
                                               capital: "", capitalLat: 1.0, capitalLng: 1.0,
                                               currency: "", currencyName: "", languages: "",
                                               image: nil,
                                               imagePath2: nil,
                                               capitalTimeZone: NStackSDK.Timezone(id: 1,
                                                                                   name: "",
                                                                                   abbreviation: "",
                                                                                   offsetSec: 12,
                                                                                   label: ""))]
        let result: Result = .success(countryArray)
        completion(result)
    }

    func fetchLanguages(completion: @escaping Completion<[Language]>) {

    }

    func fetchTimeZones(completion: @escaping Completion<[Timezone]>) {

    }

    func fetchTimeZone(lat: Double, lng: Double, completion: @escaping Completion<Timezone>) {

    }

    func fetchIPDetails(completion: @escaping Completion<IPAddress>) {
        let result: Result = .success(IPAddress(ipStart: "_ipStart",
                                                ipEnd: "", country: "", stateProv: "", city: "", lat: "", lng: "", timeZoneOffset: "", timeZoneName: "", ispName: "", connectionType: "", type: "", requestedIp: ""))
        completion(result)
    }

    func validateEmail(_ email: String, completion: @escaping Completion<Validation>) {
        let result: Result = .success(Validation(ok: true))
        completion(result)
    }

    struct Person: Swift.Codable {
        var firstName: String
        var lastName: String
    }

    func fetchStaticResponse<T>(_ slug: String, completion: @escaping ((Result<T>) -> Void)) where T: Decodable, T: Encodable {
        let number: Int = 12
        let result: Result = .success(number)
        completion(result as! Result<T>)
    }

    func fetchCollection<T>(_ id: Int, completion: @escaping ((Result<T>) -> Void)) where T: Decodable, T: Encodable {
        let number: Int = 12
        let result: Result = .success(number)
        completion(result as! Result<T>)
    }

    func markWhatsNewAsSeen(_ id: Int) {

    }

    func markMessageAsRead(_ id: Int) {

    }

    func markRateReminderAsSeen(_ answer: AlertManager.RateReminderResult) {

    }

    func storeProposal(section: String, key: String, value: String, locale: String, completion: @escaping Completion<Proposal>) {

    }

    func fetchProposals(completion: @escaping Completion<[Proposal]>) {

    }

    func deleteProposal(_ proposal: Proposal, completion: @escaping (Result<ProposalDeletion>) -> Void) {

    }
}

extension MockConnectionManager {
    func postAppOpen(oldVersion: String, currentVersion: String, acceptLanguage: String?, completion: @escaping Completion<AppOpenResponse>) {
        let lang = Language(id: 56, name: "English", direction: "LRM", acceptLanguage: "en_EN", isDefault: true, isBestFit: false)
        let data = AppOpenData(count: 58,
                               message: nil,
                               update: nil,
                               rateReminder: nil,
                               localize: [
                                Localization(id: 56, url: "locazlize.56.url", lastUpdatedAt: "2019-06-21T14:10:29+00:00", shouldUpdate: true, language: lang),
                                Localization(id: 56, url: "locazlize.56.url", lastUpdatedAt: "2019-06-21T14:10:29+00:00", shouldUpdate: true, language: lang)],
                               platform: "ios",
                               createdAt: "2019-06-21T14:10:29+00:00",
                               lastUpdated: "2019-06-21T14:10:29+00:00")

        let response = AppOpenResponse(data: data, languageData: LanguageData(acceptLanguage: "da-DK"))
        completion(.success(response))
    }<commit_msg>test fix to set best fit<commit_after>//
//  AppOpenMockRepository.swift
//  NStackSDK
//
//  Created by <NAME> on 03/07/2019.
//  Copyright © 2019 Nodes ApS. All rights reserved.
//

import Foundation

#if os(iOS)
import UIKit
import TranslationManager
#elseif os(tvOS)
import TranslationManager_tvOS
#elseif os(watchOS)
import TranslationManager_watchOS
#elseif os(macOS)
import TranslationManager_macOS
#endif

class MockConnectionManager: Repository {

    func fetchPreferredLanguages() -> [String] {
        return []
    }

    func getLocalizationBundles() -> [Bundle] {
        return []
    }

    func fetchCurrentPhoneLanguage() -> String? {
        return nil
    }

    func getLocalizationConfig<C>(acceptLanguage: String, lastUpdated: Date?, completion: @escaping (Result<[C]>) -> Void) where C: LocalizationModel {

    }

    func getTranslations<L>(localization: LocalizationModel, acceptLanguage: String, completion: @escaping (Result<TranslationResponse<L>>) -> Void) where L: LanguageModel {
        let translationsResponse: TranslationResponse<Language>? = TranslationResponse(translations: [
            "default": ["successKey": "SuccessUpdated"],
            "otherSection": ["anotherKey": "HeresAValue"]
            ], meta: TranslationMeta(language: Language(id: 1, name: "English",
                                                        direction: "LRM", acceptLanguage: "en-GB",
                                                        isDefault: true, isBestFit: true)))

        let result: Result = .success(translationsResponse!)
        completion(result as! Result<TranslationResponse<L>>)
    }

    func getAvailableLanguages<L>(completion: @escaping (Result<[L]>) -> Void) where L: LanguageModel {

    }

    func fetchUpdates(oldVersion: String, currentVersion: String, completion: @escaping Completion<Update>) {

    }

    func fetchContinents(completion: @escaping Completion<[Continent]>) {

    }

    func fetchCountries(completion: @escaping Completion<[Country]>) {
        let countryArray = [Country(id: 1,
                                               name: "",
                                               code: "",
                                               codeIso: "", native: "", phone: 1, continent: "",
                                               capital: "", capitalLat: 1.0, capitalLng: 1.0,
                                               currency: "", currencyName: "", languages: "",
                                               image: nil,
                                               imagePath2: nil,
                                               capitalTimeZone: NStackSDK.Timezone(id: 1,
                                                                                   name: "",
                                                                                   abbreviation: "",
                                                                                   offsetSec: 12,
                                                                                   label: ""))]
        let result: Result = .success(countryArray)
        completion(result)
    }

    func fetchLanguages(completion: @escaping Completion<[Language]>) {

    }

    func fetchTimeZones(completion: @escaping Completion<[Timezone]>) {

    }

    func fetchTimeZone(lat: Double, lng: Double, completion: @escaping Completion<Timezone>) {

    }

    func fetchIPDetails(completion: @escaping Completion<IPAddress>) {
        let result: Result = .success(IPAddress(ipStart: "_ipStart",
                                                ipEnd: "", country: "", stateProv: "", city: "", lat: "", lng: "", timeZoneOffset: "", timeZoneName: "", ispName: "", connectionType: "", type: "", requestedIp: ""))
        completion(result)
    }

    func validateEmail(_ email: String, completion: @escaping Completion<Validation>) {
        let result: Result = .success(Validation(ok: true))
        completion(result)
    }

    struct Person: Swift.Codable {
        var firstName: String
        var lastName: String
    }

    func fetchStaticResponse<T>(_ slug: String, completion: @escaping ((Result<T>) -> Void)) where T: Decodable, T: Encodable {
        let number: Int = 12
        let result: Result = .success(number)
        completion(result as! Result<T>)
    }

    func fetchCollection<T>(_ id: Int, completion: @escaping ((Result<T>) -> Void)) where T: Decodable, T: Encodable {
        let number: Int = 12
        let result: Result = .success(number)
        completion(result as! Result<T>)
    }

    func markWhatsNewAsSeen(_ id: Int) {

    }

    func markMessageAsRead(_ id: Int) {

    }

    func markRateReminderAsSeen(_ answer: AlertManager.RateReminderResult) {

    }

    func storeProposal(section: String, key: String, value: String, locale: String, completion: @escaping Completion<Proposal>) {

    }

    func fetchProposals(completion: @escaping Completion<[Proposal]>) {

    }

    func deleteProposal(_ proposal: Proposal, completion: @escaping (Result<ProposalDeletion>) -> Void) {

    }
}

extension MockConnectionManager {
    func postAppOpen(oldVersion: String, currentVersion: String, acceptLanguage: String?, completion: @escaping Completion<AppOpenResponse>) {
        let lang = Language(id: 56, name: "English", direction: "LRM", acceptLanguage: "en-GB", isDefault: true, isBestFit: true)
        let data = AppOpenData(count: 58,
                               message: nil,
                               update: nil,
                               rateReminder: nil,
                               localize: [
                                Localization(id: 56, url: "locazlize.56.url", lastUpdatedAt: "2019-06-21T14:10:29+00:00", shouldUpdate: true, language: lang),
                                Localization(id: 56, url: "locazlize.56.url", lastUpdatedAt: "2019-06-21T14:10:29+00:00", shouldUpdate: true, language: lang)],
                               platform: "ios",
                               createdAt: "2019-06-21T14:10:29+00:00",
                               lastUpdated: "2019-06-21T14:10:29+00:00")

        let response = AppOpenResponse(data: data, languageData: LanguageData(acceptLanguage: "da-DK"))
        completion(.success(response))
    }
{'fraction_non_alphanumeric': 0.11115537848605578, 'fraction_numerical': 0.017689243027888445, 'mean_word_length': 1.8899378309924015, 'pattern_counts': {'":': 8, '<': 61, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 68, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6535620', 'n_tokens_mistral': 3416, 'n_tokens_neox': 3090, 'n_words': 771}