Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 41ac9dc

Browse files
authored
Merge pull request #609 from wordpress-mobile/task/can_blaze
Blaze Manage Campaigns: Add can_blaze property to blog options
2 parents 273190e + 58597b3 commit 41ac9dc

File tree

4 files changed

+3
-100
lines changed

4 files changed

+3
-100
lines changed

WordPressKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Pod::Spec.new do |s|
44
s.name = 'WordPressKit'
5-
s.version = '8.3.0'
5+
s.version = '8.4.0-beta.1'
66

77
s.summary = 'WordPressKit offers a clean and simple WordPress.com and WordPress.org API.'
88
s.description = <<-DESC

WordPressKit/BlazeServiceRemote.swift

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,6 @@ import Foundation
22

33
open class BlazeServiceRemote: ServiceRemoteWordPressComREST {
44

5-
public typealias BlazeStatusResponseCallback = (Result<Bool, Error>) -> Void
6-
7-
public enum BlazeServiceRemoteError: Error {
8-
case InvalidDataError
9-
}
10-
11-
// MARK: - Status
12-
13-
open func getStatus(forSiteId siteId: Int, callback: @escaping BlazeStatusResponseCallback) {
14-
15-
let endpoint = "sites/\(siteId)/blaze/status"
16-
let path = self.path(forEndpoint: endpoint, withVersion: ._2_0)
17-
18-
wordPressComRestApi.GET(path, parameters: nil, success: { response, _ in
19-
if let json = response as? [String: Any],
20-
let approved = json["approved"] as? Bool {
21-
callback(.success(approved))
22-
} else {
23-
callback(.failure(BlazeServiceRemoteError.InvalidDataError))
24-
}
25-
}, failure: { error, response in
26-
WPKitLogError("Error retrieving blaze status")
27-
WPKitLogError("\(error)")
28-
29-
if let response = response {
30-
WPKitLogDebug("Response Code: \(response.statusCode)")
31-
}
32-
33-
callback(.failure(error))
34-
})
35-
}
36-
375
// MARK: - Campaigns
386

397
/// Searches the campaigns for the site with the given ID. The campaigns are returned ordered by the post date.

WordPressKit/RemoteBlogOptionsHelper.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import Foundation
3333
"page_on_front",
3434
"page_for_posts",
3535
"blogging_prompts_settings",
36-
"jetpack_connection_active_plugins"
36+
"jetpack_connection_active_plugins",
37+
"can_blaze"
3738
]
3839
for key in optionsDirectMapKeys {
3940
if let value = response.value(forKeyPath: "options.\(key)") {

WordPressKitTests/BlazeServiceRemoteTests.swift

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,75 +9,9 @@ final class BlazeServiceRemoteTests: RemoteTestCase, RESTTestable {
99

1010
// MARK: - Properties
1111

12-
var statusEndpoint: String { "sites/\(siteId)/blaze/status" }
1312
var searchEndpoint: String { "sites/\(siteId)/wordads/dsp/api/v1/search/campaigns/site/\(siteId)" }
1413
var service: BlazeServiceRemote!
1514

16-
// MARK: - Get Status
17-
18-
func testGetStatusReturnsSuccess() throws {
19-
// Given
20-
let status = ["approved": true]
21-
let data = try JSONEncoder().encode(status)
22-
stubRemoteResponse(statusEndpoint, data: data, contentType: .ApplicationJSON)
23-
24-
// When
25-
let expectation = XCTestExpectation()
26-
BlazeServiceRemote(wordPressComRestApi: getRestApi()).getStatus(forSiteId: siteId) { result in
27-
28-
// Then
29-
let approved = try! result.get()
30-
XCTAssertEqual(approved, true)
31-
expectation.fulfill()
32-
}
33-
34-
wait(for: [expectation], timeout: 1)
35-
}
36-
37-
func testMalformedResponseReturnsError() throws {
38-
// Given
39-
let data = try toJSON(object: ["Invalid"])
40-
stubRemoteResponse(statusEndpoint, data: data, contentType: .ApplicationJSON)
41-
42-
// When
43-
let expectation = XCTestExpectation()
44-
BlazeServiceRemote(wordPressComRestApi: getRestApi()).getStatus(forSiteId: siteId) { result in
45-
46-
// Then
47-
switch result {
48-
case .success: XCTFail()
49-
case .failure: expectation.fulfill()
50-
}
51-
52-
}
53-
54-
wait(for: [expectation], timeout: 1)
55-
}
56-
57-
func testGetStatusReturnsFailure() {
58-
// Given
59-
stubRemoteResponse(statusEndpoint, data: Data(), contentType: .NoContentType, status: 403)
60-
61-
// When
62-
let expectation = XCTestExpectation()
63-
BlazeServiceRemote(wordPressComRestApi: getRestApi()).getStatus(forSiteId: siteId) { result in
64-
65-
// Then
66-
if case .success = result {
67-
XCTFail()
68-
}
69-
expectation.fulfill()
70-
}
71-
72-
wait(for: [expectation], timeout: 1)
73-
}
74-
75-
private func toJSON<T: Codable>(object: T) throws -> Data {
76-
let encoder = JSONEncoder()
77-
encoder.outputFormatting = [.sortedKeys, .prettyPrinted]
78-
return try encoder.encode(object)
79-
}
80-
8115
// MARK: - Campaigns
8216

8317
func testGetCampaignsSuccess() throws {

0 commit comments

Comments
 (0)