<commit_before><?php namespace Arcanedev\Currencies\Services;

use Arcanedev\Currencies\Exceptions\ApiException;
use Illuminate\Support\Arr;

/**
 * Class     OpenExchangeRatesService
 *
 * @package  Arcanedev\Currencies\Services
 * @author   ARCANEDEV <<EMAIL>>
 */
class OpenExchangeRatesService extends AbstractService
{
    /* ------------------------------------------------------------------------------------------------
     |  Properties
     | ------------------------------------------------------------------------------------------------
     */
    /**
     * The base URL.
     *
     * @var string
     */
    protected $baseUrl = 'http://openexchangerates.org/api';

    /**
     * The API ID.
     *
     * @var string
     */
    protected $apiId;

    /**
     * The Pro Plan.
     *
     * @var bool
     */
    protected $proPlan = false;

    /* ------------------------------------------------------------------------------------------------
     |  Getters & Setters
     | ------------------------------------------------------------------------------------------------
     */
    /**
     * Set the configs.
     *
     * @param  array  $configs
     */
    protected function setProviderConfigs(array $configs)
    {
        $this->apiId   = Arr::get($configs, 'api-id');
        $this->proPlan = Arr::get($configs, 'pro-plan', false);
    }

    /**
     * Get the API ID.
     *
     * @return string
     *
     * @throws \Arcanedev\Currencies\Exceptions\ApiException
     */
    private function getAppId()
    {
        if ( ! $this->apiId) {
            throw new ApiException('OpenExchangeRates.org requires an app key.');
        }

        return $this->apiId;
    }

    /* ------------------------------------------------------------------------------------------------
     |  Main Functions
     | ------------------------------------------------------------------------------------------------
     */
    /**
     * Make an API request.
     *
     * @param  string  $from
     * @param  array   $to
     *
     * @return array
     *
     * @throws \Arcanedev\Currencies\Exceptions\ApiException
     */
    protected function request($from, array $to)
    {
        $response = $this->client->get('/latest.json', [
            'app_id'  => $this->getAppId(),
            'base'    => $from,
            'symbols' => $this->proPlan ? implode(',', $to) : null,
        ]);

        $data = json_decode($response, true);

        return $data['rates'];
    }
}<commit_msg>Fix: Cache the results by different services<commit_after><?php namespace Arcanedev\Currencies\Services;

use Arcanedev\Currencies\Exceptions\ApiException;
use Illuminate\Support\Arr;

/**
 * Class     OpenExchangeRatesService
 *
 * @package  Arcanedev\Currencies\Services
 * @author   ARCANEDEV <<EMAIL>>
 */
class OpenExchangeRatesService extends AbstractService
{
    /* ------------------------------------------------------------------------------------------------
     |  Properties
     | ------------------------------------------------------------------------------------------------
     */
    /**
     * The base URL.
     *
     * @var string
     */
    protected $baseUrl = 'http://openexchangerates.org/api';

    /**
     * The API ID.
     *
     * @var string
     */
    protected $apiId;

    /**
     * The Pro Plan.
     *
     * @var bool
     */
    protected $proPlan = false;

    /* ------------------------------------------------------------------------------------------------
     |  Getters & Setters
     | ------------------------------------------------------------------------------------------------
     */
    /**
     * Set the configs.
     *
     * @param  array  $configs
     */
    protected function setProviderConfigs(array $configs)
    {
        $this->apiId   = Arr::get($configs, 'api-id');
        $this->proPlan = Arr::get($configs, 'pro-plan', false);
    }

    /**
     * Get the API ID.
     *
     * @return string
     *
     * @throws \Arcanedev\Currencies\Exceptions\ApiException
     */
    private function getAppId()
    {
        if ( ! $this->apiId) {
            throw new ApiException('OpenExchangeRates.org requires an app key.');
        }

        return $this->apiId;
    }

    /**
     * Get cache key.
     *
     * @return string
     */
    protected function getCacheKey()
    {
        return parent::getCacheKey() . '.openexchangerates';
    }

    /* ------------------------------------------------------------------------------------------------
     |  Main Functions
     | ------------------------------------------------------------------------------------------------
     */
    /**
     * Make an API request.
     *
     * @param  string  $from
     * @param  array   $to
     *
     * @return array
     *
     * @throws \Arcanedev\Currencies\Exceptions\ApiException
     */
    protected function request($from, array $to)
    {
        $response = $this->client->get('/latest.json', [
            'app_id'  => $this->getAppId(),
            'base'    => $from,
            'symbols' => $this->proPlan ? implode(',', $to) : null,
        ]);

        $data = json_decode($response, true);

        return $data['rates'];
    }
}
{'fraction_non_alphanumeric': 0.3303417987397365, 'fraction_numerical': 0.0, 'mean_word_length': 0.9795918367346939, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, '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': '964673', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1323, 'n_words': 257}