Skip to content

Commit 65fd21a

Browse files
arcangelinimatticbot
authored andcommitted
Help Center: extend support interaction API (#40112)
Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11769196475 Upstream-Ref: Automattic/jetpack@9ef05ec
1 parent 4f5bf17 commit 65fd21a

File tree

5 files changed

+152
-87
lines changed

5 files changed

+152
-87
lines changed

composer.lock

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

vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This is an alpha version! The changes listed here are not final.
1313
- Added a feature check to the Marketing Bar that updates the text and upgrade link for Global Styles
1414
- Enable test coverage.
1515
- Help Center: add new rest route for support interactions
16+
- Help Center: extend support interaction API
1617
- The notice and modal shown on the editor now displays the plan name and upgrade URL based on the GS gated plan type'
1718

1819
### Changed

vendor/automattic/jetpack-mu-wpcom/src/features/help-center/class-wp-rest-help-center-support-interactions.php

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,29 @@ public function register_rest_route() {
3232
'methods' => \WP_REST_Server::READABLE,
3333
'callback' => array( $this, 'get_support_interactions' ),
3434
'permission_callback' => 'is_user_logged_in',
35+
'args' => array(
36+
'status' => array(
37+
'type' => 'string',
38+
'required' => false,
39+
'enum' => array(
40+
'open',
41+
'resolved',
42+
),
43+
),
44+
'page' => array(
45+
'type' => 'integer',
46+
'required' => false,
47+
'default' => 1,
48+
'minimum' => 1,
49+
),
50+
'per_page' => array(
51+
'type' => 'integer',
52+
'required' => false,
53+
'default' => 10,
54+
'minimum' => 1,
55+
'maximum' => 100,
56+
),
57+
),
3558
)
3659
);
3760

@@ -54,7 +77,7 @@ public function register_rest_route() {
5477
'permission_callback' => 'is_user_logged_in',
5578
'args' => array(
5679
'event_external_id' => array(
57-
'type' => 'int',
80+
'type' => 'string',
5881
'required' => true,
5982
),
6083
'event_source' => array(
@@ -78,7 +101,7 @@ public function register_rest_route() {
78101
'permission_callback' => 'is_user_logged_in',
79102
'args' => array(
80103
'event_external_id' => array(
81-
'type' => 'int',
104+
'type' => 'string',
82105
'required' => true,
83106
),
84107
'event_source' => array(
@@ -92,6 +115,26 @@ public function register_rest_route() {
92115
),
93116
)
94117
);
118+
119+
register_rest_route(
120+
$this->namespace,
121+
'/' . $this->rest_base . '/(?P<support_interaction_id>[a-zA-Z0-9-]+)/status',
122+
array(
123+
'methods' => \WP_REST_Server::EDITABLE,
124+
'callback' => array( $this, 'update_support_interaction_status' ),
125+
'permission_callback' => 'is_user_logged_in',
126+
'args' => array(
127+
'status' => array(
128+
'type' => 'string',
129+
'required' => true,
130+
'enum' => array(
131+
'open',
132+
'resolved',
133+
),
134+
),
135+
),
136+
)
137+
);
95138
}
96139

97140
/**
@@ -173,4 +216,25 @@ public function create_support_interaction_event( \WP_REST_Request $request ) {
173216

174217
return rest_ensure_response( $response );
175218
}
219+
220+
/**
221+
* Update support interaction status.
222+
*
223+
* @param \WP_REST_Request $request The request sent to the API.
224+
*/
225+
public function update_support_interaction_status( \WP_REST_Request $request ) {
226+
$support_interaction_id = isset( $request['support_interaction_id'] ) ? (int) $request['support_interaction_id'] : null;
227+
228+
$status = $request['status'];
229+
230+
$body = Client::wpcom_json_api_request_as_user( "/support-interactions/$support_interaction_id/status?status={$status}" );
231+
232+
if ( is_wp_error( $body ) ) {
233+
return $body;
234+
}
235+
236+
$response = json_decode( wp_remote_retrieve_body( $body ) );
237+
238+
return rest_ensure_response( $response );
239+
}
176240
}

0 commit comments

Comments
 (0)