Skip to content

Commit

Permalink
Added ClosedUserOffers method
Browse files Browse the repository at this point in the history
  • Loading branch information
Allyans3 committed May 7, 2022
1 parent d40cdaf commit c3de93e
Show file tree
Hide file tree
Showing 24 changed files with 204 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/DMarketAuthApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -36,13 +37,19 @@ public function __construct($publicKey, $secretKey)


//Account
/**
* @throws \SodiumException
*/
public function getUserProfile(array $proxy = [])
{
$class = new UserProfile();

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getUserBalance(array $proxy = [])
{
$class = new UserBalance();
Expand All @@ -53,48 +60,79 @@ public function getUserBalance(array $proxy = [])


//Sell Items
/**
* @throws \SodiumException
*/
public function depositAssets(array $postParams, array $proxy = [])
{
$class = new DepositAssets();

return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getDepositStatus(string $depositId, array $proxy = [])
{
$class = new DepositStatus($depositId);

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getUserOffers(array $queries = [], array $proxy = [])
{
$class = new UserOffers($queries);

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();

return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function editUserOffers(array $postParams, array $proxy = [])
{
$class = new EditUserOffers();

return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getMarketItems(array $queries, array $proxy = [])
{
$class = new MarketItems($queries);

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function deleteOffers(array $postParams, array $proxy = [])
{
$class = new DeleteOffers();
Expand All @@ -105,27 +143,39 @@ public function deleteOffers(array $postParams, array $proxy = [])


//Inventory/items
/**
* @throws \SodiumException
*/
public function getUserInventory(array $queries = [], array $proxy = [])
{
$class = new UserInventory($queries);

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function syncUserInventory(array $postParams, array $proxy = [])
{
$class = new SyncUserInventory();

return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function withdrawAssets(array $postParams, array $proxy = [])
{
$class = new WithdrawAssets();

return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getUserItems(array $queries, array $proxy = [])
{
$class = new UserItems($queries);
Expand All @@ -136,48 +186,69 @@ public function getUserItems(array $queries, array $proxy = [])


//Buy items
/**
* @throws \SodiumException
*/
public function getOffersByTitle(array $queries, array $proxy = [])
{
$class = new OffersByTitle($queries);

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getAggregatedPrices(array $queries, array $proxy = [])
{
$class = new AggregatedPrices($queries);

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getUserTargets(array $queries = [], array $proxy = [])
{
$class = new UserTargets($queries);

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function getClosedUserTargets(array $queries = [], array $proxy = [])
{
$class = new ClosedUserTargets($queries);

return $class->call($this->publicKey, $this->secretKey, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function createUserTargets(array $postParams, array $proxy = [])
{
$class = new CreateUserTargets();

return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function deleteUserTargets(array $postParams, array $proxy = [])
{
$class = new DeleteUserTargets();

return $class->call($this->publicKey, $this->secretKey, $postParams, $proxy)->response();
}

/**
* @throws \SodiumException
*/
public function buyOffers(array $postParams, array $proxy = [])
{
$class = new BuyOffers();
Expand Down
6 changes: 6 additions & 0 deletions src/Engine/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function initCurl()
$this->ch = curl_init();
}

/**
* @throws \SodiumException
*/
public function dmarketHttpRequest($publicKey, $secretKey, $postParams = [], $proxy = [])
{
if (!isset($this->ch)) {
Expand Down Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/AggregatedPrices.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/BuyOffers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
42 changes: 42 additions & 0 deletions src/Requests/ClosedUserOffers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace DMarketAuthApi\Requests;

use DMarketAuthApi\Engine\Request;
use DMarketAuthApi\Interfaces\RequestInterface;

class ClosedUserOffers extends Request implements RequestInterface
{
const URL = "/marketplace-api/v1/user-offers/closed";

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

public function __construct($queries)
{
$this->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";
}
}
3 changes: 3 additions & 0 deletions src/Requests/ClosedUserTargets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/CreateUserOffers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/CreateUserTargets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/DeleteOffers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/DeleteUserTargets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/DepositAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/DepositStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/EditUserOffers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Requests/MarketItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit c3de93e

Please sign in to comment.