'GET', 'blocking' => true, ]; // If there is data, request will be POST request, otherwise it will be GET if ($data) { $params['method'] = 'POST'; $params['body'] = $data; } // If authorization is needed, send token to the request header if ($authorize) { /** @var SettingsService $settingsService */ $settingsService = $this->getContainer()->get('domain.settings.service'); $params['headers']['Authorization'] = "Bearer {$settingsService->getSetting('notifications', 'smsApiToken')}"; } $response = wp_remote_post(AMELIA_SMS_API_URL . $route, $params); return !is_wp_error($response) ? json_decode($response['body']) : ''; } }