Skip to content

Commit 3914afb

Browse files
jkmasseloguzkocer
andauthored
Add Support Tickets + Eligibility endpoints (#743)
* Add support tickets endpoints * Add support eligibility endpoint support Add Swift Support Eligibility support * add wp_com_e2e package * Remove `Testable` trait and simplify wp_com_e2e tests * Update imports in wp_com_e2e/src/main --------- Co-authored-by: Oguz Kocer <[email protected]>
1 parent f66f337 commit 3914afb

18 files changed

+626
-2
lines changed

Cargo.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"wp_api_integration_tests",
55
"wp_api_integration_tests_backend",
66
"wp_cli",
7+
"wp_com_e2e",
78
"wp_contextual",
89
"wp_derive",
910
"wp_derive_request_builder",

native/swift/Sources/wordpress-api/Exports.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ public typealias CreateBotConversationParams = WordPressAPIInternal.CreateBotCon
179179
public typealias AddMessageToBotConversationParams = WordPressAPIInternal.AddMessageToBotConversationParams
180180
public typealias GetBotConversationParams = WordPressAPIInternal.GetBotConversationParams
181181
public typealias CreateBotConversationFeedbackParams = WordPressAPIInternal.CreateBotConversationFeedbackParams
182+
183+
// MARK: Support Tickets
184+
public typealias CreateSupportTicketParams = WordPressAPIInternal.CreateSupportTicketParams
185+
public typealias AddMessageToSupportConversationParams = WordPressAPIInternal.AddMessageToSupportConversationParams

native/swift/Sources/wordpress-api/WPComApiClient.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ public class WPComApiClient {
2525
public var supportBots: SupportBotsRequestExecutor {
2626
internalClient.supportBots()
2727
}
28+
29+
public var supportEligibility: SupportEligibilityRequestExecutor {
30+
internalClient.supportEligibility()
31+
}
32+
33+
public var supportTickets: SupportTicketsRequestExecutor {
34+
internalClient.supportTickets()
35+
}
2836
}

wp_api/src/wp_com/client.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ use super::endpoint::{
66
oauth2::{Oauth2RequestBuilder, Oauth2RequestExecutor},
77
subscribers_endpoint::{SubscribersRequestBuilder, SubscribersRequestExecutor},
88
support_bots_endpoint::{SupportBotsRequestBuilder, SupportBotsRequestExecutor},
9+
support_eligibility_endpoint::{
10+
SupportEligibilityRequestBuilder, SupportEligibilityRequestExecutor,
11+
},
12+
support_tickets_endpoint::{SupportTicketsRequestBuilder, SupportTicketsRequestExecutor},
913
};
1014
use crate::{
1115
api_client::WpApiClientDelegate, api_client_generate_api_client,
@@ -36,6 +40,8 @@ pub struct WpComApiRequestBuilder {
3640
oauth2: Arc<Oauth2RequestBuilder>,
3741
subscribers: Arc<SubscribersRequestBuilder>,
3842
support_bots: Arc<SupportBotsRequestBuilder>,
43+
support_eligibility: Arc<SupportEligibilityRequestBuilder>,
44+
support_tickets: Arc<SupportTicketsRequestBuilder>,
3945
}
4046

4147
impl WpComApiRequestBuilder {
@@ -49,7 +55,9 @@ impl WpComApiRequestBuilder {
4955
jetpack_connection,
5056
oauth2,
5157
subscribers,
52-
support_bots
58+
support_bots,
59+
support_eligibility,
60+
support_tickets
5361
)
5462
}
5563
}
@@ -75,6 +83,8 @@ pub struct WpComApiClient {
7583
oauth2: Arc<Oauth2RequestExecutor>,
7684
subscribers: Arc<SubscribersRequestExecutor>,
7785
support_bots: Arc<SupportBotsRequestExecutor>,
86+
support_eligibility: Arc<SupportEligibilityRequestExecutor>,
87+
support_tickets: Arc<SupportTicketsRequestExecutor>,
7888
}
7989

8090
impl WpComApiClient {
@@ -89,7 +99,9 @@ impl WpComApiClient {
8999
jetpack_connection,
90100
oauth2,
91101
subscribers,
92-
support_bots
102+
support_bots,
103+
support_eligibility,
104+
support_tickets
93105
)
94106
}
95107
}
@@ -98,3 +110,5 @@ api_client_generate_endpoint_impl!(WpComApi, jetpack_connection);
98110
api_client_generate_endpoint_impl!(WpComApi, oauth2);
99111
api_client_generate_endpoint_impl!(WpComApi, subscribers);
100112
api_client_generate_endpoint_impl!(WpComApi, support_bots);
113+
api_client_generate_endpoint_impl!(WpComApi, support_eligibility);
114+
api_client_generate_endpoint_impl!(WpComApi, support_tickets);

wp_api/src/wp_com/endpoint.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub mod jetpack_connection_endpoint;
1212
pub mod oauth2;
1313
pub mod subscribers_endpoint;
1414
pub mod support_bots_endpoint;
15+
pub mod support_eligibility_endpoint;
16+
pub mod support_tickets_endpoint;
1517

1618
#[derive(uniffi::Object)]
1719
pub struct WpComDotOrgApiUrlResolver {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use wp_derive_request_builder::WpDerivedRequest;
2+
3+
use crate::{
4+
request::endpoint::{AsNamespace, DerivedRequest},
5+
wp_com::{WpComNamespace, support_eligibility::SupportEligibility},
6+
};
7+
8+
#[derive(WpDerivedRequest)]
9+
enum SupportEligibilityRequest {
10+
#[get(url = "/mobile-support/eligibility", output = SupportEligibility)]
11+
GetSupportEligibility,
12+
}
13+
14+
impl DerivedRequest for SupportEligibilityRequest {
15+
fn namespace() -> impl AsNamespace {
16+
WpComNamespace::V2
17+
}
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use crate::{
2+
request::endpoint::{AsNamespace, DerivedRequest},
3+
wp_com::{
4+
WpComNamespace,
5+
support_tickets::{
6+
AddMessageToSupportConversationParams, ConversationId, CreateSupportTicketParams,
7+
SupportConversation, SupportConversationSummary,
8+
},
9+
},
10+
};
11+
use wp_derive_request_builder::WpDerivedRequest;
12+
13+
#[derive(WpDerivedRequest)]
14+
enum SupportTicketsRequest {
15+
#[post(url = "/mobile-support/conversations", params = &CreateSupportTicketParams, output = SupportConversation)]
16+
CreateSupportTicket,
17+
#[get(url = "/mobile-support/conversations", output = Vec<SupportConversationSummary>)]
18+
GetSupportConversationList,
19+
#[get(url = "/mobile-support/conversations/<conversation_id>", output = SupportConversation)]
20+
GetSupportConversation,
21+
#[post(url = "/mobile-support/conversations/<conversation_id>", params = &AddMessageToSupportConversationParams, output = SupportConversation)]
22+
AddMessageToSupportConversation,
23+
}
24+
25+
impl DerivedRequest for SupportTicketsRequest {
26+
fn namespace() -> impl AsNamespace {
27+
WpComNamespace::V2
28+
}
29+
}

wp_api/src/wp_com/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub mod jetpack_connection;
1010
pub mod oauth2;
1111
pub mod subscribers;
1212
pub mod support_bots;
13+
pub mod support_eligibility;
14+
pub mod support_tickets;
1315

1416
impl_as_query_value_for_new_type!(WpComSiteId);
1517
uniffi::custom_newtype!(WpComSiteId, u64);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)]
4+
pub struct SupportEligibility {
5+
pub is_user_eligible: bool,
6+
}

0 commit comments

Comments
 (0)