<commit_before><?php

namespace SmartyStreets\PhpSdk\Tests\IntegrationTests;

require_once(dirname(dirname(dirname(__FILE__))) . '/src/ClientBuilder.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_ZIPCode/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_ZIPCode/Result.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_Street/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_Extract/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_Autocomplete/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/International_Street/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/StaticCredentials.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/SharedCredentials.php');
use SmartyStreets\PhpSdk\StaticCredentials;
use SmartyStreets\PhpSdk\US_ZIPCode\Lookup as USZIPCodeLookup;
use SmartyStreets\PhpSdk\US_Street\Lookup as USStreetLookup;
use SmartyStreets\PhpSdk\US_Extract\Lookup as USExtractLookup;
use SmartyStreets\PhpSdk\US_Autocomplete\Lookup as USAutocompleteLookup;
use SmartyStreets\PhpSdk\International_Street\Lookup as InternationStreetLookup;
use SmartyStreets\PhpSdk\ClientBuilder;

$apiTest = new IntegrationTests();
$apiTest->runAllApiIntegrationTests();

class IntegrationTests {

    public function runAllApiIntegrationTests() {
        $credentials = new StaticCredentials(getenv('SMARTY_AUTH_ID'), getenv('SMARTY_AUTH_TOKEN'));

        print("\n");
        $this->testInternationalStreetRequestReturnsWithCorrectNumberOfResults($credentials);
//        $this->testUSAutocompleteRequestReturnsWithCorrectNumberOfResults($credentials);
//        $this->testUSExtractRequestReturnsWithCorrectNumberOfResults($credentials);
//        $this->testUSStreetRequestReturnsWithCorrectNumberOfResults($credentials);
//        $this->testUSZIPCodeRequestReturnsWithCorrectNumberOfResults($credentials);
//        $this->testGetsResultsViaProxy($credentials);
    }

    public function testInternationalStreetRequestReturnsWithCorrectNumberOfResults(StaticCredentials $credentials) {
        $client = (new ClientBuilder($credentials))->retryAtMost(0)->buildInternationalStreetApiClient();
        $lookup = new InternationStreetLookup();
        $lookup->setFreeformInput("<NAME> 121 Casa Verde, Sao Paulo", "Brazil");

        try {
            $client->sendLookup($lookup);
        }
        catch (\Exception $ex) {}

        $candidates = count($lookup->getResult());
        $this->assertResults("International_Street", $candidates, 1);
    }

    public function testUSAutocompleteRequestReturnsWithCorrectNumberOfResults(StaticCredentials $credentials) {
        $client = (new ClientBuilder($credentials))->retryAtMost(0)->buildUSAutocompleteApiClient();
        $lookup = new USAutocompleteLookup("4770 Lincoln Ave O");
        $lookup->addStateFilter("IL");

        try {<commit_msg>Uncommented integration tests<commit_after><?php

namespace SmartyStreets\PhpSdk\Tests\IntegrationTests;

require_once(dirname(dirname(dirname(__FILE__))) . '/src/ClientBuilder.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_ZIPCode/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_ZIPCode/Result.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_Street/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_Extract/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/US_Autocomplete/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/International_Street/Lookup.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/StaticCredentials.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/src/SharedCredentials.php');
use SmartyStreets\PhpSdk\StaticCredentials;
use SmartyStreets\PhpSdk\US_ZIPCode\Lookup as USZIPCodeLookup;
use SmartyStreets\PhpSdk\US_Street\Lookup as USStreetLookup;
use SmartyStreets\PhpSdk\US_Extract\Lookup as USExtractLookup;
use SmartyStreets\PhpSdk\US_Autocomplete\Lookup as USAutocompleteLookup;
use SmartyStreets\PhpSdk\International_Street\Lookup as InternationStreetLookup;
use SmartyStreets\PhpSdk\ClientBuilder;

$apiTest = new IntegrationTests();
$apiTest->runAllApiIntegrationTests();

class IntegrationTests {

    public function runAllApiIntegrationTests() {
        $credentials = new StaticCredentials(getenv('SMARTY_AUTH_ID'), getenv('SMARTY_AUTH_TOKEN'));

        print("\n");
        $this->testInternationalStreetRequestReturnsWithCorrectNumberOfResults($credentials);
        $this->testUSAutocompleteRequestReturnsWithCorrectNumberOfResults($credentials);
        $this->testUSExtractRequestReturnsWithCorrectNumberOfResults($credentials);
        $this->testUSStreetRequestReturnsWithCorrectNumberOfResults($credentials);
        $this->testUSZIPCodeRequestReturnsWithCorrectNumberOfResults($credentials);
        $this->testGetsResultsViaProxy($credentials);
    }

    public function testInternationalStreetRequestReturnsWithCorrectNumberOfResults(StaticCredentials $credentials) {
        $client = (new ClientBuilder($credentials))->retryAtMost(0)->buildInternationalStreetApiClient();
        $lookup = new InternationStreetLookup();
        $lookup->setFreeformInput("R<NAME> 121 Casa Verde, Sao Paulo", "Brazil");

        try {
            $client->sendLookup($lookup);
        }
        catch (\Exception $ex) {}

        $candidates = count($lookup->getResult());
        $this->assertResults("International_Street", $candidates, 1);
    }

    public function testUSAutocompleteRequestReturnsWithCorrectNumberOfResults(StaticCredentials $credentials) {
        $client = (new ClientBuilder($credentials))->retryAtMost(0)->buildUSAutocompleteApiClient();
        $lookup = new USAutocompleteLookup("4770 Lincoln Ave O");
        $lookup->addStateFilter("IL");

        try {
{'fraction_non_alphanumeric': 0.12518980934705584, 'fraction_numerical': 0.0033743883921039312, 'mean_word_length': 5.998819362455726, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, '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': '4430636', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1709, 'n_words': 216}