Skip to content

Commit

Permalink
Cleaned up examples.
Browse files Browse the repository at this point in the history
Cleaned up readme.md slightly. (Still needs more examples and directions)
Updated get_response to be get_api_response to match set_api_response naming convention
Updated references to get_response to get_api_response when utilized.
Minor code formatting cleanup
  • Loading branch information
aaronware committed Aug 19, 2015
1 parent 15151ee commit 774dc07
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $browser_list = $api->get_browsers();

#### Generate a screenshot
```php
use Linchpin\Browserstack\Screenshots\Api;
use Linchpin\Browserstack\Screenshots\ScreenshotsAPI;
use Linchpin\Browserstack\Screenshots\Request;
$screenshots_api = new ScreenshotsAPI( 'account', 'password' );
$request = Request::build_request( 'http://www.example.org', 'Windows', '8.1', 'ie', '11.0' );
Expand Down
14 changes: 7 additions & 7 deletions examples/advancedRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
*
*/

use Alexschwarz89\Browserstack\Screenshots\Api;
use Alexschwarz89\Browserstack\Screenshots\Request;
use Linchpin\Browserstack\Screenshots\ScreenshotsAPI;
use Linchpin\Browserstack\Screenshots\Request;

const BROWSERSTACK_ACCOUNT = '';
const BROWSERSTACK_PASSWORD = '';

$api = new Api(BROWSERSTACK_ACCOUNT, BROWSERSTACK_PASSWORD);
$api = new ScreenshotsAPI( BROWSERSTACK_ACCOUNT, BROWSERSTACK_PASSWORD );

$request = new Request();
$request->url = 'http://www.example.org';
Expand All @@ -23,12 +23,12 @@
$request->wait_time = 10;
$request->orientation = 'landscape';

$request->addBrowser('ios', '8.0', 'Mobile Safari', NULL, 'iPhone 6');
$request->addBrowser('ios', '8.0', 'Mobile Safari', NULL, 'iPhone 6 Plus');
$request->addBrowser('Windows', 'XP', 'ie', '7.0');
$request->add_browser( 'ios', '8.0', 'Mobile Safari', NULL, 'iPhone 6' );
$request->add_browser( 'ios', '8.0', 'Mobile Safari', NULL, 'iPhone 6 Plus' );
$request->add_browser( 'Windows', 'XP', 'ie', '7.0' );

// Send the request
$api->sendRequest( $request );
$api->send_request( $request );

// Output
var_dump($request);
18 changes: 9 additions & 9 deletions examples/generateScreenshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
const BROWSERSTACK_ACCOUNT = '';
const BROWSERSTACK_PASSWORD = '';

$api = new Api(BROWSERSTACK_ACCOUNT, BROWSERSTACK_PASSWORD);
$api = new ScreenshotsAPI( BROWSERSTACK_ACCOUNT, BROWSERSTACK_PASSWORD );

// Short-hand Notation
$request = Request::buildRequest('http://www.example.org', 'Windows', '8.1', 'ie', '11.0');
$request = Request::build_request( 'http://www.example.org', 'Windows', '8.1', 'ie', '11.0' );

// Send the request
$response = $api->sendRequest( $request );
$response = $api->send_request( $request );

// Query information about the newly created request
if ($response->isSuccessful) {
if ( $response->is_successful ) {
// Wait until the request is finished
do {
// Query Job Status
$status = $api->getJobStatus($response->jobId);
if ($status->isFinished()) {
$status = $api->get_job_status( $response->job_ID );
if ( $status->is_finished() ) {
// When it's finished, print out the image URLs
foreach ($status->finishedScreenshots as $screenshot) {
print $screenshot->image_url ."\n";
foreach ( $status->finished_screenshots as $screenshot ) {
print $screenshot->image_url . "\n";
}
break;
}
Expand All @@ -43,5 +43,5 @@
} while (true);

} else {
print 'Job creation failed. Reason: ' . $response->errorMessage . "\n";
print 'Job creation failed. Reason: ' . $response->error_message . "\n";
}
6 changes: 3 additions & 3 deletions examples/getAvailableBrowsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*
*/

use Alexschwarz89\Browserstack\Screenshots\Api;
use Linchpin\Browserstack\Screenshots\ScreenshotsAPI;

$api = new Api('', '');
$browserList = $api->getBrowsers();
$api = new ScreenshotsAPI( '', '' );
$browserList = $api->get_browsers();

var_dump( $browserList );
2 changes: 1 addition & 1 deletion src/Screenshots/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function set_api_response( $api_response ) {
*
* @return Array
*/
public function get_response() {
public function get_api_response() {
return $this->_response;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Screenshots/Response/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function set_api_response( $api_response ) {
/**
* @return mixed
*/
public function get_response() {
public function get_api_response() {
return $this->response;
}
}
6 changes: 3 additions & 3 deletions src/Screenshots/Response/ScreenshotsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*/
class ScreenshotsResponse extends Base {

const ERROR_LIMIT_REACHED = 'Parallel limit reached';
const ERROR_INVALID_REQUEST = 'Invalid Request';
const ERROR_VALIDATION_FAILED = 'Validation failed';
const ERROR_LIMIT_REACHED = 'Parallel limit reached';
const ERROR_INVALID_REQUEST = 'Invalid Request';
const ERROR_VALIDATION_FAILED = 'Validation failed';
const ERROR_AUTHENTICATION_FAILED = 'Authentication failed. Please check your login details and retry.';

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Screenshots/ScreenshotsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function get_browsers() {
$res = new Response();
$res->set_api_response( $this->_request( 'browsers.json' ) );

return $res->get_response();
return $res->get_api_response();
}

/**
Expand Down Expand Up @@ -226,7 +226,7 @@ public function is_browserstack_accessible() {
case 2 :
$response->set_api_response( [ 'success' => [ 'Service is available' ] ] );

return $response->get_response();
return $response->get_api_response();
case 4 :
if ( 404 === $http_code ) {
$message = 'API Endpoint not found';
Expand All @@ -246,6 +246,6 @@ public function is_browserstack_accessible() {

$response->set_api_response( [ 'errors' => [ $message ] ] );

return $response->get_response();
return $response->get_api_response();
}
}

0 comments on commit 774dc07

Please sign in to comment.