<commit_before><?php

namespace GooseStudio\WpUpdatesAPI;

use Requests;

class WpUpdatesAPI {
	/**
	 * @var array
	 */
	private $options;
	/**
	 * @var string
	 */
	private $endpoint;

	/**
	 * WpUpdatesAPI constructor.
	 *
	 * @param string $endpoint
	 * @param array $options
	 */
	public function __construct( $endpoint, $options = null ) {
		$this->options  = $options;
		$this->endpoint = $endpoint;
	}

	/**
	 * Retrieves latest version number for a plugin or a theme.
	 *
	 * @param string $extension_name
	 *
	 * @return string
	 * @throws WpUpdatesAPIException
	 */
	public function get_latest_version( $extension_name ) {
		$headers  = [ 'Accept' => 'application/json' ];
		$response = Requests::get( $this->endpoint . '/products/' . $extension_name . '/version/', $headers, $this->options );
		if ( $response->success ) {
			return json_decode( $response->body, true );
		}
		throw new WpUpdatesAPIException( $response->body, $response->status_code );
	}

	/**
	 * @return string
	 */
	public function get_endpoint() {
		return $this->endpoint;
	}

	/**
	 * @param string $extension_name
	 *
	 * @return array
	 * @throws WpUpdatesAPIException
	 */
	public function get_extension_meta_data( $extension_name ) {
		$headers  = [ 'Accept' => 'application/json' ];
		$response = Requests::get( $this->endpoint . '/products/' . urlencode( $extension_name ), $headers, $this->options );
		if ( $response->success ) {
			return json_decode( $response->body, true );
		}
		throw new WpUpdatesAPIException( $response->body, $response->status_code );
	}

	public function get_extension_package_meta_data( $extension_name, $license_key ) {
		$headers  = [ 'Accept' => 'application/json' ];
		$query_array = [ 'extension_name' => $extension_name, 'license_key' => $license_key ];
		$query       = http_build_query( $query_array );
		$response = Requests::get( $this->endpoint . '/products/package/' . urlencode( $extension_name ), $headers, $this->options );
		if ( $response->success ) {
			return json_decode( $response->body, true );
		}
		throw new WpUpdatesAPIException( $response->body, $response->status_code );<commit_msg>add query with license key to package call<commit_after><?php

namespace GooseStudio\WpUpdatesAPI;

use Requests;

class WpUpdatesAPI {
	/**
	 * @var array
	 */
	private $options;
	/**
	 * @var string
	 */
	private $endpoint;

	/**
	 * WpUpdatesAPI constructor.
	 *
	 * @param string $endpoint
	 * @param array $options
	 */
	public function __construct( $endpoint, $options = null ) {
		$this->options  = $options;
		$this->endpoint = $endpoint;
	}

	/**
	 * Retrieves latest version number for a plugin or a theme.
	 *
	 * @param string $extension_name
	 *
	 * @return string
	 * @throws WpUpdatesAPIException
	 */
	public function get_latest_version( $extension_name ) {
		$headers  = [ 'Accept' => 'application/json' ];
		$response = Requests::get( $this->endpoint . '/products/' . $extension_name . '/version/', $headers, $this->options );
		if ( $response->success ) {
			return json_decode( $response->body, true );
		}
		throw new WpUpdatesAPIException( $response->body, $response->status_code );
	}

	/**
	 * @return string
	 */
	public function get_endpoint() {
		return $this->endpoint;
	}

	/**
	 * @param string $extension_name
	 *
	 * @return array
	 * @throws WpUpdatesAPIException
	 */
	public function get_extension_meta_data( $extension_name ) {
		$headers  = [ 'Accept' => 'application/json' ];
		$response = Requests::get( $this->endpoint . '/products/' . urlencode( $extension_name ), $headers, $this->options );
		if ( $response->success ) {
			return json_decode( $response->body, true );
		}
		throw new WpUpdatesAPIException( $response->body, $response->status_code );
	}

	public function get_extension_package_meta_data( $extension_name, $license_key ) {
		$headers  = [ 'Accept' => 'application/json' ];
		$query_array = [ 'extension_name' => $extension_name, 'license_key' => $license_key ];
		$query       = http_build_query( $query_array );
		$response = Requests::get( $this->endpoint . '/products/package/' . urlencode( $extension_name ) . '?'.$query, $headers, $this->options );
		if ( $response->success ) {
			return json_decode( $response->body, true );
		}
		throw new WpUpdatesAPIException( $response->body, $response->status_code );
{'fraction_non_alphanumeric': 0.15481171548117154, 'fraction_numerical': 0.0, 'mean_word_length': 3.9009111617312073, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1737473', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1353, 'n_words': 310}