Skip to content

Commit

Permalink
Update some of the public APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Jul 13, 2024
1 parent eee1e01 commit ed81029
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ let package = Package(
targets: [
.binaryTarget(
name: "WordPressKit",
url: "https://github.com/user-attachments/files/16200320/WordPressKit.zip",
checksum: "fa2ddc1fedcc225beb23d23168043bd78bbd12d43e187cc0dd772aef8d81ee20"
url: "https://github.com/user-attachments/files/16200425/WordPressKit.zip",
checksum: "3ec44e1f08dea7851c9e52784e9378948a3fabc1742eced9e281305c23908343"
),
]
)
4 changes: 2 additions & 2 deletions Sources/CoreAPI/HTTPRequestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Foundation
///
/// Calling this class's url related functions (the ones that changes path, query, etc) does not modify the
/// original URL string. The URL will be perserved in the final result that's returned by the `build` function.
final class HTTPRequestBuilder {
enum Method: String, CaseIterable {
public final class HTTPRequestBuilder {
public enum Method: String, CaseIterable {
case get = "GET"
case post = "POST"
case put = "PUT"
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreAPI/WordPressAPIError.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public enum WordPressAPIError<EndpointError>: Error where EndpointError: LocalizedError {
@frozen public enum WordPressAPIError<EndpointError>: Error where EndpointError: LocalizedError {
static var unknownErrorMessage: String {
NSLocalizedString(
"wordpress-api.error.unknown",
Expand Down
4 changes: 2 additions & 2 deletions Sources/CoreAPI/WordPressComRestApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ open class WordPressComRestApi: NSObject {
return configuration
}

func perform(
open func perform(
_ method: HTTPRequestBuilder.Method,
URLString: String,
parameters: [String: AnyObject]? = nil,
Expand All @@ -373,7 +373,7 @@ open class WordPressComRestApi: NSObject {
}
}

func perform<T: Decodable>(
open func perform<T: Decodable>(
_ method: HTTPRequestBuilder.Method,
URLString: String,
parameters: [String: AnyObject]? = nil,
Expand Down
4 changes: 4 additions & 0 deletions Sources/CoreAPI/WordPressOrgXMLRPCApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ open class WordPressOrgXMLRPCApi: NSObject {
///
@objc public static let minimumSupportedVersion = "4.0"

@objc public static var errorDomain: String {
wpxmlrpc.WPXMLRPCFaultErrorDomain
}

private lazy var urlSession: URLSession = makeSession(configuration: .default)
private lazy var uploadURLSession: URLSession = {
backgroundUploads
Expand Down
2 changes: 1 addition & 1 deletion Sources/WordPressKit/Models/AccountSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public struct AccountSettings {
}
}

public enum AccountSettingsChange {
@frozen public enum AccountSettingsChange {
case firstName(String)
case lastName(String)
case displayName(String)
Expand Down
4 changes: 2 additions & 2 deletions Sources/WordPressKit/Models/Activity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public class ActivityGroup {
public let name: String
public let count: Int

init(_ groupKey: String, dictionary: [String: AnyObject]) throws {
public init(_ groupKey: String, dictionary: [String: AnyObject]) throws {
guard let groupName = dictionary["name"] as? String else {
throw Error.missingName
}
Expand Down Expand Up @@ -293,7 +293,7 @@ public class RestoreStatus {
}

public extension RestoreStatus {
enum Status: String {
@frozen enum Status: String {
case queued
case finished
case running
Expand Down
2 changes: 1 addition & 1 deletion Sources/WordPressKit/Models/Atomic/AtomicLogs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class AtomicErrorLogEntry: Decodable {
public let line: Int?
public let timestamp: Date?

public enum Severity: String {
@frozen public enum Severity: String {
case user = "User"
case warning = "Warning"
case deprecated = "Deprecated"
Expand Down
2 changes: 1 addition & 1 deletion Sources/WordPressKit/Models/Blaze/BlazeCampaign.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class BlazeCampaign: Codable {
case creativeHTML = "creativeHtml"
}

public enum Status: String, Codable {
@frozen public enum Status: String, Codable {
case scheduled
case created
case rejected
Expand Down
11 changes: 11 additions & 0 deletions Sources/WordPressKit/Models/JetpackBackup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ public struct JetpackBackup: Decodable {
case url
case validUntil
}

public init(backupPoint: Date, downloadID: Int, rewindID: String, startedAt: Date, progress: Int?, downloadCount: Int?, url: String?, validUntil: Date?) {
self.backupPoint = backupPoint
self.downloadID = downloadID
self.rewindID = rewindID
self.startedAt = startedAt
self.progress = progress
self.downloadCount = downloadCount
self.url = url
self.validUntil = validUntil
}
}
2 changes: 1 addition & 1 deletion Sources/WordPressKit/Models/Plugins/PluginState.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public struct PluginState: Equatable, Codable {
public enum UpdateState: Equatable, Codable {
@frozen public enum UpdateState: Equatable, Codable {
public static func ==(lhs: PluginState.UpdateState, rhs: PluginState.UpdateState) -> Bool {
switch (lhs, rhs) {
case (.updated, .updated):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class RemoteNotificationSettings {

/// Represents a communication channel that may post notifications to the user.
///
public enum Channel: Equatable {
@frozen public enum Channel: Equatable {
case blog(blogId: Int)
case other
case wordPressCom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension StatsTagsAndCategoriesInsight: StatsInsightData {
}

public struct StatsTagAndCategory: Codable {
public enum Kind: String, Codable {
@frozen public enum Kind: String, Codable {
case tag
case category
case folder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
public enum StatsPeriodUnit: Int {
@frozen public enum StatsPeriodUnit: Int {
case day
case week
case month
case year
}

public enum StatsSummaryType: Int {
@frozen public enum StatsSummaryType: Int {
case views
case visitors
case likes
Expand Down
5 changes: 5 additions & 0 deletions Sources/WordPressKit/Models/WPTimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public struct NamedTimeZone: WPTimeZone {
public let label: String
public let value: String

public init(label: String, value: String) {
self.label = label
self.value = value
}

public var gmtOffset: Float? {
return nil
}
Expand Down
24 changes: 22 additions & 2 deletions Sources/WordPressKit/Services/AnnouncementServiceRemote.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Foundation

/// Retrieves feature announcements from the related endpoint
public class AnnouncementServiceRemote: ServiceRemoteWordPressComREST {
open class AnnouncementServiceRemote: ServiceRemoteWordPressComREST {

public func getAnnouncements(appId: String,
open func getAnnouncements(appId: String,
appVersion: String,
locale: String,
completion: @escaping (Result<[Announcement], Error>) -> Void) {
Expand Down Expand Up @@ -86,6 +86,18 @@ public struct Announcement: Codable {
public let isLocalized: Bool
public let responseLocale: String
public let features: [Feature]

public init(appVersionName: String, minimumAppVersion: String, maximumAppVersion: String, appVersionTargets: [String], detailsUrl: String, announcementVersion: String, isLocalized: Bool, responseLocale: String, features: [Feature]) {
self.appVersionName = appVersionName
self.minimumAppVersion = minimumAppVersion
self.maximumAppVersion = maximumAppVersion
self.appVersionTargets = appVersionTargets
self.detailsUrl = detailsUrl
self.announcementVersion = announcementVersion
self.isLocalized = isLocalized
self.responseLocale = responseLocale
self.features = features
}
}

public struct Feature: Codable {
Expand All @@ -94,6 +106,14 @@ public struct Feature: Codable {
public let icons: [FeatureIcon]?
public let iconUrl: String
public let iconBase64: String?

public init(title: String, subtitle: String, icons: [FeatureIcon]?, iconUrl: String, iconBase64: String?) {
self.title = title
self.subtitle = subtitle
self.icons = icons
self.iconUrl = iconUrl
self.iconBase64 = iconBase64
}
}

public struct FeatureIcon: Codable {
Expand Down
4 changes: 2 additions & 2 deletions Sources/WordPressKit/Services/AutomatedTransferService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import Foundation
/// Class encapsualting all requests related to performing Automated Transfer operations.
public class AutomatedTransferService: ServiceRemoteWordPressComREST {

public enum ResponseError: Error {
@frozen public enum ResponseError: Error {
case decodingFailure
}

public enum AutomatedTransferEligibilityError: Error {
@frozen public enum AutomatedTransferEligibilityError: Error {
case unverifiedEmail
case excessiveDiskSpaceUsage
case noBusinessPlan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public protocol PostServiceRemoteExtended: PostServiceRemote {
func deletePost(withID postID: Int) async throws
}

public enum PostServiceRemoteError: Error {
@frozen public enum PostServiceRemoteError: Error {
/// 409 (Conflict)
case conflict
/// 404 (Not Found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class QRLoginServiceRemote: ServiceRemoteWordPressComREST {
}
}

public enum QRLoginError {
@frozen public enum QRLoginError {
case invalidData
case expired

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Foundation
/// - daily: daily frequency
/// - instantly: instantly frequency
/// - weekly: weekly frequency
public enum ReaderServiceDeliveryFrequency: String {
@frozen public enum ReaderServiceDeliveryFrequency: String {
case daily
case instantly
case weekly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public enum SiteSegmentsError: Error {
/// - success: the site segments request succeeded with the accompanying result.
/// - failure: the site segments request failed due to the accompanying error.
///
public enum SiteSegmentsResult {
@frozen public enum SiteSegmentsResult {
case success([SiteSegment])
case failure(SiteSegmentsError)
}
Expand Down
2 changes: 2 additions & 0 deletions WordPressKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@
0C1C08422B9CD8D200E52F8C /* PostServiceRemoteREST+Extended.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostServiceRemoteREST+Extended.swift"; sourceTree = "<group>"; };
0C1C08442B9CDB0B00E52F8C /* PostServiceRemoteXMLRPC+Extended.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostServiceRemoteXMLRPC+Extended.swift"; sourceTree = "<group>"; };
0C3A2A412A2E7BA500FD91D6 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
0C6183C62C420A3700289E73 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
0C674E2F2BF3A91300F3B3D4 /* JetpackAIServiceRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackAIServiceRemote.swift; sourceTree = "<group>"; };
0C938A052C416789009BA7B2 /* Secret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secret.swift; sourceTree = "<group>"; };
0C938A072C4167BB009BA7B2 /* NSString+XMLExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+XMLExtensions.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2317,6 +2318,7 @@
9368C7711EC5EF1B0092CE8E = {
isa = PBXGroup;
children = (
0C6183C62C420A3700289E73 /* Package.swift */,
3FE2E9432BB11413002CA2E1 /* Sources */,
3FE2E9442BB11592002CA2E1 /* Tests */,
FFE247CD20CB1245002DF3A2 /* LICENSE */,
Expand Down

0 comments on commit ed81029

Please sign in to comment.