You are here

public function CommerceGuysMarketplaceAddonManager::getLicenses in Commerce Guys Marketplace 7

Returns an array of addon licenses.

Parameters

$category: (optional) The id of the category to filter the query by.

File

includes/commerceguys_marketplace.addon.inc, line 98

Class

CommerceGuysMarketplaceAddonManager
Defines the manager class for interacting with remote marketplace addons.

Code

public function getLicenses($category = 0) {

  // Authorize the site and get an access token.
  $access_token = $this
    ->getAccessToken();
  $options = array(
    'headers' => array(
      'Authorization' => 'Bearer ' . $access_token['token'],
    ),
  );

  // Filter by category if needed.
  $params = array();
  if (!empty($category)) {
    $params['category'] = $category;
  }
  $url = url($this->endpoint . '/addon_licenses', array(
    'query' => $params,
  ));
  $response = drupal_http_request($url, $options);
  $result = json_decode($response->data);
  return array(
    'results' => $result->results,
    'result_count' => $result->result_count,
  );
}