forked from syntaxerrors/Steam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request syntaxerrors#74 from jastend/master
Language attribute for client requests
- Loading branch information
Showing
10 changed files
with
217 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Array | ||
( | ||
[0] => stdClass Object | ||
( | ||
[id] => 76710 | ||
[name] => Just Cause 3 XL | ||
[page_image] => https: //steamcdn-a.akamaihd.net/steam/subs/76710/header.jpg?t=1449600260 | ||
[header] => https: //steamcdn-a.akamaihd.net/steam/subs/76710/header_ratio.jpg?t=1449600260 | ||
[small_logo] => https: //steamcdn-a.akamaihd.net/steam/subs/76710/capsule_231x87.jpg?t=1449600260 | ||
[apps] => Array( | ||
[0] => stdClass Object( | ||
[id] => 225540 | ||
[name] => Just Cause™ 3 | ||
) | ||
|
||
[1] => stdClass Object( | ||
[id] => 401850 | ||
[name] => Just Cause™ 3 DLC: Air, Land & Sea Expansion Pass | ||
) | ||
|
||
) | ||
|
||
[page_content] => none[price] => stdClass Object( | ||
[currency] => USD | ||
[initial] => 4499 | ||
[final] => 4499 | ||
[discount_percent] => 0 | ||
[individual] => 4498 | ||
) | ||
|
||
[platforms] => stdClass Object( | ||
[windows] => 1 | ||
[mac] => | ||
[linux] => | ||
) | ||
|
||
[release] => stdClass Object( | ||
[coming_soon] => | ||
[date] => | ||
) | ||
|
||
[controller] => stdClass Object( | ||
[full_gamepad] => 1 | ||
) | ||
|
||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Syntax\SteamApi\Containers; | ||
|
||
class Package extends BaseContainer | ||
{ | ||
public $id; | ||
public $name; | ||
public $page_image; | ||
public $header; | ||
public $small_logo; | ||
public $apps; | ||
public $page_content; | ||
public $price; | ||
public $platforms; | ||
public $release; | ||
|
||
public function __construct($package, $id) | ||
{ | ||
$this->id = (int) $id; | ||
$this->name = $package->name; | ||
$this->apps = $package->apps; | ||
$this->page_content = $this->checkIssetField($package, 'page_content', 'none'); | ||
$this->header = $this->checkIssetField($package, 'header_image', 'none'); | ||
$this->small_logo = $this->checkIssetField($package, 'small_logo', 'none'); | ||
$this->page_image = $this->checkIssetField($package, 'page_image', 'none'); | ||
$this->price = $this->formatPriceObject($package, 'price'); | ||
$this->platforms = $package->platforms; | ||
$this->controller = $package->controller; | ||
$this->release = $package->release_date; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Syntax\SteamApi\Steam; | ||
|
||
use Syntax\SteamApi\Client; | ||
use NukaCode\Database\Collection; | ||
use Syntax\SteamApi\Containers\Package as PackageContainer; | ||
|
||
class Package extends Client | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->url = 'http://store.steampowered.com/'; | ||
$this->interface = 'api'; | ||
} | ||
|
||
public function packageDetails($packIds, $cc = null, $language = null) | ||
{ | ||
// Set up the api details | ||
$this->method = 'packagedetails'; | ||
$this->version = null; | ||
// Set up the arguments | ||
$arguments = [ | ||
'packageids' => $packIds, | ||
'cc' => $cc, | ||
'l' => $language, | ||
]; | ||
// Get the client | ||
$client = $this->setUpClient($arguments); | ||
$packs = $this->convertToObjects($client, $packIds); | ||
|
||
return $packs; | ||
} | ||
|
||
protected function convertToObjects($package, $packIds) | ||
{ | ||
$convertedPacks = $this->convertPacks($package, $packIds); | ||
$package = $this->sortObjects($convertedPacks); | ||
|
||
return $package; | ||
} | ||
|
||
/** | ||
* @param $packs | ||
* | ||
* @return Collection | ||
*/ | ||
protected function convertPacks($packages, $packIds) | ||
{ | ||
$convertedPacks = new Collection(); | ||
foreach ($packages as $package) { | ||
if (isset($package->data)) { | ||
$convertedPacks->add(new PackageContainer($package->data, $packIds)); | ||
} | ||
} | ||
|
||
return $convertedPacks; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
* Once you get your key, add it here. | ||
*/ | ||
'steamApiKey' => env('STEAM_API_KEY'), | ||
|
||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
require_once 'BaseTester.php'; | ||
|
||
/** @group Package */ | ||
class PackageTest extends BaseTester | ||
{ | ||
/** @test */ | ||
public function it_gets_details_for_an_package_by_id() | ||
{ | ||
$details = $this->steamClient->package()->packageDetails($this->packageId); | ||
|
||
$this->assertCount(1, $details); | ||
|
||
$detail = $details->first(); | ||
|
||
$this->checkPackageProperties($detail); | ||
$this->checkPackageClasses($detail); | ||
} | ||
|
||
/** | ||
* @param $detail | ||
*/ | ||
private function checkPackageClasses($detail) | ||
{ | ||
$this->assertInstanceOf('Syntax\SteamApi\Containers\Package', $detail); | ||
} | ||
} |