/** * @REQUIRED: php artisan lml-user:add test@test.com test1234 1 on local or staging env. * @return [type] [description] */ public function testValidCredentials() { TrustedSearch::setApiEnvironment('local'); TrustedSearch::setApiVersion('1'); $username = $this->getTestCredentials('email'); $password = $this->getTestCredentials('password'); try { $resource = TrustedSearch_Token::get($username, $password); $data = $resource->getData(); $this->assertTrue(!empty($data['token']), 'Token field should exist'); } catch (TrustedSearch_AuthenticationError $e) { echo $e->getMessage(); } }
public function testSimulateFulfillment() { TrustedSearch::setApiPublicKey($this->getTestCredentials('public_key')); TrustedSearch::setApiPrivateKey($this->getTestCredentials('private_key')); TrustedSearch::setApiEnvironment('local'); TrustedSearch::setApiVersion('1'); try { $uuid = '45c907bc-6d2f-5f62-9610-5395858d41a0'; //Take from response above. $response = TrustedSearch_DirectoryListing::simulate($uuid); echo json_encode($response->getData()); } catch (TrustedSearch_AuthenticationError $e) { echo $e->getMessage(); $this->assertEquals(401, $e->getHttpStatus()); } }
function authorizeFromEnv() { $apiPublicKey = getenv('TRUSTEDSEARCH_API_PUBLIC_KEY'); $apiPrivateKey = getenv('TRUSTEDSEARCH_API_PRIVATE_KEY'); $apiEnvironemnt = getenv('TRUSTEDSEARCH_API_ENVIRONMENT'); if (!$apiPublicKey) { $apiPublicKey = "d7a6454ef686dfad24e08d773bc273eb"; } if (!$apiPrivateKey) { $apiPrivateKey = "7lOx6Swg9e0yTjQz5laIfJQ9"; } if (!$apiEnvironemnt) { $apiEnvironemnt = "sandbox"; } TrustedSearch::setApiCredentials($apiPublicKey, $apiPrivateKey); TrustedSearch::setApiEnvironment($apiEnvironemnt); }
public function testGetPublisherHours() { TrustedSearch::setApiPublicKey($this->getTestCredentials('public_key')); TrustedSearch::setApiPrivateKey($this->getTestCredentials('private_key')); TrustedSearch::setApiEnvironment('local'); TrustedSearch::setApiVersion('2'); try { $resource = TrustedSearch_PublisherHours::get('yahoolocal', 'MNNONENONEH'); $data = $resource->getData(); // var_dump(($data)); $this->assertEquals($data['status'], 'success'); } catch (TrustedSearch_Error $e) { var_dump($e); echo $e->getMessage(); $this->assertTrue(false, "should not get here"); $this->assertEquals(401, $e->getCode()); } }
public function testAddLocalBusinessFailNoExternalID() { $data = $this->getTestData(); unset($data[0]['externalId']); TrustedSearch::setApiPublicKey($this->getTestCredentials('public_key')); TrustedSearch::setApiPrivateKey($this->getTestCredentials('private_key')); TrustedSearch::setApiEnvironment('local'); TrustedSearch::setApiVersion('1'); try { $resource = TrustedSearch_LocalBusiness::create($data); $data = $resource->getData(); $this->assertEquals(count($data), 2, 'There should be two results.'); $this->assertTrue(!empty($data[0]['externalId']), 'There should be an external id present.'); $this->assertTrue(!empty($data[0]['uuid']), "There should be uuid returned."); $this->assertTrue(!empty($data[0]['status']), "There should be status returned."); $this->assertTrue(!empty($data[1]['externalId']), 'There should be an external id present.'); $this->assertTrue(!empty($data[1]['uuid']), "There should be uuid returned."); $this->assertTrue(!empty($data[1]['status']), "There should be status returned."); } catch (TrustedSearch_InvalidRequestError $e) { //echo $e->getMessage(); $this->assertEquals(400, $e->getCode()); } }
public function getPagination() { $data = $this->getResponse(); if (TrustedSearch::getApiVersion() == 2) { return $data['body']['pagination']; } }
public static function setVerifySslCerts($verify) { self::$verifySslCerts = $verify; }
public function testGetListingByLocationAndName() { TrustedSearch::setApiPublicKey($this->getTestCredentials('public_key')); TrustedSearch::setApiPrivateKey($this->getTestCredentials('private_key')); TrustedSearch::setApiEnvironment('local'); TrustedSearch::setApiVersion('2'); try { //Note: You will need to update the id while testing if you clear your local or dev db. $resource = TrustedSearch_Listing::getByLocationAndProductName('376a15ee-d45c-5890-ac08-aafe3cbc864a', 'yahoolocal'); $record = $resource->getData(); if (!empty($record)) { $this->assertTrue(array_key_exists('id', $record)); $this->assertTrue(array_key_exists('location_id', $record)); $this->assertTrue(array_key_exists('product_id', $record)); $this->assertTrue(array_key_exists('listing_status_id', $record)); $this->assertTrue(array_key_exists('username', $record)); $this->assertTrue(array_key_exists('password', $record)); $this->assertTrue(array_key_exists('fulfillment_status_id', $record)); $this->assertTrue(array_key_exists('url', $record)); $this->assertTrue(array_key_exists('duplicate_url', $record)); $this->assertTrue(array_key_exists('verification', $record)); $this->assertTrue(array_key_exists('deleted_at', $record)); $this->assertTrue(array_key_exists('created_at', $record)); $this->assertTrue(array_key_exists('updated_at', $record)); } else { $this->assertTrue(false, 'Data should come back from getByLocationAndProductName'); } } catch (TrustedSearch_AuthenticationError $e) { echo $e->getMessage(); $this->assertEquals(401, $e->getCode()); } }
public static function apiUrl($url = '') { $apiBase = TrustedSearch::getApiBaseUrl(TrustedSearch::$apiEnvironemnt); return "{$apiBase}{$url}"; }