Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
767b0ba
Merge pull request #323 from wordpress-mobile/release/4.24.0
oguzkocer Jan 11, 2021
75b2629
Add public memberwise init for JetpackRestoreTypes
Jan 12, 2021
523d566
Update version to 4.25.0-beta.1
Jan 12, 2021
2816917
Merge pull request #325 from wordpress-mobile/fix/jetpack-restore-types
momo-ozawa Jan 13, 2021
bb48baf
Adds a Jetpack Capabilities service to return jetpack capabilities fo…
leandroalonso Jan 13, 2021
b976822
Bump version
leandroalonso Jan 13, 2021
1134fd2
Fix some descriptions
leandroalonso Jan 13, 2021
1b65a16
Make JetpackCapabilitiesServiceRemote open
leandroalonso Jan 13, 2021
94b6abf
Add isSeen property to RemoteReaderPost.
ScoutHarris Jan 13, 2021
b3c724f
Add method to mark a post as seen/unseen.
ScoutHarris Jan 13, 2021
7041171
Bump pod version.
ScoutHarris Jan 13, 2021
66f4b4d
Move arg one live above
leandroalonso Jan 14, 2021
e15de41
Refactor: use the single endpoint with dispatch groups instead of the…
leandroalonso Jan 14, 2021
ca0abe0
Use background thread instead of the main to avoid hitting the UI
leandroalonso Jan 14, 2021
17acc7c
Use DispatchQueue to avoid blocking the thread
leandroalonso Jan 14, 2021
247d11b
Remove debug output
leandroalonso Jan 14, 2021
ff29654
Check that the update actually succeeded.
ScoutHarris Jan 14, 2021
a7a180d
Merge pull request #327 from wordpress-mobile/feature/15355-seen_support
ScoutHarris Jan 14, 2021
deda618
Bump version
leandroalonso Jan 15, 2021
aef8482
Merge branch 'develop' into task/jetpack_capabilities
leandroalonso Jan 15, 2021
e3f17d3
Merge pull request #326 from wordpress-mobile/task/jetpack_capabilities
leandroalonso Jan 15, 2021
3744d34
Add current entry to Restore Status
Jan 16, 2021
e368dc1
Bump up version to 4.25.0-beta.4
Jan 18, 2021
55fcbbc
Add Jetpack scan fix status model
Jan 18, 2021
a07fcb9
Add fix threats / get fix status endpoints
Jan 18, 2021
8ab656e
Fix wrong status name
Jan 18, 2021
0f7efb6
Bump to 4.25.0-beta.4
Jan 18, 2021
0d0cf06
Fix build issue
Jan 18, 2021
bf96981
Merge pull request #328 from wordpress-mobile/restore-status-current-…
momo-ozawa Jan 18, 2021
6b0dea4
Update WordPressKit.podspec
Jan 19, 2021
f3707ff
Exposes the type property
Jan 20, 2021
3c077b6
Merge branch 'develop' into task/15190-fix-actions
Jan 20, 2021
f8aa799
Merge pull request #329 from wordpress-mobile/task/15190-fix-actions
Jan 20, 2021
bbf48d7
Bump version to stable 4.25.0
AliSoftware Jan 25, 2021
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
2 changes: 1 addition & 1 deletion WordPressKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressKit"
s.version = "4.24.0"
s.version = "4.25.0"
s.summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API."

s.description = <<-DESC
Expand Down
24 changes: 24 additions & 0 deletions WordPressKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,13 @@
8B2F4BEF24ACCC120056C08A /* RemoteReaderCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B2F4BEE24ACCC120056C08A /* RemoteReaderCard.swift */; };
8B2F4BF124ACE3C30056C08A /* RemoteReaderInterest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B2F4BF024ACE3C30056C08A /* RemoteReaderInterest.swift */; };
8B52B901257AC5A200221663 /* Date+endOfDay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B52B900257AC5A200221663 /* Date+endOfDay.swift */; };
8B749DED25AF3E4600023F03 /* JetpackCapabilitiesServiceRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B749DEC25AF3E4600023F03 /* JetpackCapabilitiesServiceRemote.swift */; };
8B749E8225AF7DDA00023F03 /* JetpackCapabilitiesServiceRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B749E8125AF7DDA00023F03 /* JetpackCapabilitiesServiceRemoteTests.swift */; };
8B749E8625AF808600023F03 /* jetpack-capabilities-107159616-success.json in Resources */ = {isa = PBXBuildFile; fileRef = 8B749E8525AF808600023F03 /* jetpack-capabilities-107159616-success.json */; };
8B749E8A25AF819700023F03 /* jetpack-capabilities-malformed.json in Resources */ = {isa = PBXBuildFile; fileRef = 8B749E8925AF819700023F03 /* jetpack-capabilities-malformed.json */; };
8BB66DB02523C181000B29DA /* ReaderPostServiceRemote+V2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB66DAF2523C181000B29DA /* ReaderPostServiceRemote+V2.swift */; };
8BE67ED324AD05D3004DB4C9 /* Decodable+DictionaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BE67ED224AD05D3004DB4C9 /* Decodable+DictionaryTests.swift */; };
8BFB4E6625B07905004D026E /* jetpack-capabilities-34197361-success.json in Resources */ = {isa = PBXBuildFile; fileRef = 8BFB4E6525B07905004D026E /* jetpack-capabilities-34197361-success.json */; };
8C5734F925681A6A005E61EE /* Enum+UnknownCaseRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C5734F825681A6A005E61EE /* Enum+UnknownCaseRepresentable.swift */; };
9309994D1F1657C600F006A1 /* ThemeServiceRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 9309994B1F1657C600F006A1 /* ThemeServiceRemote.h */; settings = {ATTRIBUTES = (Public, ); }; };
9309994E1F1657C600F006A1 /* ThemeServiceRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 9309994C1F1657C600F006A1 /* ThemeServiceRemote.m */; };
Expand Down Expand Up @@ -488,6 +493,7 @@
BA9A7F7F24C6895600925E81 /* plugin-directory-jetpack-beta.json in Resources */ = {isa = PBXBuildFile; fileRef = BA9A7F7E24C6895600925E81 /* plugin-directory-jetpack-beta.json */; };
BAB0E36424AD599700B3D22C /* MockPluginStateProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB0E36324AD599700B3D22C /* MockPluginStateProvider.swift */; };
BAFA775624ADAB3C000F0D3A /* MockPluginDirectoryEntryProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAFA775524ADAB3C000F0D3A /* MockPluginDirectoryEntryProvider.swift */; };
C785325625B5F46C006CEAFB /* JetpackThreatFixStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = C785325525B5F46C006CEAFB /* JetpackThreatFixStatus.swift */; };
D813437621F6D70D0060D99A /* SiteSegmentsResponseDecodingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D813437521F6D70D0060D99A /* SiteSegmentsResponseDecodingTests.swift */; };
D813437821F6D7DC0060D99A /* site-segments-single.json in Resources */ = {isa = PBXBuildFile; fileRef = D813437721F6D7DC0060D99A /* site-segments-single.json */; };
D816857121EDACD10049883E /* WordPressComServiceRemote+SiteSegments.swift in Sources */ = {isa = PBXBuildFile; fileRef = D816857021EDACD10049883E /* WordPressComServiceRemote+SiteSegments.swift */; };
Expand Down Expand Up @@ -909,8 +915,13 @@
8B2F4BEE24ACCC120056C08A /* RemoteReaderCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteReaderCard.swift; sourceTree = "<group>"; };
8B2F4BF024ACE3C30056C08A /* RemoteReaderInterest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteReaderInterest.swift; sourceTree = "<group>"; };
8B52B900257AC5A200221663 /* Date+endOfDay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+endOfDay.swift"; sourceTree = "<group>"; };
8B749DEC25AF3E4600023F03 /* JetpackCapabilitiesServiceRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackCapabilitiesServiceRemote.swift; sourceTree = "<group>"; };
8B749E8125AF7DDA00023F03 /* JetpackCapabilitiesServiceRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackCapabilitiesServiceRemoteTests.swift; sourceTree = "<group>"; };
8B749E8525AF808600023F03 /* jetpack-capabilities-107159616-success.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "jetpack-capabilities-107159616-success.json"; sourceTree = "<group>"; };
8B749E8925AF819700023F03 /* jetpack-capabilities-malformed.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "jetpack-capabilities-malformed.json"; sourceTree = "<group>"; };
8BB66DAF2523C181000B29DA /* ReaderPostServiceRemote+V2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ReaderPostServiceRemote+V2.swift"; sourceTree = "<group>"; };
8BE67ED224AD05D3004DB4C9 /* Decodable+DictionaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Decodable+DictionaryTests.swift"; sourceTree = "<group>"; };
8BFB4E6525B07905004D026E /* jetpack-capabilities-34197361-success.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "jetpack-capabilities-34197361-success.json"; sourceTree = "<group>"; };
8C5734F825681A6A005E61EE /* Enum+UnknownCaseRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Enum+UnknownCaseRepresentable.swift"; sourceTree = "<group>"; };
9309994B1F1657C600F006A1 /* ThemeServiceRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeServiceRemote.h; sourceTree = "<group>"; };
9309994C1F1657C600F006A1 /* ThemeServiceRemote.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThemeServiceRemote.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1061,6 +1072,7 @@
BAFA775524ADAB3C000F0D3A /* MockPluginDirectoryEntryProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPluginDirectoryEntryProvider.swift; sourceTree = "<group>"; };
BEEC8B5D92DA614468900BD7 /* Pods-WordPressKit.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressKit.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressKit/Pods-WordPressKit.release-alpha.xcconfig"; sourceTree = "<group>"; };
C5953994B3865AF409BA4210 /* Pods-WordPressKitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressKitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressKitTests/Pods-WordPressKitTests.release.xcconfig"; sourceTree = "<group>"; };
C785325525B5F46C006CEAFB /* JetpackThreatFixStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackThreatFixStatus.swift; sourceTree = "<group>"; };
CA5ABD95F40077D001644BCC /* Pods-WordPressKit.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressKit.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressKit/Pods-WordPressKit.release-internal.xcconfig"; sourceTree = "<group>"; };
D813437521F6D70D0060D99A /* SiteSegmentsResponseDecodingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteSegmentsResponseDecodingTests.swift; sourceTree = "<group>"; };
D813437721F6D7DC0060D99A /* site-segments-single.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "site-segments-single.json"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1172,6 +1184,7 @@
32FC1D26255C91ED00CD0A7B /* JetpackScan.swift */,
32FC20CD255DCC6100CD0A7B /* JetpackScanThreat.swift */,
3297E15525645C7D00287D21 /* JetpackCredentials.swift */,
C785325525B5F46C006CEAFB /* JetpackThreatFixStatus.swift */,
);
path = "Jetpack Scan";
sourceTree = "<group>";
Expand Down Expand Up @@ -1567,6 +1580,7 @@
1769DEA924729AFF00F42EFC /* HomepageSettingsServiceRemote.swift */,
9A2D0B27225E0119009E585F /* JetpackServiceRemote.swift */,
32FC1D27255C91ED00CD0A7B /* JetpackScanServiceRemote.swift */,
8B749DEC25AF3E4600023F03 /* JetpackCapabilitiesServiceRemote.swift */,
74DA56361F06EB0500FE9BF4 /* MediaServiceRemote.h */,
74DA562E1F06EAF000FE9BF4 /* MediaServiceRemoteREST.h */,
74DA562F1F06EAF000FE9BF4 /* MediaServiceRemoteREST.m */,
Expand Down Expand Up @@ -1972,6 +1986,9 @@
4625BAF6253E130800C04AAD /* page-layout-blog-layouts-malformed.json */,
462422302548BFEE002B8A12 /* nux-starter-designs-success.json */,
462422342548C031002B8A12 /* nux-starter-designs-malformed.json */,
8B749E8525AF808600023F03 /* jetpack-capabilities-107159616-success.json */,
8BFB4E6525B07905004D026E /* jetpack-capabilities-34197361-success.json */,
8B749E8925AF819700023F03 /* jetpack-capabilities-malformed.json */,
3297E1E32564683600287D21 /* jetpack-scan-in-progress.json */,
3297E2842564746800287D21 /* jetpack-scan-unavailable.json */,
3297E1EB2564694C00287D21 /* jetpack-scan-idle-success-no-threats.json */,
Expand Down Expand Up @@ -2024,6 +2041,7 @@
children = (
3297E1DC2564649D00287D21 /* Scan */,
9A2D0B2A225E0E22009E585F /* JetpackServiceRemoteTests.swift */,
8B749E8125AF7DDA00023F03 /* JetpackCapabilitiesServiceRemoteTests.swift */,
);
name = Jetpack;
sourceTree = "<group>";
Expand Down Expand Up @@ -2359,6 +2377,7 @@
40819771221DFDB700A298E4 /* stats-posts-data.json in Resources */,
740B23EE1F17FB7E00067A2A /* xmlrpc-malformed-request-xml-error.xml in Resources */,
826016F91F9FAF6300533B6C /* activity-log-success-3.json in Resources */,
8B749E8A25AF819700023F03 /* jetpack-capabilities-malformed.json in Resources */,
93BD27551EE73442002BB00B /* auth-send-login-email-invalid-client-failure.json in Resources */,
826016FD1F9FAF6300533B6C /* activity-log-bad-json-failure.json in Resources */,
74C473CD1EF336BD009918F2 /* site-active-purchases-bad-json-failure.json in Resources */,
Expand Down Expand Up @@ -2423,6 +2442,7 @@
40819775221E497D00A298E4 /* stats-published-posts.json in Resources */,
FFA4D4B12423B33800BF5180 /* wp-pages.json in Resources */,
74D67F151F15C2D70010C5ED /* site-roles-success.json in Resources */,
8BFB4E6625B07905004D026E /* jetpack-capabilities-34197361-success.json in Resources */,
9A881753223C01E400A3AB20 /* jetpack-service-error-site-is-jetpack.json in Resources */,
D8DB404221EF22B500B8238E /* site-segments-multiple.json in Resources */,
740B23E11F17FB4200067A2A /* xmlrpc-metaweblog-editpost-bad-xml-failure.xml in Resources */,
Expand All @@ -2433,6 +2453,7 @@
BA3F139024A0AAF8006367A3 /* plugin-install-succeeds.json in Resources */,
74D67F131F15C2D70010C5ED /* site-roles-auth-failure.json in Resources */,
74B040721EF8B366002C6258 /* rest-site-settings.json in Resources */,
8B749E8625AF808600023F03 /* jetpack-capabilities-107159616-success.json in Resources */,
93BD27611EE73442002BB00B /* me-sites-empty-success.json in Resources */,
40E4698D2017D2E30030DB5F /* plugin-directory-new.json in Resources */,
4081977C221F153B00A298E4 /* stats-visits-day.json in Resources */,
Expand Down Expand Up @@ -2601,6 +2622,7 @@
8B2F4BE724ABC8A90056C08A /* ReaderPostServiceRemote+Cards.swift in Sources */,
8B16CE8E25250039007BE5A9 /* RemoteReaderPost.swift in Sources */,
74E2294E1F1E73FE0085F7F2 /* RemotePublicizeService.swift in Sources */,
8B749DED25AF3E4600023F03 /* JetpackCapabilitiesServiceRemote.swift in Sources */,
9F3E0BA22087345F009CB5BA /* ServiceRequest.swift in Sources */,
E1A6605F1FD694ED00BAC339 /* PluginDirectoryEntry.swift in Sources */,
9A2D0B28225E0119009E585F /* JetpackServiceRemote.swift in Sources */,
Expand Down Expand Up @@ -2659,6 +2681,7 @@
E6D0EE621F7EF9CE0064D3FC /* AccountServiceRemoteREST+SocialService.swift in Sources */,
7430C9B61F1927C50051B8E6 /* RemoteReaderSiteInfo.m in Sources */,
74DA56351F06EAF000FE9BF4 /* MediaServiceRemoteXMLRPC.m in Sources */,
C785325625B5F46C006CEAFB /* JetpackThreatFixStatus.swift in Sources */,
93F50A381F226B9300B5BEBA /* WordPressComServiceRemote.m in Sources */,
9F4E52002088E38200424676 /* ObjectValidation.swift in Sources */,
7430C9B81F1927C50051B8E6 /* RemoteReaderTopic.m in Sources */,
Expand Down Expand Up @@ -2805,6 +2828,7 @@
32AF21E3236DEB3C001C6502 /* PostServiceRemoteRESTAutosaveTests.swift in Sources */,
3236F79A24AE406D0088E8F3 /* ReaderTopicServiceRemote+InterestsTests.swift in Sources */,
74B5F0DE1EF82A9600B411E7 /* BlogServiceRemoteRESTTests.m in Sources */,
8B749E8225AF7DDA00023F03 /* JetpackCapabilitiesServiceRemoteTests.swift in Sources */,
74E2294B1F1E73340085F7F2 /* SharingServiceRemoteTests.m in Sources */,
73B3DAD621FBB20D00B2CF18 /* WordPressComRestApiTests+Locale.swift in Sources */,
3297E1DE2564653A00287D21 /* JetpackScanServiceRemoteTests.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions WordPressKit/Activity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public class RestoreStatus {
public let status: Status
public let progress: Int
public let message: String?
public let currentEntry: String?
public let errorCode: String?
public let failureReason: String?

Expand All @@ -266,6 +267,7 @@ public class RestoreStatus {
status = restoreStatusEnum
progress = dictionary["progress"] as? Int ?? 0
message = dictionary["message"] as? String
currentEntry = dictionary["current_entry"] as? String
errorCode = dictionary["error_code"] as? String
failureReason = dictionary["reason"] as? String
}
Expand Down
2 changes: 1 addition & 1 deletion WordPressKit/Jetpack Scan/JetpackScanThreat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public struct JetpackScanThreat: Decodable {
public let `extension`: JetpackThreatExtension?

/// The type of threat this is
private(set) var type: ThreatType = .unknown
public private(set) var type: ThreatType = .unknown

/// If this is a file based threat this will provide code context to be displayed
/// Context example:
Expand Down
68 changes: 68 additions & 0 deletions WordPressKit/Jetpack Scan/JetpackThreatFixStatus.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import Foundation

public struct JetpackThreatFixResponse: Decodable {
public let success: Bool
public let threats: [JetpackThreatFixStatus]

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

success = try container.decode(Bool.self, forKey: .success)

let statusDict = try container.decode([String: [String: String]].self, forKey: .threats)
var statusArray: [JetpackThreatFixStatus] = []

for (threatId, status) in statusDict {
guard let id = Int(threatId), let statusValue = status["status"] else {
throw ResponseError.decodingFailure
}

let fixStatus = JetpackThreatFixStatus(with: id, status: statusValue)
statusArray.append(fixStatus)
}

threats = statusArray
}


/// Returns true the fixing status is complete, and all threats are no longer in progress
public var finished: Bool {
return inProgress.count <= 0
}

/// Returns all the fixed threats
public var fixed: [JetpackThreatFixStatus] {
return threats.filter { $0.status == .fixed }
}

/// Returns all the in progress threats
public var inProgress: [JetpackThreatFixStatus] {
return threats.filter { $0.status == .inProgress }
}

private enum CodingKeys: String, CodingKey {
case success = "ok", threats
}

enum ResponseError: Error {
case decodingFailure
}
}

public struct JetpackThreatFixStatus {
public enum ThreatFixStatus: String, Decodable, UnknownCaseRepresentable {
case inProgress = "in_progress"
case fixed

case unknown
static let unknownCase: Self = .unknown
}

public let threatId: Int
public let status: ThreatFixStatus

public init(with threatId: Int, status: String){
self.threatId = threatId
self.status = ThreatFixStatus(rawValue: status)
}
}
41 changes: 41 additions & 0 deletions WordPressKit/JetpackCapabilitiesServiceRemote.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Foundation

/// A service that returns the Jetpack Capabilities for a set of blogs
open class JetpackCapabilitiesServiceRemote: ServiceRemoteWordPressComREST {

/// Returns a Dictionary of capabilities for each given siteID
/// - Parameters:
/// - siteIds: an array of Int representing siteIDs
/// - success: a success block that accepts a dictionary as a parameter
open func `for`(siteIds: [Int], success: @escaping ([String: AnyObject]) -> Void) {
var jetpackCapabilities: [String: AnyObject] = [:]
let dispatchGroup = DispatchGroup()
let dispatchQueue = DispatchQueue(label: "com.rewind.capabilities")

siteIds.forEach { siteID in
dispatchGroup.enter()

dispatchQueue.async {
let endpoint = "sites/\(siteID)/rewind/capabilities"
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)

self.wordPressComRestApi.GET(path,
parameters: nil,
success: { response, _ in
if let capabilities = (response as? [String: AnyObject])?["capabilities"] as? [String] {
jetpackCapabilities["\(siteID)"] = capabilities as AnyObject
}

dispatchGroup.leave()
}, failure: { error, _ in
dispatchGroup.leave()
})
}
}

dispatchGroup.notify(queue: .global(qos: .background)) {
success(jetpackCapabilities)
}
}

}
28 changes: 21 additions & 7 deletions WordPressKit/JetpackRestoreTypes.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import Foundation

public struct JetpackRestoreTypes: Decodable {
public let themes: Bool
public let plugins: Bool
public let uploads: Bool
public let sqls: Bool
public let roots: Bool
public let contents: Bool
public struct JetpackRestoreTypes {
public var themes: Bool
public var plugins: Bool
public var uploads: Bool
public var sqls: Bool
public var roots: Bool
public var contents: Bool

public init(themes: Bool = true,
plugins: Bool = true ,
uploads: Bool = true,
sqls: Bool = true,
roots: Bool = true,
contents: Bool = true) {
self.themes = themes
self.plugins = plugins
self.uploads = uploads
self.sqls = sqls
self.roots = roots
self.contents = contents
}

func toDictionary() -> [String: AnyObject] {
return [
Expand Down
Loading