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

Commit 686e007

Browse files
authored
Add JetpackAIServiceRemote/getAssistantFeatureDetails (#805)
2 parents c064bf5 + ee0f15c commit 686e007

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import Foundation
2+
3+
public final class JetpackAssistantFeatureDetails: Codable {
4+
public let hasFeature: Bool
5+
/// Returns `true` if you are out of limit for the current plan.
6+
public let isOverLimit: Bool
7+
/// The all-time request count.
8+
public let requestsCount: Int
9+
/// The request limit for a free plan.
10+
public let requestsLimit: Int
11+
/// Contains data about the user plan.
12+
public let currentTier: Tier?
13+
public let usagePeriod: UsagePeriod?
14+
public let isSiteUpdateRequired: Bool?
15+
public let upgradeType: String?
16+
public let nextTier: Tier?
17+
public let tierPlans: [Tier]?
18+
public let tierPlansEnabled: Bool?
19+
public let costs: Costs?
20+
21+
public struct Tier: Codable {
22+
public let slug: String?
23+
public let limit: Int
24+
public let value: Int
25+
public let readableLimit: String?
26+
27+
enum CodingKeys: String, CodingKey {
28+
case slug, limit, value
29+
case readableLimit = "readable-limit"
30+
}
31+
}
32+
33+
public struct UsagePeriod: Codable {
34+
public let currentStart: String?
35+
public let nextStart: String?
36+
public let requestsCount: Int
37+
38+
enum CodingKeys: String, CodingKey {
39+
case currentStart = "current-start"
40+
case nextStart = "next-start"
41+
case requestsCount = "requests-count"
42+
}
43+
}
44+
45+
public struct Costs: Codable {
46+
public let jetpackAILogoGenerator: JetpackAILogoGenerator
47+
public let featuredPostImage: FeaturedPostImage
48+
49+
enum CodingKeys: String, CodingKey {
50+
case jetpackAILogoGenerator = "jetpack-ai-logo-generator"
51+
case featuredPostImage = "featured-post-image"
52+
}
53+
}
54+
55+
public struct FeaturedPostImage: Codable {
56+
public let image: Int
57+
}
58+
59+
public struct JetpackAILogoGenerator: Codable {
60+
public let logo: Int
61+
}
62+
63+
enum CodingKeys: String, CodingKey {
64+
case hasFeature = "has-feature"
65+
case isOverLimit = "is-over-limit"
66+
case requestsCount = "requests-count"
67+
case requestsLimit = "requests-limit"
68+
case usagePeriod = "usage-period"
69+
case isSiteUpdateRequired = "site-require-upgrade"
70+
case upgradeType = "upgrade-type"
71+
case currentTier = "current-tier"
72+
case nextTier = "next-tier"
73+
case tierPlans = "tier-plans"
74+
case tierPlansEnabled = "tier-plans-enabled"
75+
case costs
76+
}
77+
}

Sources/WordPressKit/Services/JetpackAIServiceRemote.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import Foundation
22

33
public final class JetpackAIServiceRemote: SiteServiceRemoteWordPressComREST {
4+
5+
/// Returns information about your current tier, requests limit, and more.
6+
public func getAssistantFeatureDetails() async throws -> JetpackAssistantFeatureDetails {
7+
let path = path(forEndpoint: "sites/\(siteID)/jetpack-ai/ai-assistant-feature", withVersion: ._2_0)
8+
let response = await wordPressComRestApi.perform(.get, URLString: path, type: JetpackAssistantFeatureDetails.self)
9+
return try response.get().body
10+
}
11+
412
/// Returns short-lived JWT token (lifetime is in minutes).
513
public func getAuthorizationToken() async throws -> String {
614
struct Response: Decodable {

WordPressKit.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
019C5B8B2BD59CE000A69DB0 /* StatsEmailsSummaryData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 019C5B892BD59CE000A69DB0 /* StatsEmailsSummaryData.swift */; };
1717
0847B92C2A4442730044D32F /* IPLocationRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0847B92B2A4442730044D32F /* IPLocationRemote.swift */; };
1818
08C7493E2A45EA11000DA0E2 /* IPLocationRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C7493D2A45EA11000DA0E2 /* IPLocationRemoteTests.swift */; };
19+
0C0791B22BFE7DE50049C06E /* JetpackAssistantFeatureDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C0791B12BFE7DE50049C06E /* JetpackAssistantFeatureDetails.swift */; };
1920
0C1C08412B9CD79900E52F8C /* PostServiceRemoteExtended.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C1C08402B9CD79900E52F8C /* PostServiceRemoteExtended.swift */; };
2021
0C1C08432B9CD8D200E52F8C /* PostServiceRemoteREST+Extended.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C1C08422B9CD8D200E52F8C /* PostServiceRemoteREST+Extended.swift */; };
2122
0C1C08452B9CDB0B00E52F8C /* PostServiceRemoteXMLRPC+Extended.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C1C08442B9CDB0B00E52F8C /* PostServiceRemoteXMLRPC+Extended.swift */; };
@@ -770,6 +771,7 @@
770771
019C5B892BD59CE000A69DB0 /* StatsEmailsSummaryData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatsEmailsSummaryData.swift; sourceTree = "<group>"; };
771772
0847B92B2A4442730044D32F /* IPLocationRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPLocationRemote.swift; sourceTree = "<group>"; };
772773
08C7493D2A45EA11000DA0E2 /* IPLocationRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPLocationRemoteTests.swift; sourceTree = "<group>"; };
774+
0C0791B12BFE7DE50049C06E /* JetpackAssistantFeatureDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackAssistantFeatureDetails.swift; sourceTree = "<group>"; };
773775
0C1C08402B9CD79900E52F8C /* PostServiceRemoteExtended.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostServiceRemoteExtended.swift; sourceTree = "<group>"; };
774776
0C1C08422B9CD8D200E52F8C /* PostServiceRemoteREST+Extended.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostServiceRemoteREST+Extended.swift"; sourceTree = "<group>"; };
775777
0C1C08442B9CDB0B00E52F8C /* PostServiceRemoteXMLRPC+Extended.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostServiceRemoteXMLRPC+Extended.swift"; sourceTree = "<group>"; };
@@ -1560,6 +1562,14 @@
15601562
path = Emails;
15611563
sourceTree = "<group>";
15621564
};
1565+
0C0791B02BFE7DDB0049C06E /* Assistant */ = {
1566+
isa = PBXGroup;
1567+
children = (
1568+
0C0791B12BFE7DE50049C06E /* JetpackAssistantFeatureDetails.swift */,
1569+
);
1570+
path = Assistant;
1571+
sourceTree = "<group>";
1572+
};
15631573
3297E1DC2564649D00287D21 /* Scan */ = {
15641574
isa = PBXGroup;
15651575
children = (
@@ -1741,6 +1751,7 @@
17411751
3FE2E93F2BB11038002CA2E1 /* Models */ = {
17421752
isa = PBXGroup;
17431753
children = (
1754+
0C0791B02BFE7DDB0049C06E /* Assistant */,
17441755
3FE2E93D2BB1100F002CA2E1 /* Atomic */,
17451756
3FE2E93C2BB10FF1002CA2E1 /* Blaze */,
17461757
3FE2E9392BB10F67002CA2E1 /* Plugins */,
@@ -3355,6 +3366,7 @@
33553366
4041405E220F9EF500CF7C5B /* StatsDotComFollowersInsight.swift in Sources */,
33563367
74650F721F0EA1A700188EDB /* GravatarServiceRemote.swift in Sources */,
33573368
B5969E1D20A49AC4005E9DF1 /* NSString+MD5.m in Sources */,
3369+
0C0791B22BFE7DE50049C06E /* JetpackAssistantFeatureDetails.swift in Sources */,
33583370
01438D3B2B6A36BF0097D60A /* StatsTotalsSummaryData.swift in Sources */,
33593371
4A68E3E1294076C1004AC3DC /* RemoteReaderSiteInfo.swift in Sources */,
33603372
8236EB4D2024B9F8007C7CF9 /* RemoteBlogJetpackModulesSettings.swift in Sources */,

0 commit comments

Comments
 (0)