Skip to content

Commit 8897cdb

Browse files
committed
fix: sendy authorization issue fixed
1 parent e4c0b0b commit 8897cdb

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

frontend-dev/src/components/AllIntegrations/Log.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ function Log({ allIntegURL }) {
220220
fontFamily: "'Fira Code', monospace",
221221
fontSize: '14px',
222222
overflow: 'auto',
223-
width: '100%',
224223
maxWidth: '800px',
225224
maxHeight: '500px',
226225
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',

includes/Actions/Sendy/SendyController.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,15 @@
66

77
namespace BitCode\FI\Actions\Sendy;
88

9-
use WP_Error;
10-
use BitCode\FI\Log\LogHandler;
119
use BitCode\FI\Core\Util\HttpHelper;
10+
use BitCode\FI\Log\LogHandler;
11+
use WP_Error;
1212

1313
/**
1414
* Provide functionality for MailChimp integration
1515
*/
1616
class SendyController
1717
{
18-
private $_integrationID;
19-
20-
// public function __construct($integrationID)
21-
// {
22-
// $this->_integrationID = $integrationID;
23-
// }
24-
2518
/**
2619
* Process ajax request for generate_token
2720
*
@@ -31,7 +24,7 @@ class SendyController
3124
*/
3225
public static function sendyAuthorize($requestsParams)
3326
{
34-
if (empty($requestsParams->api_key)) {
27+
if (empty($requestsParams->api_key) || empty($requestsParams->sendy_url)) {
3528
wp_send_json_error(
3629
__(
3730
'Requested parameter is empty',
@@ -40,16 +33,16 @@ public static function sendyAuthorize($requestsParams)
4033
400
4134
);
4235
}
43-
$apiKey = $requestsParams->api_key;
44-
$sendy_url = $requestsParams->sendy_url;
45-
$apiEndpoint = "{$sendy_url}/includes/helpers/integrations/zapier/triggers/dropdowns.php?api_key={$apiKey}&event=brands";
46-
$authorizationHeader['Accept'] = 'application/json';
47-
// $authorizationHeader["api-key"] = $requestsParams->api_key;
48-
$apiResponse = HttpHelper::get($apiEndpoint, null, $authorizationHeader);
4936

50-
if (is_wp_error($apiResponse) || !\is_array($apiResponse)) {
37+
$apiEndpoint = "{$requestsParams->sendy_url}/api/brands/get-brands.php";
38+
$authorizationHeader = ['Accept' => 'application/json'];
39+
$requestsParams = ['api_key' => $requestsParams->api_key];
40+
41+
$apiResponse = HttpHelper::post($apiEndpoint, $requestsParams, $authorizationHeader);
42+
43+
if (HttpHelper::$responseCode !== 200 && (is_wp_error($apiResponse) || !\is_array($apiResponse))) {
5144
wp_send_json_error(
52-
empty($apiResponse->code) ? 'Unknown' : $apiResponse->message,
45+
empty($apiResponse->message) ? $apiResponse : $apiResponse->message,
5346
400
5447
);
5548
}

0 commit comments

Comments
 (0)