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

Commit a128446

Browse files
committed
Add support for plans
1 parent e8e8652 commit a128446

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ let package = Package(
1111
targets: [
1212
.binaryTarget(
1313
name: "WordPressKit",
14-
url: "https://github.com/user-attachments/files/20087743/WordPressKit.zip",
15-
checksum: "138689853d7a65384fa5dae5b5732b40769689a0108f4265e23cc47ca3eea647"
14+
url: "https://github.com/user-attachments/files/20105676/WordPressKit.zip",
15+
checksum: "6a446e44dda98d3f5d0d916fbd946d1bf602dfb6124e4ce01aeb7a0c161ee3f6"
1616
),
1717
]
1818
)

Sources/WordPressKit/Services/SubscribersServiceRemote.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,58 @@ public class SubscribersServiceRemote: ServiceRemoteWordPressComREST {
126126
public let displayName: String?
127127
public let avatar: String?
128128
public let emailAddress: String?
129+
public let siteURL: String?
129130
public let dateSubscribed: Date
130131
public let isEmailSubscriptionEnabled: Bool
131132
public let subscriptionStatus: String?
132133
public let country: Country?
134+
public var plans: [Plan]?
133135

134136
public struct Country: Decodable {
135137
public var code: String?
136138
public var name: String?
137139
}
138140

141+
public struct Plan: Decodable {
142+
public let isGift: Bool
143+
public let giftId: Int?
144+
public let paidSubscriptionId: String?
145+
public let status: String
146+
public let title: String
147+
public let currency: String?
148+
public let renewInterval: String?
149+
public let inactiveRenewInterval: String?
150+
public let renewalPrice: Decimal
151+
public let startDate: Date
152+
public let endDate: Date
153+
154+
enum CodingKeys: String, CodingKey {
155+
case isGift = "is_gift"
156+
case giftId = "gift_id"
157+
case paidSubscriptionId = "paid_subscription_id"
158+
case status
159+
case title
160+
case currency
161+
case renewInterval = "renew_interval"
162+
case inactiveRenewInterval = "inactive_renew_interval"
163+
case renewalPrice = "renewal_price"
164+
case startDate = "start_date"
165+
case endDate = "end_date"
166+
}
167+
}
168+
139169
private enum CodingKeys: String, CodingKey {
140170
case subscriberID = "subscription_id"
141171
case dotComUserID = "user_id"
142172
case displayName = "display_name"
143173
case emailAddress = "email_address"
144174
case avatar
175+
case siteURL = "url"
145176
case dateSubscribed = "date_subscribed"
146177
case isEmailSubscriptionEnabled = "is_email_subscriber"
147178
case subscriptionStatus = "subscription_status"
148179
case country
180+
case plans
149181
}
150182
}
151183

Tests/WordPressKitTests/Mock Data/site-subscriber-get-details-response.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,33 @@
1111
"country": {
1212
"code": "US",
1313
"name": "United States"
14-
}
14+
},
15+
"plans": [
16+
{
17+
"is_gift": false,
18+
"gift_id": null,
19+
"paid_subscription_id": "12422686",
20+
"status": "active",
21+
"title": "Newsletter Tier",
22+
"currency": "USD",
23+
"renew_interval": "1 month",
24+
"inactive_renew_interval": null,
25+
"renewal_price": 0.5,
26+
"start_date": "2025-01-13T18:51:55+00:00",
27+
"end_date": "2025-02-13T18:51:55+00:00"
28+
},
29+
{
30+
"is_gift": true,
31+
"gift_id": 31,
32+
"paid_subscription_id": null,
33+
"status": "active",
34+
"title": "Newsletter Tier 3",
35+
"currency": "USD",
36+
"renew_interval": "one-time",
37+
"inactive_renew_interval": null,
38+
"renewal_price": 0,
39+
"start_date": "2025-05-08T14:50:28+00:00",
40+
"end_date": "2025-06-07T14:50:28+00:00"
41+
}
42+
]
1543
}

Tests/WordPressKitTests/Tests/SubscribersServiceRemoteTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class SubscribersServiceRemoteTests: RemoteTestCase, RESTTestable {
2727

2828
XCTAssertEqual(response.country?.code, "US")
2929
XCTAssertEqual(response.country?.name, "United States")
30+
31+
let plan = try XCTUnwrap(response.plans?.first)
32+
XCTAssertFalse(plan.isGift)
33+
XCTAssertEqual(plan.status, "active")
34+
XCTAssertEqual(plan.paidSubscriptionId, "12422686")
3035
}
3136

3237
func testDecoderSubscriberStatsResponse() throws {

0 commit comments

Comments
 (0)