Skip to content

Commit

Permalink
Fixed methods and added Rust and NAVI
Browse files Browse the repository at this point in the history
  • Loading branch information
Allyans3 committed Feb 18, 2021
1 parent 77cec89 commit aa5c794
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 40 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ Games ID's
| Game | Game ID |
| --------------- | ------- |
| CS:GO | csgo |
| NAVI | navi |
| DotA2 | dota2 |
| Team Fortress 2 | tf2 |
| Rust | rust |
| Life Beyond | lb |
| DMarket | dmarket |
| Misc | misc |
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ class Config
{
const GAME = [
'csgo' => 'a8db',
'navi' => 'navi',
'dota2' => '9a92',
'tf2' => 'tf2',
'rust' => 'rust',
'lb' => 'life_beyond',
'dmarket' => 'ab99',
'misc' => '1a42'
Expand Down
8 changes: 4 additions & 4 deletions src/Requests/GamesList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class GamesList extends Request implements RequestInterface
{
const URL = 'https://trading.dmarket.com/exchange/v1/games';
const URL = 'https://api.dmarket.com/exchange/v1/games';

private string $method = 'GET';
private $method = 'GET';

public function getUrl()
public function getUrl(): string
{
return self::URL;
}
Expand All @@ -21,7 +21,7 @@ public function call($proxy = [])
return $this->steamHttpRequest($proxy);
}

public function getRequestMethod()
public function getRequestMethod(): string
{
return $this->method;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Requests/LastSales.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@

class LastSales extends Request implements RequestInterface
{
const URL = 'https://trading.dmarket.com/marketplace-api/v1/last-sales?GameID=%s&Title=%s&Currency=%s';
const URL = 'https://api.dmarket.com/marketplace-api/v1/last-sales?Title=%s&GameID=%s&Currency=%s';

private string $gameId;
private string $title = '';
private string $currency = 'USD';
private string $method = 'GET';
private $gameId;
private $title = '';
private $currency = 'USD';
private $method = 'GET';

public function __construct($gameId, $options = [])
{
$this->gameId = $gameId;
$this->setOptions($options);
}

public function getUrl()
public function getUrl(): string
{
return sprintf(self::URL, $this->gameId, $this->title, $this->currency);
return sprintf(self::URL, $this->title,$this->gameId, $this->currency);
}

public function call($options = [], $proxy = [])
{
return $this->setOptions($options)->steamHttpRequest($proxy);
}

public function getRequestMethod()
public function getRequestMethod(): string
{
return $this->method;
}

private function setOptions($options)
private function setOptions($options): LastSales
{
if (isset($options['title'])) {
$this->title = rawurlencode($options['title']);
Expand Down
36 changes: 18 additions & 18 deletions src/Requests/MarketItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@

class MarketItems extends Request implements RequestInterface
{
const URL = 'https://trading.dmarket.com/exchange/v1/market/items?gameId=%s&title=%s&currency=%s&orderBy=%s&orderDir=%s&priceFrom=%s&priceTo=%s&treeFilters=%s&types=%s&cursor=%s&limit=%s&platform=%s&isLoggedIn=%s';
const URL = 'https://api.dmarket.com/exchange/v1/market/items?gameId=%s&title=%s&currency=%s&orderBy=%s&orderDir=%s&priceFrom=%s&priceTo=%s&treeFilters=%s&types=%s&cursor=%s&limit=%s&platform=%s&isLoggedIn=%s';

private string $gameId;
private string $title = '';
private string $currency = 'USD';
private string $orderBy = 'best_deals';
private string $orderDir = 'desc';
private int $priceFrom = 0;
private int $priceTo = 0;
private string $treeFilters = '';
private string $types = 'dmarket';
private string $cursor = '';
private int $limit = 100;
private string $platform = 'browser';
private bool $isLoggedIn = true;
private $gameId;
private $title = '';
private $currency = 'USD';
private $orderBy = 'best_deals';
private $orderDir = 'desc';
private $priceFrom = 0;
private $priceTo = 0;
private $treeFilters = '';
private $types = 'dmarket';
private $cursor = '';
private $limit = 100;
private $platform = 'browser';
private $isLoggedIn = true;

private string $method = 'GET';
private $method = 'GET';

public function __construct($gameId, $options = [])
{
$this->gameId = $gameId;
$this->setOptions($options);
}

public function getUrl()
public function getUrl(): string
{
return sprintf(self::URL, $this->gameId, $this->title, $this->currency, $this->orderBy, $this->orderDir,
$this->priceFrom, $this->priceTo, $this->treeFilters, $this->types, $this->cursor, $this->limit,
Expand All @@ -43,12 +43,12 @@ public function call($options = [], $proxy = [])
return $this->setOptions($options)->steamHttpRequest($proxy);
}

public function getRequestMethod()
public function getRequestMethod(): string
{
return $this->method;
}

private function setOptions($options)
private function setOptions($options): MarketItems
{
$this->orderBy = $options['orderBy'] ?? $this->orderBy;
$this->orderDir = $options['orderDir'] ?? $this->orderDir;
Expand Down
18 changes: 9 additions & 9 deletions src/Requests/SalesHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

class SalesHistory extends Request implements RequestInterface
{
const URL = 'https://trading.dmarket.com/marketplace-api/v1/sales-history?GameID=%s&Title=%s&Currency=%s&Period=%s';
const URL = 'https://api.dmarket.com/marketplace-api/v1/sales-history?GameID=%s&Title=%s&Currency=%s&Period=%s';

private string $gameId;
private string $title = '';
private string $currency = 'USD';
private string $period = '7D';
private string $method = 'GET';
private $gameId;
private $title = '';
private $currency = 'USD';
private $period = '7D';
private $method = 'GET';

public function __construct($gameId, $options = [])
{
$this->gameId = $gameId;
$this->setOptions($options);
}

public function getUrl()
public function getUrl(): string
{
return sprintf(self::URL, $this->gameId, $this->title, $this->currency, $this->period);
}
Expand All @@ -32,12 +32,12 @@ public function call($options = [], $proxy = [])
return $this->setOptions($options)->steamHttpRequest($proxy);
}

public function getRequestMethod()
public function getRequestMethod(): string
{
return $this->method;
}

private function setOptions($options)
private function setOptions($options): SalesHistory
{
if (isset($options['title'])) {
$this->title = rawurlencode($options['title']);
Expand Down

0 comments on commit aa5c794

Please sign in to comment.