class-wpml-tm-icl20-acknowledge.php
1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @author OnTheGo Systems
*/
class WPML_TM_ICL20_Acknowledge {
private $end_point;
private $http;
/**
* WPML_TM_ICL20 constructor.
*
* @param WP_Http $http
* @param string $end_point
*/
public function __construct( WP_Http $http, $end_point ) {
$this->http = $http;
$this->end_point = $end_point;
}
/**
* @param string $ts_accesskey
* @param int $ts_id
*
* @return bool
* @throws \WPML_TM_ICL20MigrationException
*
* Note: `ts_id` (aka `website_id`) = `website_id`
*
* @link https://onthegosystems.myjetbrains.com/youtrack/issue/icldev-2322
*/
public function acknowledge_icl( $ts_id, $ts_accesskey ) {
$url = $this->end_point . '/wpml/websites/' . $ts_id . '/migrated';
$url = add_query_arg( array(
'accesskey' => $ts_accesskey,
),
$url );
$response = $this->http->post( $url,
array(
'method' => 'POST',
'headers' => array(
'Accept' => 'application/json',
'Content-Type' => 'application/json',
),
) );
$code = (int) $response['response']['code'];
if ( $code !== 200 ) {
throw new WPML_TM_ICL20MigrationException( $response['response']['message'], $code );
}
return true;
}
}