diff options
Diffstat (limited to 'plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php')
-rw-r--r-- | plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php | 183 |
1 files changed, 182 insertions, 1 deletions
diff --git a/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php b/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php index bf8d23ea..918349ce 100644 --- a/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php +++ b/plugins/jetpack/json-endpoints/jetpack/json-api-jetpack-endpoints.php @@ -1134,9 +1134,60 @@ new Jetpack_JSON_API_Cron_Unschedule_Endpoint( array( ) ); // BACKUPS -require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-post-backup-endpoint.php' ); + +// GET /sites/%s/comments/%d/backup +require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-comment-backup-endpoint.php' ); +new Jetpack_JSON_API_Get_Comment_Backup_Endpoint( array( + 'description' => 'Fetch a backup of a comment, along with all of its metadata', + 'group' => '__do_not_document', + 'method' => 'GET', + 'path' => '/sites/%s/comments/%d/backup', + 'stat' => 'comments:1:backup', + 'allow_jetpack_site_auth' => true, + 'path_labels' => array( + '$site' => '(int|string) The site ID, The site domain', + '$post' => '(int) The comment ID', + ), + 'response_format' => array( + 'comment' => '(array) Comment table row', + 'meta' => '(array) Associative array of key/value commentmeta data', + ), + 'example_request_data' => array( + 'headers' => array( + 'authorization' => 'Bearer YOUR_API_TOKEN' + ), + ), + 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/comments/1/backup' +) ); + +// GET /sites/%s/options/backup +require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-option-backup-endpoint.php' ); +new Jetpack_JSON_API_Get_Option_Backup_Endpoint( array( + 'description' => 'Fetch a backup of an option', + 'group' => '__do_not_document', + 'method' => 'GET', + 'path' => '/sites/%s/options/backup', + 'stat' => 'options:backup', + 'allow_jetpack_site_auth' => true, + 'path_labels' => array( + '$site' => '(int|string) The site ID, The site domain', + ), + 'query_parameters' => array( + 'name' => '(string|array) One or more option names to include in the backup', + ), + 'response_format' => array( + 'options' => '(array) Associative array of option_name => option_value entries', + ), + 'example_request_data' => array( + 'headers' => array( + 'authorization' => 'Bearer YOUR_API_TOKEN' + ) + ), + 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/options/backup' +) ); // GET /sites/%s/posts/%d/backup +require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-post-backup-endpoint.php' ); new Jetpack_JSON_API_Get_Post_Backup_Endpoint( array( 'description' => 'Fetch a backup of a post, along with all of its metadata', 'group' => '__do_not_document', @@ -1159,3 +1210,133 @@ new Jetpack_JSON_API_Get_Post_Backup_Endpoint( array( ), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/posts/1/backup' ) ); + +// GET /sites/%s/terms/%d/backup +require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-term-backup-endpoint.php' ); +new Jetpack_JSON_API_Get_Term_Backup_Endpoint( array( + 'description' => 'Fetch a backup of a term, along with all of its metadata', + 'group' => '__do_not_document', + 'method' => 'GET', + 'path' => '/sites/%s/terms/%d/backup', + 'stat' => 'terms:1:backup', + 'allow_jetpack_site_auth' => true, + 'path_labels' => array( + '$site' => '(int|string) The site ID, The site domain', + '$term' => '(int) The term ID', + ), + 'response_format' => array( + 'term' => '(array) Term table row', + 'meta' => '(array) Metadata associated with the term', + ), + 'example_request_data' => array( + 'headers' => array( + 'authorization' => 'Bearer YOUR_API_TOKEN' + ), + ), + 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/terms/1/backup' +) ); + +// GET /sites/%s/users/%d/backup +require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-get-user-backup-endpoint.php' ); +new Jetpack_JSON_API_Get_User_Backup_Endpoint( array( + 'description' => 'Fetch a backup of a user, along with all of its metadata', + 'group' => '__do_not_document', + 'method' => 'GET', + 'path' => '/sites/%s/users/%d/backup', + 'stat' => 'users:1:backup', + 'allow_jetpack_site_auth' => true, + 'path_labels' => array( + '$site' => '(int|string) The site ID, The site domain', + '$user' => '(int) The user ID', + ), + 'response_format' => array( + 'user' => '(array) User table row', + 'meta' => '(array) Associative array of key/value usermeta data', + ), + 'example_request_data' => array( + 'headers' => array( + 'authorization' => 'Bearer YOUR_API_TOKEN' + ), + ), + 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/users/1/backup' +) ); + +// USERS + +require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-user-connect-endpoint.php' ); + +// POST /sites/%s/users/%d/connect +new Jetpack_JSON_API_User_Connect_Endpoint( array( + 'description' => 'Creates or returns a new user given profile data', + 'group' => '__do_not_document', + 'method' => 'POST', + 'path' => '/sites/%s/users/%d/connect', + 'stat' => 'users:connect', + 'allow_jetpack_site_auth' => true, + 'path_labels' => array( + '$site' => '(int|string) The site ID, The site domain', + '$user_id' => '(int) The site user ID to connect', + ), + 'request_format' => array( + 'user_token' => '(string) The user token', + ), + 'response_format' => array( + 'success' => '(bool) Was the user connected', + ), + 'example_request_data' => array( + 'headers' => array( + 'authorization' => 'Bearer YOUR_API_TOKEN', + ), + 'body' => array( + 'user_token' => 'XDH55jndskjf3klh3', + ) + ), + 'example_response' => '{ + "success" => true + }', + 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/users/6/connect' +) ); + +require_once( $json_jetpack_endpoints_dir . 'class.jetpack-json-api-user-create-endpoint.php' ); + +// POST /sites/%s/users/create +new Jetpack_JSON_API_User_Create_Endpoint( array( + 'description' => 'Creates or returns a new user given profile data', + 'group' => '__do_not_document', + 'method' => 'POST', + 'path' => '/sites/%s/users/create', + 'stat' => 'users:create', + 'allow_jetpack_site_auth' => true, + 'path_labels' => array( + '$site' => '(int|string) The site ID, The site domain', + ), + 'request_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format, + 'response_format' => WPCOM_JSON_API_Site_User_Endpoint::$user_format, + 'example_request_data' => array( + 'headers' => array( + 'authorization' => 'Bearer YOUR_API_TOKEN' + ), + 'body' => array( + 'roles' => array( + array( + 'administrator', + ) + ), + 'first_name' => 'John', + 'last_name' => 'Doe', + 'email' => 'john.doe@example.wordpress.org', + ) + ), + 'example_response' => '{ + "ID": 18342963, + "login": "binarysmash" + "email": false, + "name": "binarysmash", + "URL": "http:\/\/binarysmash.wordpress.com", + "avatar_URL": "http:\/\/0.gravatar.com\/avatar\/a178ebb1731d432338e6bb0158720fcc?s=96&d=identicon&r=G", + "profile_URL": "http:\/\/en.gravatar.com\/binarysmash", + "roles": [ "administrator" ] + }', + 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/users/create' + +) ); |