<commit_before><?php
use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Lookup;
use ApaiIO\Request\GuzzleRequest;
use GuzzleHttp\Client;

class Kiku_Amazon {
    protected $config = null;
    protected $client = null;
    protected $request = null;

    public function __construct($accessKeyId, $secretKey, $associateId) {
        $this->client = new Client();
        $this->request = new GuzzleRequest($this->client);
        $this->config = new GenericConfiguration();
        $this->config->setCountry($this->get_country())
                     ->setAccessKey($accessKeyId)
                     ->setSecretKey($secretKey)
                     ->setAssociateTag($associateId)
                     ->setRequest($this->request);
    }

    public function lookupASIN($asin) {
        if ( empty($asin) ) {
            return null;
        }

        $results = null;
        try {
            $apaiIO = new ApaiIO($this->config);
            $lookup = new Lookup();

            $lookup->setItemId($asin);
            $lookup->setResponseGroup(['ItemAttributes', 'Images']);
            $formattedResponse = $apaiIO->runOperation($lookup);
            $results = simplexml_load_string( $formattedResponse );

            return $results->Items->Item;
        } catch (Exception $e) {
            return null;
        }

    }

    private function get_country() {
        $lang = get_locale();
        $country = '';

        switch ($lang) {
            case 'en_GB':
            $country = 'co.uk';
            break;
            case 'ja':
            $country = 'co.jp';
            break;
            default:  // en_US
            $country = 'com';
            break;
        }

        return $country;
    }
}<commit_msg>modify: can't load Amazon components<commit_after><?php
use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Lookup;
use ApaiIO\Request\GuzzleRequest;
use GuzzleHttp\Client;

class Kiku_Amazon {
    protected $config = null;
    protected $client = null;
    protected $request = null;

    public function __construct($accessKeyId, $secretKey, $associateId) {
        if ( empty($accessKeyId) && empty($secretKey) && empty($associateId) ) {
            return;
        }
        if ( class_exists('Client') && class_exists('GuzzleRequest') && class_exists('GenericConfiguration') ) {
            $this->client = new Client();
            $this->config = new GenericConfiguration();
            $this->config->setCountry($this->get_country())
                         ->setAccessKey($accessKeyId)
                         ->setSecretKey($secretKey)
                         ->setAssociateTag($associateId)
                         ->setRequest($this->request);
        } else {
            return;
        }
    }

    public function lookupASIN($asin) {
        if ( empty($this->config) || empty($asin) ) {
            return null;
        }

        try {
            if ( class_exists('ApaiIO') && class_exists('Lookup') ) {
                $apaiIO = new ApaiIO($this->config);
                $lookup = new Lookup();

                $lookup->setItemId($asin);
                $lookup->setResponseGroup(['ItemAttributes', 'Images']);
                $formattedResponse = $apaiIO->runOperation($lookup);

                $results = null;
                $results = simplexml_load_string( $formattedResponse );

                return $results->Items->Item;
            }
        } catch (Exception $e) {
            return null;
        }

        return null;
    }

    private function get_country() {
        $lang = get_locale();
        $country = '';

        switch ($lang) {
            case 'en_GB':
            $country = 'co.uk';
            break;
            case 'ja':
            $country = 'co.jp';
            break;
            default:  // en_US
            $country = 'com';
            break;
        }

        return $country;
    }
}
{'fraction_non_alphanumeric': 0.1273644388398487, 'fraction_numerical': 0.0, 'mean_word_length': 1.7351724137931035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2097063', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1061, 'n_words': 212}