Skip to content

Commit

Permalink
Remove unused code in Zendesk utils (#22651)
Browse files Browse the repository at this point in the history
  • Loading branch information
guarani authored Feb 21, 2024
2 parents b3d4674 + 8621500 commit a2aacfc
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions WordPress/Classes/Utility/ZendeskUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1004,46 +1004,6 @@ private extension ZendeskUtils {

// MARK: - Plans

/// Retrieves the highest priority plan, if it exists
/// - Returns: the highest priority plan found, or an empty string if none was found
private func getHighestPriorityPlan(planService: PlanService? = nil) -> String {

let availablePlans = getAvailablePlansWithPriority(planService: planService)
if !ZendeskUtils.sharedInstance.sitePlansCache.isEmpty {
let plans = Set(ZendeskUtils.sharedInstance.sitePlansCache.values.compactMap { $0.name })

for availablePlan in availablePlans {
if plans.contains(availablePlan.nonLocalizedName) {
return availablePlan.supportName
}
}
} else {
// fail safe: if the plan cache call fails for any reason, at least let's use the cached blogs
// and compare the localized names
let plans = Set(((try? BlogQuery().blogs(in: contextManager.mainContext)) ?? []).compactMap { $0.planTitle })

for availablePlan in availablePlans {
if plans.contains(availablePlan.name) {
return availablePlan.supportName
}
}
}
return ""
}

/// Obtains the available plans, sorted by priority
private func getAvailablePlansWithPriority(planService: PlanService? = nil) -> [SupportPlan] {
let planService = planService ?? PlanService(coreDataStack: contextManager)
return planService.allPlans(in: contextManager.mainContext).map {
SupportPlan(priority: $0.supportPriority,
name: $0.shortname,
nonLocalizedName: $0.nonLocalizedShortname,
supportName: $0.supportName)

}
.sorted { $0.priority > $1.priority }
}

/// Retrieves up to date Zendesk metadata from the backend
/// - Parameters:
/// - planServiceRemote: optional plan service remote. The default is used if none is passed
Expand Down Expand Up @@ -1088,27 +1048,6 @@ private extension ZendeskUtils {
return Int(truncating: siteID)
}

struct SupportPlan {
let priority: Int
let name: String
let nonLocalizedName: String
let supportName: String

// used to resolve discrepancies of unlocalized names between endpoints
let mappings = ["E-commerce": "eCommerce"]

init(priority: Int16,
name: String,
nonLocalizedName: String,
supportName: String) {

self.priority = Int(priority)
self.name = name
self.nonLocalizedName = mappings[nonLocalizedName] ?? nonLocalizedName
self.supportName = supportName
}
}

// MARK: - Constants

struct Constants {
Expand Down

0 comments on commit a2aacfc

Please sign in to comment.