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

Commit 035a9d7

Browse files
committed
Merge branch 'trunk' of github.com:wordpress-mobile/WordPressKit-iOS into feature/eu-us-compliance-locator
# Conflicts: # CHANGELOG.md # WordPressKit.podspec
2 parents 8e763c2 + e82a089 commit 035a9d7

File tree

10 files changed

+402
-6
lines changed

10 files changed

+402
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ _None._
3939
### New Features
4040

4141
- Add `IPLocationRemote` [#613]
42+
- Add `ui_status` field to `BlazeCampaign` [#611]
4243

4344
### Bug Fixes
4445

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.5.0-beta.1'
5+
s.version = '8.5.0-beta.2'
66

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

WordPressKit.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@
638638
FEAE3AC7298AC2A300E05A24 /* JetpackProxyServiceRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEAE3AC6298AC2A300E05A24 /* JetpackProxyServiceRemote.swift */; };
639639
FEB7A88F271873BD00A8CF85 /* reader-post-comments-update-notification-success.json in Resources */ = {isa = PBXBuildFile; fileRef = FEB7A88E271873BD00A8CF85 /* reader-post-comments-update-notification-success.json */; };
640640
FED77253298B819900C2346E /* JetpackProxyServiceRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FED77252298B819900C2346E /* JetpackProxyServiceRemoteTests.swift */; };
641+
FEE48EF62A4B3602008A48E0 /* BlogServiceRemote+ActiveFeaturesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEE48EF52A4B3602008A48E0 /* BlogServiceRemote+ActiveFeaturesTests.swift */; };
642+
FEE48EF82A4B3E43008A48E0 /* sites-site-active-features.json in Resources */ = {isa = PBXBuildFile; fileRef = FEE48EF72A4B3E43008A48E0 /* sites-site-active-features.json */; };
643+
FEE48EFA2A4B3E50008A48E0 /* sites-site-no-active-features.json in Resources */ = {isa = PBXBuildFile; fileRef = FEE48EF92A4B3E50008A48E0 /* sites-site-no-active-features.json */; };
641644
FEE4EF57272FDD4B003CDA3C /* RemoteCommentV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEE4EF56272FDD4B003CDA3C /* RemoteCommentV2.swift */; };
642645
FEE4EF59272FF78C003CDA3C /* CommentServiceRemoteREST+ApiV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEE4EF58272FF78C003CDA3C /* CommentServiceRemoteREST+ApiV2.swift */; };
643646
FEE4EF5B27302317003CDA3C /* CommentServiceRemoteREST+APIv2Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEE4EF5A27302317003CDA3C /* CommentServiceRemoteREST+APIv2Tests.swift */; };
@@ -1328,6 +1331,9 @@
13281331
FEAE3AC6298AC2A300E05A24 /* JetpackProxyServiceRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackProxyServiceRemote.swift; sourceTree = "<group>"; };
13291332
FEB7A88E271873BD00A8CF85 /* reader-post-comments-update-notification-success.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "reader-post-comments-update-notification-success.json"; sourceTree = "<group>"; };
13301333
FED77252298B819900C2346E /* JetpackProxyServiceRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackProxyServiceRemoteTests.swift; sourceTree = "<group>"; };
1334+
FEE48EF52A4B3602008A48E0 /* BlogServiceRemote+ActiveFeaturesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BlogServiceRemote+ActiveFeaturesTests.swift"; sourceTree = "<group>"; };
1335+
FEE48EF72A4B3E43008A48E0 /* sites-site-active-features.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "sites-site-active-features.json"; sourceTree = "<group>"; };
1336+
FEE48EF92A4B3E50008A48E0 /* sites-site-no-active-features.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "sites-site-no-active-features.json"; sourceTree = "<group>"; };
13311337
FEE4EF56272FDD4B003CDA3C /* RemoteCommentV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteCommentV2.swift; sourceTree = "<group>"; };
13321338
FEE4EF58272FF78C003CDA3C /* CommentServiceRemoteREST+ApiV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CommentServiceRemoteREST+ApiV2.swift"; sourceTree = "<group>"; };
13331339
FEE4EF5A27302317003CDA3C /* CommentServiceRemoteREST+APIv2Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CommentServiceRemoteREST+APIv2Tests.swift"; sourceTree = "<group>"; };
@@ -1610,6 +1616,7 @@
16101616
isa = PBXGroup;
16111617
children = (
16121618
74B5F0DD1EF82A9600B411E7 /* BlogServiceRemoteRESTTests.m */,
1619+
FEE48EF52A4B3602008A48E0 /* BlogServiceRemote+ActiveFeaturesTests.swift */,
16131620
);
16141621
name = Blog;
16151622
sourceTree = "<group>";
@@ -2308,6 +2315,8 @@
23082315
40819774221E497C00A298E4 /* stats-published-posts.json */,
23092316
404057DB221C9FD70060250C /* stats-referrer-data.json */,
23102317
404057C6221B36070060250C /* stats-search-term-result.json */,
2318+
FEE48EF72A4B3E43008A48E0 /* sites-site-active-features.json */,
2319+
FEE48EF92A4B3E50008A48E0 /* sites-site-no-active-features.json */,
23112320
40F9880D221ACFB400B7B369 /* stats-streak-result.json */,
23122321
404057CA221B80BC0060250C /* stats-top-authors.json */,
23132322
404057CF221C46780060250C /* stats-videos-data.json */,
@@ -2894,6 +2903,7 @@
28942903
E6B0461325E5B6F500DF6F4F /* sites-invites-links-disable.json in Resources */,
28952904
98E1A60D27AB621200C61A7F /* xmlrpc-site-comment-success.xml in Resources */,
28962905
74C473C71EF334D4009918F2 /* site-active-purchases-none-active-success.json in Resources */,
2906+
FEE48EFA2A4B3E50008A48E0 /* sites-site-no-active-features.json in Resources */,
28972907
FA87FE0D24EB4450003FBEE3 /* reader-post-comments-unsubscribe-success.json in Resources */,
28982908
98E1A60B27AB604600C61A7F /* site-comment-success.json in Resources */,
28992909
829BA4321FACF187003ADEEA /* activity-rewind-status-restore-finished.json in Resources */,
@@ -2984,6 +2994,7 @@
29842994
C738CAF928622BB1001BE107 /* qrlogin-authenticate-failed-400.json in Resources */,
29852995
74D67F1E1F15C3240010C5ED /* people-send-invitation-failure.json in Resources */,
29862996
7403A3001EF06FEB00DED7DC /* me-settings-success.json in Resources */,
2997+
FEE48EF82A4B3E43008A48E0 /* sites-site-active-features.json in Resources */,
29872998
439A44DE2107CF6F00795ED7 /* site-plans-v3-bad-json-failure.json in Resources */,
29882999
74B335EA1F06F76B0053A184 /* xmlrpc-response-getpost.xml in Resources */,
29893000
FEE4EF6127303361003CDA3C /* comments-v2-edit-context-success.json in Resources */,
@@ -3433,6 +3444,7 @@
34333444
4A1DEF46293051C600322608 /* LoggingTests.m in Sources */,
34343445
930999521F1658F800F006A1 /* ThemeServiceRemoteTests.m in Sources */,
34353446
8BE67ED324AD05D3004DB4C9 /* Decodable+DictionaryTests.swift in Sources */,
3447+
FEE48EF62A4B3602008A48E0 /* BlogServiceRemote+ActiveFeaturesTests.swift in Sources */,
34363448
74B335DA1F06F3D60053A184 /* WordPressComRestApiTests.swift in Sources */,
34373449
FA87FE0724EB39C4003FBEE3 /* ReaderPostServiceRemote+SubscriptionTests.swift in Sources */,
34383450
7403A2E61EF06F7000DED7DC /* AccountSettingsRemoteTests.swift in Sources */,

WordPressKit/BlazeCampaign.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import Foundation
22

3-
public final class BlazeCampaign: Decodable {
3+
public final class BlazeCampaign: Codable {
44
public let campaignID: Int
55
public let name: String?
66
public let startDate: Date?
77
public let endDate: Date?
8+
/// A raw campaign status on the server.
89
public let status: Status
10+
/// A subset of ``BlazeCampaign/status-swift.property`` values where some
11+
/// cases are skipped for simplicity and mapped to other more common ones.
12+
public let uiStatus: Status
913
public let budgetCents: Int?
1014
public let targetURL: String?
1115
public let stats: Stats?
1216
public let contentConfig: ContentConfig?
1317
public let creativeHTML: String?
1418

15-
public init(campaignID: Int, name: String?, startDate: Date?, endDate: Date?, status: Status, budgetCents: Int?, targetURL: String?, stats: Stats?, contentConfig: ContentConfig?, creativeHTML: String?) {
19+
public init(campaignID: Int, name: String?, startDate: Date?, endDate: Date?, status: Status, uiStatus: Status, budgetCents: Int?, targetURL: String?, stats: Stats?, contentConfig: ContentConfig?, creativeHTML: String?) {
1620
self.campaignID = campaignID
1721
self.name = name
1822
self.startDate = startDate
1923
self.endDate = endDate
2024
self.status = status
25+
self.uiStatus = uiStatus
2126
self.budgetCents = budgetCents
2227
self.targetURL = targetURL
2328
self.stats = stats
@@ -31,14 +36,15 @@ public final class BlazeCampaign: Decodable {
3136
case startDate
3237
case endDate
3338
case status
39+
case uiStatus
3440
case budgetCents
3541
case targetURL = "targetUrl"
3642
case contentConfig
3743
case stats = "campaignStats"
3844
case creativeHTML = "creativeHtml"
3945
}
4046

41-
public enum Status: String, Decodable {
47+
public enum Status: String, Codable {
4248
case scheduled
4349
case created
4450
case rejected
@@ -55,7 +61,7 @@ public final class BlazeCampaign: Decodable {
5561
}
5662
}
5763

58-
public struct Stats: Decodable {
64+
public struct Stats: Codable {
5965
public let impressionsTotal: Int?
6066
public let clicksTotal: Int?
6167

@@ -65,7 +71,7 @@ public final class BlazeCampaign: Decodable {
6571
}
6672
}
6773

68-
public struct ContentConfig: Decodable {
74+
public struct ContentConfig: Codable {
6975
public let title: String?
7076
public let snippet: String?
7177
public let clickURL: String?

WordPressKit/RemoteBlog.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import NSObject_SafeExpectations
3434
/// Indicates whether the current's blog plan is paid, or not.
3535
public var hasPaidPlan: Bool = false
3636

37+
/// Features available for the current blog's plan.
38+
public var planActiveFeatures = [String]()
39+
3740
/// Indicates whether it's a jetpack site, or not.
3841
public var jetpack: Bool = false
3942

@@ -73,6 +76,7 @@ import NSObject_SafeExpectations
7376
self.planID = json.number(forKeyPath: "plan.product_id")
7477
self.planTitle = json.string(forKeyPath: "plan.product_name_short")
7578
self.hasPaidPlan = !(json.number(forKeyPath: "plan.is_free")?.boolValue ?? true)
79+
self.planActiveFeatures = (json.array(forKeyPath: "plan.features.active") as? [String]) ?? []
7680
self.quotaSpaceAllowed = json.number(forKeyPath: "quota.space_allowed")
7781
self.quotaSpaceUsed = json.number(forKeyPath: "quota.space_used")
7882
}

WordPressKitTests/BlazeServiceRemoteTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ final class BlazeServiceRemoteTests: RemoteTestCase, RESTTestable {
3737
XCTAssertEqual(campaign.startDate, ISO8601DateFormatter().date(from: "2023-06-13T00:00:00Z"))
3838
XCTAssertEqual(campaign.endDate, ISO8601DateFormatter().date(from: "2023-06-01T19:15:45Z"))
3939
XCTAssertEqual(campaign.status, .canceled)
40+
XCTAssertEqual(campaign.uiStatus, .canceled)
4041
XCTAssertEqual(campaign.budgetCents, 500)
4142
XCTAssertEqual(campaign.targetURL, "https://alextest9123.wordpress.com/2023/06/01/test-post/")
4243
XCTAssertEqual(campaign.contentConfig?.title, "Test Post - don't approve")
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import XCTest
2+
@testable import WordPressKit
3+
4+
class BlogServiceRemote_ActiveFeaturesTests: RemoteTestCase, RESTTestable {
5+
6+
private let siteID = NSNumber(value: 1001)
7+
private let syncBlogWithFeaturesFilename = "sites-site-active-features.json"
8+
private let syncBlogWithEmptyFeaturesFilename = "sites-site-no-active-features.json"
9+
10+
private var syncBlogEndpoint: String {
11+
"/sites/\(siteID)"
12+
}
13+
14+
private lazy var remote: BlogServiceRemoteREST = {
15+
.init(wordPressComRestApi: getRestApi(), siteID: siteID)
16+
}()
17+
18+
// MARK: Tests
19+
20+
func testSyncBlogParsesActiveFeatures() async throws {
21+
stubRemoteResponse(syncBlogEndpoint, filename: syncBlogWithFeaturesFilename, contentType: .ApplicationJSON)
22+
23+
let blog = try await withCheckedThrowingContinuation { continuation in
24+
remote.syncBlog { remoteBlog in
25+
continuation.resume(returning: remoteBlog)
26+
} failure: { error in
27+
continuation.resume(throwing: error!)
28+
}
29+
}
30+
31+
let features = try XCTUnwrap(blog?.planActiveFeatures)
32+
XCTAssertEqual(features.count, 3)
33+
}
34+
35+
func testActiveFeaturesDefaultValue() async throws {
36+
stubRemoteResponse(syncBlogEndpoint, filename: syncBlogWithEmptyFeaturesFilename, contentType: .ApplicationJSON)
37+
38+
let blog = try await withCheckedThrowingContinuation { continuation in
39+
remote.syncBlog { remoteBlog in
40+
continuation.resume(returning: remoteBlog)
41+
} failure: { error in
42+
continuation.resume(throwing: error!)
43+
}
44+
}
45+
46+
let features = try XCTUnwrap(blog?.planActiveFeatures)
47+
XCTAssertTrue(features.isEmpty)
48+
}
49+
}

WordPressKitTests/Mock Data/blaze-campaigns-search.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"end_date": "2023-06-01T19:15:45.000Z",
99
"status_smart": 0,
1010
"status": "canceled",
11+
"ui_status": "canceled",
1112
"subscription_id": 117499,
1213
"display_name": "Test User",
1314
"avatar_url": "https://0.gravatar.com/avatar/614d27bcc21db12e7c49b516b4750387?s=96&amp;d=identicon&amp;r=G",
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
{
2+
"ID": 55555551,
3+
"name": "Public Test Blog",
4+
"description": "A fine WordPress.com site",
5+
"URL": "https://test1.wordpress.com",
6+
"user_can_manage": false,
7+
"capabilities": {
8+
"edit_pages": true,
9+
"edit_posts": true,
10+
"edit_others_posts": true,
11+
"edit_others_pages": true,
12+
"delete_posts": true,
13+
"delete_others_posts": true,
14+
"edit_theme_options": true,
15+
"edit_users": false,
16+
"list_users": true,
17+
"manage_categories": true,
18+
"manage_options": true,
19+
"activate_wordads": true,
20+
"promote_users": true,
21+
"publish_posts": true,
22+
"upload_files": true,
23+
"delete_users": false,
24+
"remove_users": true,
25+
"view_stats": true
26+
},
27+
"jetpack": false,
28+
"is_multisite": true,
29+
"post_count": 25,
30+
"subscribers_count": 51,
31+
"lang": "en",
32+
"logo": {
33+
"id": 1987,
34+
"sizes": {
35+
"thumbnail": {
36+
"height": 150,
37+
"width": 113,
38+
"url": "https://test1.files.wordpress.com/2017/02/img_1111.jpg?w=113",
39+
"orientation": "portrait"
40+
},
41+
"medium": {
42+
"height": 300,
43+
"width": 225,
44+
"url": "https://test1.files.wordpress.com/2017/02/img_1111.jpg?w=225",
45+
"orientation": "portrait"
46+
},
47+
"large": {
48+
"height": 960,
49+
"width": 720,
50+
"url": "https://test1.files.wordpress.com/2017/02/img_1111.jpg?w=720",
51+
"orientation": "portrait"
52+
},
53+
"full": {
54+
"url": "https://test1.files.wordpress.com/2017/02/img_1111.jpg",
55+
"height": 4032,
56+
"width": 3024,
57+
"orientation": "portrait"
58+
}
59+
},
60+
"url": "https://test1.files.wordpress.com/2017/02/img_1111.jpg"
61+
},
62+
"visible": true,
63+
"is_private": false,
64+
"single_user_site": false,
65+
"is_vip": false,
66+
"is_following": false,
67+
"options": {
68+
"blog_public": 1,
69+
"timezone": "",
70+
"gmt_offset": 0,
71+
"videopress_enabled": false,
72+
"upgraded_filetypes_enabled": false,
73+
"login_url": "https://test1.wordpress.com/wp-login.php",
74+
"admin_url": "https://test1.wordpress.com/wp-admin/",
75+
"is_mapped_domain": false,
76+
"is_redirect": false,
77+
"unmapped_url": "https://test1.wordpress.com",
78+
"featured_images_enabled": false,
79+
"theme_slug": "pub/libretto",
80+
"header_image": false,
81+
"background_color": false,
82+
"image_default_link_type": "file",
83+
"image_thumbnail_width": 150,
84+
"image_thumbnail_height": 150,
85+
"image_thumbnail_crop": 0,
86+
"image_medium_width": 300,
87+
"image_medium_height": 300,
88+
"image_large_width": 1024,
89+
"image_large_height": 1024,
90+
"permalink_structure": "/%year%/%monthnum%/%day%/%postname%/",
91+
"post_formats": [],
92+
"default_post_format": "standard",
93+
"default_category": 1,
94+
"allowed_file_types": [
95+
"jpg",
96+
"jpeg",
97+
"png",
98+
"gif",
99+
"pdf",
100+
"doc",
101+
"ppt",
102+
"odt",
103+
"pptx",
104+
"docx",
105+
"pps",
106+
"ppsx",
107+
"xls",
108+
"xlsx",
109+
"key"
110+
],
111+
"show_on_front": "posts",
112+
"default_likes_enabled": true,
113+
"default_sharing_status": true,
114+
"default_comment_status": true,
115+
"default_ping_status": true,
116+
"software_version": "4.7.3",
117+
"created_at": "2014-05-27T20:29:22+00:00",
118+
"wordads": false,
119+
"publicize_permanently_disabled": false,
120+
"frame_nonce": "99cc88877b",
121+
"headstart": false,
122+
"headstart_is_fresh": false,
123+
"ak_vp_bundle_enabled": null,
124+
"advanced_seo_front_page_description": "",
125+
"advanced_seo_title_formats": [],
126+
"verification_services_codes": null,
127+
"podcasting_archive": null,
128+
"is_domain_only": false,
129+
"is_automated_transfer": false
130+
},
131+
"plan": {
132+
"product_id": 1,
133+
"product_slug": "free_plan",
134+
"product_name_short": "Free",
135+
"free_trial": false,
136+
"expired": false,
137+
"user_is_owner": false,
138+
"is_free": true,
139+
"features": {
140+
"active": [
141+
"advanced-seo",
142+
"social-shares-1000",
143+
"donations"
144+
],
145+
"available": {}
146+
}
147+
},
148+
"meta": {
149+
"links": {
150+
"self": "https://public-api.wordpress.com/rest/v1.1/sites/55555551",
151+
"help": "https://public-api.wordpress.com/rest/v1.1/sites/55555551/help",
152+
"posts": "https://public-api.wordpress.com/rest/v1.1/sites/55555551/posts/",
153+
"comments": "https://public-api.wordpress.com/rest/v1.1/sites/55555551/comments/",
154+
"xmlrpc": "https://test1.wordpress.com/xmlrpc.php"
155+
}
156+
},
157+
"quota": {
158+
"space_allowed": 3221225472,
159+
"space_used": 339047395,
160+
"percent_used": 10.525416427602,
161+
"space_available": 2882178077
162+
}
163+
}

0 commit comments

Comments
 (0)