Skip to content

Commit

Permalink
Unofficial TargetsByTitle method and detailed() chain method
Browse files Browse the repository at this point in the history
  • Loading branch information
Allyans3 committed Feb 24, 2025
1 parent 71f4768 commit 774406c
Show file tree
Hide file tree
Showing 55 changed files with 887 additions and 134 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ $RECYCLE.BIN/
/example
/example/*

composer.lock
composer.lock
index.php
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Methods
-------------------

```php
// Used to get detailed response
$api->detailed()->getUserProfile()

// Account
$api->getUserProfile(array $proxy = [])
$api->getUserBalance(array $proxy = [])
Expand All @@ -54,6 +57,7 @@ $api->getClosedUserOffers(array $queries = [], array $proxy = [])

// Buy items
$api->getOffersByTitle(array $queries, array $proxy = [])
$api->getTargetsByTitle(string $gameId, string $title, array $proxy = [])
$api->getAggregatedPrices(array $queries, array $proxy = [])
$api->getUserTargets(array $queries = [], array $proxy = [])
$api->getClosedUserTargets(array $queries = [], array $proxy = [])
Expand Down
83 changes: 83 additions & 0 deletions src/Configs/Engine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace DMarketAuthApi\Configs;

class Engine
{
const HTTP_CODES = [
// Successful 2xx
200 => "OK",
201 => "Created",
202 => "Accepted",
203 => "Non-Authoritative Information",
204 => "No Content",
205 => "Reset Content",
206 => "Partial Content",
207 => "Multi-Status (WebDAV)",
208 => "Already Reported (WebDAV)",
226 => "IM Used",

// Redirection 3xx
300 => "Multiple Choices",
301 => "Moved Permanently",
302 => "Found",
303 => "See Other",
304 => "Not Modified",
305 => "Use Proxy",
306 => "(Unused)",
307 => "Temporary Redirect",
308 => "Permanent Redirect",

// Client Error 4xx
400 => "Bad Request",
401 => "Unauthorized",
402 => "Payment Required",
403 => "Forbidden",
404 => "Not Found",
405 => "Method Not Allowed",
406 => "Not Acceptable",
407 => "Proxy Authentication Required",
408 => "Request Timeout",
409 => "Conflict",
410 => "Gone",
411 => "Length Required",
412 => "Precondition Failed",
413 => "Content Too Large",
414 => "URI Too Long",
415 => "Unsupported Media Type",
416 => "Range Not Satisfiable",
417 => "Expectation Failed",
418 => "(Unused)",
420 => "Enhance Your Calm (Twitter)",
421 => "Misdirected Request",
422 => "Unprocessable Content",
423 => "Locked (WebDAV)",
424 => "Failed Dependency (WebDAV)",
425 => "Reserved for WebDAV",
426 => "Upgrade Required",
428 => "Precondition Required",
429 => "Too Many Requests",
431 => "Request Header Fields Too Large",
444 => "No Response (Nginx)",
449 => "Retry With (Microsoft)",
450 => "Blocked by Windows Parental Controls (Microsoft)",
451 => "Unavailable For Legal Reasons",
499 => "Client Closed Request (Nginx)",

// Server Error 5xx
500 => "Internal Server Error",
501 => "Not Implemented",
502 => "Bad Gateway",
503 => "Service Unavailable",
504 => "Gateway Timeout",
505 => "HTTP Version Not Supported",
506 => "Variant Also Negotiates (Experimental)",
507 => "Insufficient Storage (WebDAV)",
508 => "Loop Detected (WebDAV)",
509 => "Bandwidth Limit Exceeded (Apache)",
510 => "Not Extended",
511 => "Network Authentication Required",
598 => "Network read timeout error",
599 => "Network connect timeout error"
];
}
70 changes: 46 additions & 24 deletions src/DMarketAuthApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use DMarketAuthApi\Requests\MarketItems;
use DMarketAuthApi\Requests\OffersByTitle;
use DMarketAuthApi\Requests\SyncUserInventory;
use DMarketAuthApi\Requests\TargetsByTitle;
use DMarketAuthApi\Requests\UserBalance;
use DMarketAuthApi\Requests\UserInventory;
use DMarketAuthApi\Requests\UserItems;
Expand All @@ -32,12 +33,23 @@ class DMarketAuthApi
private string $publicKey;
private string $secretKey;

private bool $detailed = false;

public function __construct($publicKey, $secretKey)
{
$this->publicKey = $publicKey;
$this->secretKey = $secretKey;
}

/**
* @return $this
*/
public function detailed(): DMarketAuthApi
{
$this->detailed = true;
return $this;
}


// Account
/**
Expand All @@ -47,7 +59,7 @@ public function getUserProfile(array $proxy = [])
{
$class = new UserProfile();

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

/**
Expand All @@ -57,7 +69,7 @@ public function getUserBalance(array $proxy = [])
{
$class = new UserBalance();

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


Expand All @@ -70,7 +82,7 @@ public function depositAssets(array $postParams, array $proxy = [])
{
$class = new DepositAssets();

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

/**
Expand All @@ -80,7 +92,7 @@ public function getDepositStatus(string $depositId, array $proxy = [])
{
$class = new DepositStatus($depositId);

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

/**
Expand All @@ -90,7 +102,7 @@ public function getUserOffers(array $queries = [], array $proxy = [])
{
$class = new UserOffers($queries);

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

/**
Expand All @@ -100,7 +112,7 @@ public function createUserOffers(array $postParams, array $proxy = [])
{
$class = new CreateUserOffers();

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

/**
Expand All @@ -110,7 +122,7 @@ public function editUserOffers(array $postParams, array $proxy = [])
{
$class = new EditUserOffers();

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

/**
Expand All @@ -120,7 +132,7 @@ public function getMarketItems(array $queries, array $proxy = [])
{
$class = new MarketItems($queries);

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

/**
Expand All @@ -130,7 +142,7 @@ public function deleteOffers(array $postParams, array $proxy = [])
{
$class = new DeleteOffers();

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


Expand All @@ -143,7 +155,7 @@ public function getUserInventory(array $queries = [], array $proxy = [])
{
$class = new UserInventory($queries);

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

/**
Expand All @@ -153,7 +165,7 @@ public function syncUserInventory(array $postParams, array $proxy = [])
{
$class = new SyncUserInventory();

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

/**
Expand All @@ -163,7 +175,7 @@ public function withdrawAssets(array $postParams, array $proxy = [])
{
$class = new WithdrawAssets();

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

/**
Expand All @@ -173,7 +185,7 @@ public function getUserItems(array $queries, array $proxy = [])
{
$class = new UserItems($queries);

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

/**
Expand All @@ -183,7 +195,7 @@ public function getCustomizedFees(array $queries, array $proxy = [])
{
$class = new CustomizedFees($queries);

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


Expand All @@ -197,7 +209,7 @@ public function getClosedUserOffers(array $queries = [], array $proxy = [])
{
$class = new ClosedUserOffers($queries);

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


Expand All @@ -211,7 +223,17 @@ public function getOffersByTitle(array $queries, array $proxy = [])
{
$class = new OffersByTitle($queries);

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

/**
* @throws \SodiumException
*/
public function getTargetsByTitle(string $gameId, string $title, array $proxy = [])
{
$class = new TargetsByTitle($gameId, $title);

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

/**
Expand All @@ -221,7 +243,7 @@ public function getAggregatedPrices(array $queries, array $proxy = [])
{
$class = new AggregatedPrices($queries);

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

/**
Expand All @@ -231,7 +253,7 @@ public function getUserTargets(array $queries = [], array $proxy = [])
{
$class = new UserTargets($queries);

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

/**
Expand All @@ -241,7 +263,7 @@ public function getClosedUserTargets(array $queries = [], array $proxy = [])
{
$class = new ClosedUserTargets($queries);

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

/**
Expand All @@ -251,7 +273,7 @@ public function createUserTargets(array $postParams, array $proxy = [])
{
$class = new CreateUserTargets();

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

/**
Expand All @@ -261,7 +283,7 @@ public function editUserTargets(array $postParams, array $proxy = [])
{
$class = new EditUserTargets();

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


Expand All @@ -272,7 +294,7 @@ public function deleteUserTargets(array $postParams, array $proxy = [])
{
$class = new DeleteUserTargets();

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

/**
Expand All @@ -282,7 +304,7 @@ public function buyOffers(array $postParams, array $proxy = [])
{
$class = new BuyOffers();

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


Expand All @@ -295,6 +317,6 @@ public function getLastSales(array $queries, array $proxy = [])
{
$class = new LastSales($queries);

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

0 comments on commit 774406c

Please sign in to comment.