original_string: public function fetch($action, $params)
      {
          $endpoint = sprintf('%s/api/%s/', $this->domain, $this->version);
  
          $query = Http::buildQuery($params);
          $url   = sprintf('%s%s?%s', $endpoint, $action, $query);
  
          $response = $this->download($url);
  
          $result = json_decode($response, true);
  
          if (is_null($result)) {
              $message = sprintf('There was an error reading the response from the Marketplace: Please try again later.');
              throw new Service\Exception($message, Service\Exception::HTTP_ERROR);
          }
  
          if (!empty($result['error'])) {
              throw new Service\Exception($result['error'], Service\Exception::API_ERROR);
          }
  
          return $result;
      }
code: public function fetch($action, $params)
      {
          $endpoint = sprintf('%s/api/%s/', $this->domain, $this->version);
  
          $query = Http::buildQuery($params);
          $url   = sprintf('%s%s?%s', $endpoint, $action, $query);
  
          $response = $this->download($url);
  
          $result = json_decode($response, true);
  
          if (is_null($result)) {
              $message = sprintf('There was an error reading the response from the Marketplace: Please try again later.');
              throw new Service\Exception($message, Service\Exception::HTTP_ERROR);
          }
  
          if (!empty($result['error'])) {
              throw new Service\Exception($result['error'], Service\Exception::API_ERROR);
          }
  
          return $result;
      }
code_tokens: public function fetch ( $ action , $ params ) { $ endpoint = sprintf ( '%s/api/%s/' , $ this -> domain , $ this -> version ) ; $ query = Http :: buildQuery ( $ params ) ; $ url = sprintf ( '%s%s?%s' , $ endpoint , $ action , $ query ) ; $ response = $ this -> download ( $ url ) ; $ result = json_decode ( $ response , true ) ; if ( is_null ( $ result ) ) { $ message = sprintf ( 'There was an error reading the response from the Marketplace: Please try again later.' ) ; throw new Service \ Exception ( $ message , Service \ Exception :: HTTP_ERROR ) ; } if ( ! empty ( $ result [ 'error' ] ) ) { throw new Service \ Exception ( $ result [ 'error' ] , Service \ Exception :: API_ERROR ) ; } return $ result ; }
docstring: Executes the given API action on the Marketplace using the given params and returns the result.
  
  Make sure to call {@link authenticate()} to download paid plugins.
  
  @param string $action  eg 'plugins', 'plugins/$pluginName/info', ...
  @param array $params   eg array('sort' => 'alpha')
  @return mixed
  @throws Service\Exception
docstring_tokens: Executes the given API action on the Marketplace using the given params and returns the result .