diff --git a/src/DMarketAuthApi.php b/src/DMarketAuthApi.php index 07acdda..d586a3d 100644 --- a/src/DMarketAuthApi.php +++ b/src/DMarketAuthApi.php @@ -4,6 +4,7 @@ use DMarketAuthApi\Requests\AggregatedPrices; use DMarketAuthApi\Requests\BuyOffers; +use DMarketAuthApi\Requests\ClosedUserOffers; use DMarketAuthApi\Requests\ClosedUserTargets; use DMarketAuthApi\Requests\CreateUserOffers; use DMarketAuthApi\Requests\CreateUserTargets; @@ -36,6 +37,9 @@ public function __construct($publicKey, $secretKey) //Account + /** + * @throws \SodiumException + */ public function getUserProfile(array $proxy = []) { $class = new UserProfile(); @@ -43,6 +47,9 @@ public function getUserProfile(array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getUserBalance(array $proxy = []) { $class = new UserBalance(); @@ -53,6 +60,9 @@ public function getUserBalance(array $proxy = []) //Sell Items + /** + * @throws \SodiumException + */ public function depositAssets(array $postParams, array $proxy = []) { $class = new DepositAssets(); @@ -60,6 +70,9 @@ public function depositAssets(array $postParams, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getDepositStatus(string $depositId, array $proxy = []) { $class = new DepositStatus($depositId); @@ -67,6 +80,9 @@ public function getDepositStatus(string $depositId, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getUserOffers(array $queries = [], array $proxy = []) { $class = new UserOffers($queries); @@ -74,6 +90,19 @@ public function getUserOffers(array $queries = [], array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ + public function getClosedUserOffers(array $queries = [], array $proxy = []) + { + $class = new ClosedUserOffers($queries); + + return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); + } + + /** + * @throws \SodiumException + */ public function createUserOffers(array $postParams, array $proxy = []) { $class = new CreateUserOffers(); @@ -81,6 +110,9 @@ public function createUserOffers(array $postParams, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function editUserOffers(array $postParams, array $proxy = []) { $class = new EditUserOffers(); @@ -88,6 +120,9 @@ public function editUserOffers(array $postParams, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getMarketItems(array $queries, array $proxy = []) { $class = new MarketItems($queries); @@ -95,6 +130,9 @@ public function getMarketItems(array $queries, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function deleteOffers(array $postParams, array $proxy = []) { $class = new DeleteOffers(); @@ -105,6 +143,9 @@ public function deleteOffers(array $postParams, array $proxy = []) //Inventory/items + /** + * @throws \SodiumException + */ public function getUserInventory(array $queries = [], array $proxy = []) { $class = new UserInventory($queries); @@ -112,6 +153,9 @@ public function getUserInventory(array $queries = [], array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function syncUserInventory(array $postParams, array $proxy = []) { $class = new SyncUserInventory(); @@ -119,6 +163,9 @@ public function syncUserInventory(array $postParams, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function withdrawAssets(array $postParams, array $proxy = []) { $class = new WithdrawAssets(); @@ -126,6 +173,9 @@ public function withdrawAssets(array $postParams, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getUserItems(array $queries, array $proxy = []) { $class = new UserItems($queries); @@ -136,6 +186,9 @@ public function getUserItems(array $queries, array $proxy = []) //Buy items + /** + * @throws \SodiumException + */ public function getOffersByTitle(array $queries, array $proxy = []) { $class = new OffersByTitle($queries); @@ -143,6 +196,9 @@ public function getOffersByTitle(array $queries, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getAggregatedPrices(array $queries, array $proxy = []) { $class = new AggregatedPrices($queries); @@ -150,6 +206,9 @@ public function getAggregatedPrices(array $queries, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getUserTargets(array $queries = [], array $proxy = []) { $class = new UserTargets($queries); @@ -157,6 +216,9 @@ public function getUserTargets(array $queries = [], array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function getClosedUserTargets(array $queries = [], array $proxy = []) { $class = new ClosedUserTargets($queries); @@ -164,6 +226,9 @@ public function getClosedUserTargets(array $queries = [], array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function createUserTargets(array $postParams, array $proxy = []) { $class = new CreateUserTargets(); @@ -171,6 +236,9 @@ public function createUserTargets(array $postParams, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function deleteUserTargets(array $postParams, array $proxy = []) { $class = new DeleteUserTargets(); @@ -178,6 +246,9 @@ public function deleteUserTargets(array $postParams, array $proxy = []) return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response(); } + /** + * @throws \SodiumException + */ public function buyOffers(array $postParams, array $proxy = []) { $class = new BuyOffers(); diff --git a/src/Engine/Request.php b/src/Engine/Request.php index d896967..df6dbfe 100644 --- a/src/Engine/Request.php +++ b/src/Engine/Request.php @@ -22,6 +22,9 @@ public function initCurl() $this->ch = curl_init(); } + /** + * @throws \SodiumException + */ public function dmarketHttpRequest($publicKey, $secretKey, $postParams = [], $proxy = []) { if (!isset($this->ch)) { @@ -63,6 +66,9 @@ public function response($data) return new $class($data); } + /** + * @throws \SodiumException + */ private function generateSignature($privateKey, $method, $route, $timestamp, array $postParams = []): string { if (!empty($postParams)) diff --git a/src/Requests/AggregatedPrices.php b/src/Requests/AggregatedPrices.php index 39f6203..06dbb47 100644 --- a/src/Requests/AggregatedPrices.php +++ b/src/Requests/AggregatedPrices.php @@ -24,6 +24,9 @@ public function getUrl(): string return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/BuyOffers.php b/src/Requests/BuyOffers.php index 9188c14..9fe9480 100644 --- a/src/Requests/BuyOffers.php +++ b/src/Requests/BuyOffers.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/ClosedUserOffers.php b/src/Requests/ClosedUserOffers.php new file mode 100644 index 0000000..114faf3 --- /dev/null +++ b/src/Requests/ClosedUserOffers.php @@ -0,0 +1,42 @@ +queryPath = http_build_query($queries); + } + + public function getUrl(): string + { + return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); + } + + /** + * @throws \SodiumException + */ + public function call(string $publicKey, string $secretKey, array $proxy = []) + { + return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); + } + + public function getRequestMethod(): string + { + return $this->method; + } + + public function getRootUrl(): string + { + return "https://api.dmarket.com"; + } +} \ No newline at end of file diff --git a/src/Requests/ClosedUserTargets.php b/src/Requests/ClosedUserTargets.php index e731e45..aedf2de 100644 --- a/src/Requests/ClosedUserTargets.php +++ b/src/Requests/ClosedUserTargets.php @@ -22,6 +22,9 @@ public function getUrl(): string return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/CreateUserOffers.php b/src/Requests/CreateUserOffers.php index a73cd39..8b73e3c 100644 --- a/src/Requests/CreateUserOffers.php +++ b/src/Requests/CreateUserOffers.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/CreateUserTargets.php b/src/Requests/CreateUserTargets.php index 9389338..02b92b9 100644 --- a/src/Requests/CreateUserTargets.php +++ b/src/Requests/CreateUserTargets.php @@ -18,6 +18,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/DeleteOffers.php b/src/Requests/DeleteOffers.php index 468ff27..109ac4b 100644 --- a/src/Requests/DeleteOffers.php +++ b/src/Requests/DeleteOffers.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/DeleteUserTargets.php b/src/Requests/DeleteUserTargets.php index a8fa570..1a13290 100644 --- a/src/Requests/DeleteUserTargets.php +++ b/src/Requests/DeleteUserTargets.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/DepositAssets.php b/src/Requests/DepositAssets.php index 424bb45..0b13264 100644 --- a/src/Requests/DepositAssets.php +++ b/src/Requests/DepositAssets.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/DepositStatus.php b/src/Requests/DepositStatus.php index 4f51a1a..d142270 100644 --- a/src/Requests/DepositStatus.php +++ b/src/Requests/DepositStatus.php @@ -22,6 +22,9 @@ public function getUrl(): string return self::URL . $this->depositId; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/EditUserOffers.php b/src/Requests/EditUserOffers.php index 37b58f2..4db0d66 100644 --- a/src/Requests/EditUserOffers.php +++ b/src/Requests/EditUserOffers.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/MarketItems.php b/src/Requests/MarketItems.php index c60f92f..1314a39 100644 --- a/src/Requests/MarketItems.php +++ b/src/Requests/MarketItems.php @@ -22,6 +22,9 @@ public function getUrl(): string return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/OffersByTitle.php b/src/Requests/OffersByTitle.php index 68f8784..ae530d0 100644 --- a/src/Requests/OffersByTitle.php +++ b/src/Requests/OffersByTitle.php @@ -22,6 +22,9 @@ public function getUrl(): string return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/SyncUserInventory.php b/src/Requests/SyncUserInventory.php index 9942112..1ea5486 100644 --- a/src/Requests/SyncUserInventory.php +++ b/src/Requests/SyncUserInventory.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Requests/UserBalance.php b/src/Requests/UserBalance.php index 8b2764f..f6685e8 100644 --- a/src/Requests/UserBalance.php +++ b/src/Requests/UserBalance.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/UserInventory.php b/src/Requests/UserInventory.php index 412e695..b0702b0 100644 --- a/src/Requests/UserInventory.php +++ b/src/Requests/UserInventory.php @@ -22,6 +22,9 @@ public function getUrl(): string return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/UserItems.php b/src/Requests/UserItems.php index 2899803..2c930f3 100644 --- a/src/Requests/UserItems.php +++ b/src/Requests/UserItems.php @@ -22,6 +22,9 @@ public function getUrl(): string return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/UserOffers.php b/src/Requests/UserOffers.php index eea741c..97559f2 100644 --- a/src/Requests/UserOffers.php +++ b/src/Requests/UserOffers.php @@ -24,6 +24,9 @@ public function getUrl(): string return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/UserProfile.php b/src/Requests/UserProfile.php index 0b744bc..799532f 100644 --- a/src/Requests/UserProfile.php +++ b/src/Requests/UserProfile.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, [], $proxy); diff --git a/src/Requests/UserTargets.php b/src/Requests/UserTargets.php index 4cd5374..2420ef9 100644 --- a/src/Requests/UserTargets.php +++ b/src/Requests/UserTargets.php @@ -19,6 +19,9 @@ public function __construct($queries) $this->queryPath = http_build_query($queries); } + /** + * @throws \SodiumException + */ public function getUrl(): string { return self::URL . (!empty($this->queryPath) ? '?' . $this->queryPath : ''); diff --git a/src/Requests/WithdrawAssets.php b/src/Requests/WithdrawAssets.php index fb7c0bc..324f6b7 100644 --- a/src/Requests/WithdrawAssets.php +++ b/src/Requests/WithdrawAssets.php @@ -16,6 +16,9 @@ public function getUrl(): string return self::URL; } + /** + * @throws \SodiumException + */ public function call(string $publicKey, string $secretKey, array $postParams = [], array $proxy = []) { return $this->dmarketHttpRequest($publicKey, $secretKey, $postParams, $proxy); diff --git a/src/Responses/ClosedUserOffers.php b/src/Responses/ClosedUserOffers.php new file mode 100644 index 0000000..38e3df0 --- /dev/null +++ b/src/Responses/ClosedUserOffers.php @@ -0,0 +1,25 @@ +data = $this->decodeResponse($response); + } + + public function response() + { + return $this->data; + } + + private function decodeResponse($response) + { + return json_decode($response, true); + } +} \ No newline at end of file