Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/Steam/Command/RemoteStorage/GetCollectionDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php


namespace Steam\Command\RemoteStorage;


class GetCollectionDetails extends RemoteStorage {
protected $collectionIds = [];

/**
* GetPublishedFileDetails constructor.
* @param ?array $collectionIds Array of File IDs to get details for.
*/
public function __construct($collectionIds = null){
if (!is_null($collectionIds)){
$this->collectionIds = $collectionIds;
}
}

/**
* Add a new collection ID to the query list.
* @param integer $collectionId
*/
public function addCollectionID($collectionId){
$this->collectionIds[] = $collectionId;
}

/**
* @inheritDoc
*/
public function getMethod(){
return 'GetCollectionDetails';
}

/**
* @inheritDoc
*/
public function getRequestMethod(){
return 'POST';
}

/**
* @inheritDoc
*/
public function getParams(){
$params = [
'collectioncount' => count($this->collectionIds),
];
foreach ($this->collectionIds as $idx => $collection_id){
$params["publishedfileids[{$idx}]"] = $collection_id;
}
return $params;
}
}
54 changes: 54 additions & 0 deletions src/Steam/Command/RemoteStorage/GetPublishedFileDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php


namespace Steam\Command\RemoteStorage;


class GetPublishedFileDetails extends RemoteStorage {
protected $fileIds = [];

/**
* GetPublishedFileDetails constructor.
* @param ?array $fileIds Array of File IDs to get details for.
*/
public function __construct($fileIds = null){
if (!is_null($fileIds)){
$this->fileIds = $fileIds;
}
}

/**
* Add a new file ID to the query list.
* @param integer $fileId
*/
public function addFileID($fileId){
$this->fileIds[] = $fileId;
}

/**
* @inheritDoc
*/
public function getMethod(){
return 'GetPublishedFileDetails';
}

/**
* @inheritDoc
*/
public function getRequestMethod(){
return 'POST';
}

/**
* @inheritDoc
*/
public function getParams(){
$params = [
'itemcount' => count($this->fileIds),
];
foreach ($this->fileIds as $idx => $file_id){
$params["publishedfileids[{$idx}]"] = $file_id;
}
return $params;
}
}
22 changes: 22 additions & 0 deletions src/Steam/Command/RemoteStorage/RemoteStorage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php


namespace Steam\Command\RemoteStorage;

use Steam\Command\CommandInterface;

abstract class RemoteStorage implements CommandInterface {
/**
* @inheritDoc
*/
public function getInterface(){
return 'ISteamRemoteStorage';
}

/**
* @inheritDoc
*/
public function getVersion(){
return 'v1';
}
}
50 changes: 50 additions & 0 deletions tests/src/Steam/Command/RemoteStorage/GetCollectionDetailsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Steam\Command\RemoteStorage;

use Steam\Command\CommandInterface;

class GetCollectionDetailsTest extends \PHPUnit_Framework_TestCase
{
/**
* @var GetCollectionDetails
*/
protected $instance;

public function setUp()
{
$this->instance = new GetCollectionDetails();
}

public function testImplementsInterface()
{
$this->assertTrue($this->instance instanceof CommandInterface);
}

public function testValues()
{
$this->assertEquals('ISteamRemoteStorage', $this->instance->getInterface());
$this->assertEquals('GetCollectionDetails', $this->instance->getMethod());
$this->assertEquals('v1', $this->instance->getVersion());
$this->assertEquals('POST', $this->instance->getRequestMethod());
$this->assertEquals([
'collectioncount' => 0
], $this->instance->getParams());
}

public function testAddingCollectionID()
{
$this->instance->addCollectionID(1234);
$this->assertParams([
'collectioncount' => 1,
'publishedfileids[0]' => 1234
]);
}

public function assertParams($params)
{
$this->assertEquals(array_merge([
'collectioncount' => 0
], $params), $this->instance->getParams());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Steam\Command\RemoteStorage;

use Steam\Command\CommandInterface;

class GetPublishedFileDetailsTest extends \PHPUnit_Framework_TestCase
{
/**
* @var GetPublishedFileDetails
*/
protected $instance;

public function setUp()
{
$this->instance = new GetPublishedFileDetails();
}

public function testImplementsInterface()
{
$this->assertTrue($this->instance instanceof CommandInterface);
}

public function testValues()
{
$this->assertEquals('ISteamRemoteStorage', $this->instance->getInterface());
$this->assertEquals('GetPublishedFileDetails', $this->instance->getMethod());
$this->assertEquals('v1', $this->instance->getVersion());
$this->assertEquals('POST', $this->instance->getRequestMethod());
$this->assertEquals([
'itemcount' => 0
], $this->instance->getParams());
}

public function testAddingFileID()
{
$this->instance->addFileID(1234);
$this->assertParams([
'itemcount' => 1,
'publishedfileids[0]' => 1234
]);
}

public function assertParams($params)
{
$this->assertEquals(array_merge([
'itemcount' => 0
], $params), $this->instance->getParams());
}
}