Skip to content

Commit 924f7ae

Browse files
committed
feat: brevo addon test case
1 parent bebf1ee commit 924f7ae

File tree

3 files changed

+464
-27
lines changed

3 files changed

+464
-27
lines changed

forms-bridge/addons/brevo/class-brevo-addon.php

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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 );

forms-bridge/addons/zoho/class-zoho-form-bridge.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ function ( $headers, $backend ) {
7575
if ( ! $backend ) {
7676
return new WP_Error(
7777
'invalid_backend',
78-
'The bridge does not have a valid backend'
78+
'The bridge does not have a valid backend',
79+
(array) $this->data,
7980
);
8081
}
8182

0 commit comments

Comments
 (0)