For resolving this issue should be implemented service for easy sending request to UptimeRobot API.
cURL shouldn't be used. Use Guzzle Http Client instead (default drupal http client).

So to be able to use

\Drupal::service('uptime_widget')->getMonitors($params);
\Drupal::service('uptime_widget')->getCurrentMonitor($params);

Or inject the sevice to the custom class.

Also need to replace current API's calls.

Comments

knyshuk.vova created an issue. See original summary.

knyshuk.vova’s picture

Issue summary: View changes
id.rem.dev’s picture

Assigned: Unassigned » id.rem.dev

I`ll try to handle this.

knyshuk.vova’s picture

Issue summary: View changes
id.rem.dev’s picture

Assigned: id.rem.dev » Unassigned
Status: Active » Needs review
StatusFileSize
new5.18 KB

Please review. Single service method to handle all requests.

knyshuk.vova’s picture

StatusFileSize
new5.16 KB

What was changed in previous patch:
- removed wrong interface implemention
- changed comment

  • knyshuk.vova authored 9e32bcd on 8.x-1.x
    Issue #2939954 by Vladimirrem, knyshuk.vova: Create uptimerobot service
    
knyshuk.vova’s picture

Status: Needs review » Fixed
lolandese’s picture

Status: Fixed » Needs work

After saving the settings form at admin/config/system/uptime-widget:

Recoverable fatal error: Argument 1 passed to Drupal\\uptime_widget\\Service\\UptimeWidgetService::sendPost() must be an instance of Drupal\\uptime_widget\\Service\\string, string given, called in /modules/contrib/uptime_widget/src/Form/UptimeAdminSettingsForm.php on line 298 and defined in /modules/contrib/uptime_widget/src/Service/UptimeWidgetService.php on line 75

id.rem.dev’s picture

Status: Needs work » Needs review
StatusFileSize
new631 bytes

Removed string declaration. Can`t reproduce with Drupal 8.6.x-dev, 8.5.x-dev, 8.4.4, 8.4.x.
Made patch from 8.x-1.x branch.

lolandese’s picture

Status: Needs review » Fixed

I used Drupal Version 8.4.3. The last change fixed the issue for this version.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.