You are here

protected function MolliePaymentInstaller::getLatestsMollieApiClientUrl in Mollie Payment 7.2

Returns the URL of the zip with the latest version of the client.

Return value

string The URL of the zip with the latest version of the Mollie API client for PHP.

Throws

\Exception

1 call to MolliePaymentInstaller::getLatestsMollieApiClientUrl()
MolliePaymentInstaller::downloadLatestsMollieApiClient in includes/mollie_payment.installer.inc
Downloads the latest version of the client.

File

includes/mollie_payment.installer.inc, line 295

Class

MolliePaymentInstaller
Class MolliePaymentInstaller.

Namespace

Drupal\mollie_payment

Code

protected function getLatestsMollieApiClientUrl() {

  // Fetch information about latest release.
  $response = drupal_http_request(self::MOLLIE_API_CLIENT_URL);
  if (isset($response->data)) {
    $release = drupal_json_decode($response->data);

    // Return the URL of the zip.
    if (isset($release['assets']) && !empty($release['assets'])) {
      foreach ($release['assets'] as $asset) {
        if ($asset['content_type'] == 'application/zip') {
          return $asset['browser_download_url'];
        }
      }
    }
  }
  throw new \Exception('The Mollie API client for PHP could not be found on GitHub.');
}