@@ -138,42 +138,22 @@ function ( $path ) {
138138 * @return array
139139 */
140140 public function get_endpoint_schema ( $ endpoint , $ backend , $ method = null ) {
141- $ bytes = random_bytes ( 16 );
142- $ bytes [6 ] = chr ( ord ( $ bytes [6 ] ) & 0x0f | 0x40 );
143- $ bytes [8 ] = chr ( ord ( $ bytes [8 ] ) & 0x3f | 0x80 );
144- $ uuid = vsprintf ( '%s%s-%s-%s-%s-%s%s%s ' , str_split ( bin2hex ( $ bytes ), 4 ) );
141+ if ( ! function_exists ( 'yaml_parse ' ) ) {
142+ return array ();
143+ }
145144
146- $ response = wp_remote_get (
147- self ::OAS_URL ,
148- array (
149- 'headers ' => array (
150- 'Accept ' => 'application/json ' ,
151- 'Host ' => 'developers.brevo.com ' ,
152- 'Referer ' => 'https://developers.brevo.com/reference/get_companies ' ,
153- 'Alt-Used ' => 'developers.brevo.com ' ,
154- 'User-Agent ' => 'Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0 ' ,
155- 'X-Requested-With ' => 'XMLHttpRequest ' ,
156- ),
157- 'cookies ' => array (
158- 'anonymous_id ' => $ uuid ,
159- 'first_referrer ' => 'https://app.brevo.com/ ' ,
160- 'pscd ' => 'get.brevo.com ' ,
161- 'readme_language ' => 'shell ' ,
162- 'readme_library ' => '{%22shell%22:%22curl%22} ' ,
163- ),
164- )
165- );
145+ $ response = wp_remote_get ( self ::OAS_URL );
166146
167147 if ( is_wp_error ( $ response ) ) {
168148 return array ();
169149 }
170150
171- $ data = json_decode ( $ response ['body ' ], true );
151+ $ data = yaml_parse ( $ response ['body ' ] );
172152 if ( ! $ data ) {
173153 return array ();
174154 }
175155
176- $ oa_explorer = new OpenAPI ( $ data[ ' oasDefinition ' ] );
156+ $ oa_explorer = new OpenAPI ( $ data );
177157
178158 $ method = strtolower ( $ method ?? 'post ' );
179159 $ path = preg_replace ( '/^\/v\d+/ ' , '' , $ endpoint );
0 commit comments