Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 1 addition & 64 deletions Modules/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ let package = Package(
url: "https://github.com/wordpress-mobile/NSURL-IDN",
revision: "b34794c9a3f32312e1593d4a3d120572afa0d010"
),
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.20.1"),
.package(
url: "https://github.com/automattic/wordpress-rs",
Expand Down Expand Up @@ -579,7 +578,6 @@ enum XcodeSupport {
.product(name: "SVProgressHUD", package: "SVProgressHUD"),
.product(name: "SwiftSoup", package: "SwiftSoup"),
.product(name: "UIDeviceIdentifier", package: "UIDeviceIdentifier"),
.product(name: "ZendeskSupportSDK", package: "support_sdk_ios"),
.product(name: "ZIPFoundation", package: "ZIPFoundation"),
.product(name: "WordPressAPI", package: "wordpress-rs"),
.product(name: "ColorStudio", package: "color-studio"),
Expand Down
16 changes: 0 additions & 16 deletions Modules/Sources/BuildSettingsKit/BuildSecrets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,16 @@ public struct BuildSecrets: Sendable {
}
}

public struct Zendesk: Sendable {
public let appId: String
public let url: String
public let clientId: String

public init(appId: String, url: String, clientId: String) {
self.appId = appId
self.url = url
self.clientId = clientId
}
}

public let oauth: OAuth
public let zendesk: Zendesk
public let encryptedLogsKey: String
public let debuggingKey: String

public init(
oauth: OAuth,
zendesk: Zendesk,
encryptedLogsKey: String,
debuggingKey: String
) {
self.oauth = oauth
self.zendesk = zendesk
self.encryptedLogsKey = encryptedLogsKey
self.debuggingKey = debuggingKey
}
Expand All @@ -44,7 +29,6 @@ extension BuildSecrets {

public static let dummy = BuildSecrets(
oauth: .init(client: "", secret: ""),
zendesk: .init(appId: "", url: "", clientId: ""),
encryptedLogsKey: "",
debuggingKey: ""
)
Expand Down
2 changes: 0 additions & 2 deletions Modules/Sources/BuildSettingsKit/BuildSettings+Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ extension BuildSettings {
about = ProductAboutDetails(
blogURL: bundle.urlValue(forKey: "WPProductBlogURL")
)
zendeskSourcePlatform = bundle.infoValue(forKey: "WPZendeskSourcePlatform")
mobileAnnounceAppID = bundle.infoValue(forKey: "WPMobileAnnounceAppID")
authKeychainServiceName = bundle.infoValue(forKey: "WPAuthKeychainServiceName")
// The plist does not carry the URL scheme because the C preprocessor treats the `//` as a comment resulting in a truncated value.
sentryDSN = "https://" + bundle.infoValue(forKey: "WPSentryNoSchemeDSN")
docsBotId = bundle.infoValue(forKey: "WPDocsBotId")
}
}

Expand Down
4 changes: 1 addition & 3 deletions Modules/Sources/BuildSettingsKit/BuildSettings+Preview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ extension BuildSettings {
about: ProductAboutDetails(
blogURL: URL(string: "www.example.com")!
),
zendeskSourcePlatform: "zen",
mobileAnnounceAppID: "1234567890",
authKeychainServiceName: "public-api.wordpress.com",
sentryDSN: "",
docsBotId: ""
sentryDSN: ""
)
}

Expand Down
5 changes: 0 additions & 5 deletions Modules/Sources/BuildSettingsKit/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ public struct BuildSettings: Sendable {
public var appURLScheme: String
public var jetpackAppURLScheme: String
public var about: ProductAboutDetails
public var zendeskSourcePlatform: String
public var mobileAnnounceAppID: String
public var authKeychainServiceName: String
/// See [Sentry: DSN utilization](https://docs.sentry.io/concepts/key-terms/dsn-explainer/#dsn-utilization)
public var sentryDSN: String
/// Empty outside Jetpack, the only app that presents the support chat bot.
///
/// See [DocsBot: Embeddable Chat Widget](https://docsbot.ai/documentation/developer/embeddable-chat-widget)
public var docsBotId: String

public struct ProductAboutDetails: Sendable {
public var blogURL: URL
Expand Down
87 changes: 0 additions & 87 deletions Modules/Sources/WordPressKit/PlanServiceRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,76 +44,8 @@ open class PlanServiceRemote: ServiceRemoteWordPressComREST {
})
}

/// Fetch the plan ID and name for each of the user's sites.
/// Accepts locale as a parameter in order to override automatic localization
/// and return non-localized results when needed.
///
public func getPlanDescriptionsForAllSitesForLocale(_ locale: String, success: @escaping ([Int: RemotePlanSimpleDescription]) -> Void, failure: @escaping (Error) -> Void) {
let endpoint = "me/sites"
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)
let parameters: [String: String] = [
"fields": "ID, plan",
"locale": locale
]

wordPressComRESTAPI.get(path,
parameters: parameters as [String: AnyObject],
success: {
response, _ in

guard let response = response as? EndpointResponse else {
failure(PlanServiceRemote.ResponseError.decodingFailure)
return
}

let result = self.parsePlanDescriptionsForSites(response)
success(result)
},
failure: {
error, _ in
failure(error)
})
}

// MARK: - Non-public methods

func parsePlanDescriptionsForSites(_ response: EndpointResponse) -> [Int: RemotePlanSimpleDescription] {
var result = [Int: RemotePlanSimpleDescription]()

guard let sites = response["sites"] as? [EndpointResponse] else {
return result
}

for site in sites {
guard
let tpl = parsePlanDescriptionForSite(site)
else {
continue
}
result[tpl.siteID] = tpl.plan
}

return result
}

func parsePlanDescriptionForSite(_ site: EndpointResponse) -> (siteID: Int, plan: RemotePlanSimpleDescription)? {
guard
let siteID = site["ID"] as? Int,
let plan = site["plan"] as? EndpointResponse,
let planID = plan["product_id"] as? Int,
let planName = plan["product_name_short"] as? String,
let planSlug = plan["product_slug"] as? String else {
return nil
}

var name = planName
if planSlug.contains("jetpack") {
name = name + " (Jetpack)"
}

return (siteID, RemotePlanSimpleDescription(planID: planID, name: name))
}

func parseWpcomPlans(_ response: EndpointResponse) -> [RemoteWpcomPlan] {
guard let json = response["plans"] as? [EndpointResponse] else {
return [RemoteWpcomPlan]()
Expand Down Expand Up @@ -190,23 +122,4 @@ open class PlanServiceRemote: ServiceRemoteWordPressComREST {
}
return RemotePlanFeature(slug: slug, title: title, description: description, iconURL: nil)
}

/// Retrieves Zendesk meta data: plan and Jetpack addons, if available
open func getZendeskMetadata(siteID: Int, completion: @escaping (Result<ZendeskMetadata, Error>) -> Void) {
let endpoint = "me/sites"
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)
let parameters = ["fields": "ID, zendesk_site_meta"] as [String: AnyObject]

Task { @MainActor [wordPressComRestApi] in
await wordPressComRestApi.perform(.get, URLString: path, parameters: parameters, type: ZendeskSiteContainer.self)
.eraseToError()
.flatMap { container in
guard let metadata = container.body.sites.first(where: { $0.ID == siteID })?.zendeskMetadata else {
return .failure(PlanServiceRemoteError.noMetadata)
}
return .success(metadata)
}
.execute(completion)
}
}
}
5 changes: 0 additions & 5 deletions Modules/Sources/WordPressKit/RemoteWpcomPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,3 @@ public struct RemotePlanFeature {
// Deprecated. An icon associeated with the feature.
public let iconURL: URL?
}

public struct RemotePlanSimpleDescription {
public let planID: Int
public let name: String
}
35 changes: 0 additions & 35 deletions Modules/Sources/WordPressKit/ZendeskMetadata.swift

This file was deleted.

Loading