Skip to content

Commit

Permalink
Added 10 TradeOffer methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Allyans3 committed Dec 18, 2022
1 parent bbc546f commit c29bcca
Show file tree
Hide file tree
Showing 45 changed files with 2,786 additions and 21 deletions.
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
"imangazaliev/didom": "^1.18",
"php-curl-class/php-curl-class": "8.10.0",
"nesbot/carbon": "^2.61.0",
"ext-curl": "*",
"ext-json": "*",
"ext-bcmath": "*"
"ramsey/uuid": "^4.2"
},
"autoload": {
"psr-4": {
"SteamApi\\": "src/"
}
},
"require-dev": {
"symfony/var-dumper": "^5.4"
"symfony/var-dumper": "^5.4",
"allyans3/protobuf-steam-auth": "^1.0"
}
}
19 changes: 19 additions & 0 deletions examples/TradeOffers/accept_trade_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

$formData = [
'partner_id' => 76531274732642783
];


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->acceptTradeOffer(5654234726, $formData));
15 changes: 15 additions & 0 deletions examples/TradeOffers/cancel_trade_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->cancelTradeOffer(5461827369));
31 changes: 31 additions & 0 deletions examples/TradeOffers/create_trade_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

$tradeLink = 'https://steamcommunity.com/tradeoffer/new/?partner=152735263&token=g82gdgy2d';

$formData = [
'partner_id' => 76531274732642783, //optional
'message' => 'message', //optional
'my_items' => [
[
"app_id" => 730,
"context_id" => "2",
"amount" => 1,
"asset_id" => "28738189184"
],
],
'partner_items' => []
];


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->createTradeOffer($tradeLink, $formData));
15 changes: 15 additions & 0 deletions examples/TradeOffers/decline_trade_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->declineTradeOffer(5378282881));
19 changes: 19 additions & 0 deletions examples/TradeOffers/incoming_offers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

$options = [
'history' => false //optional
];


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getIncomingOffers($options));
29 changes: 29 additions & 0 deletions examples/TradeOffers/make_countered_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

$formData = [
'partner_id' => 76531274732642783,
'message' => 'message', //optional
'my_items' => [
[
"app_id" => 730,
"context_id" => "2",
"amount" => 1,
"asset_id" => "28264749184"
],
],
'partner_items' => []
];


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->makeCounteredOffer(5654234726, $formData));
19 changes: 19 additions & 0 deletions examples/TradeOffers/sent_offers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

$options = [
'history' => false //optional
];


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getSentOffers($options));
15 changes: 15 additions & 0 deletions examples/TradeOffers/trade_link.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getTradeLink());
15 changes: 15 additions & 0 deletions examples/TradeOffers/trade_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getTradeOffer(5578923742));
19 changes: 19 additions & 0 deletions examples/TradeOffers/trade_receipt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
require __DIR__ . '/../../vendor/autoload.php';

use SteamApi\SteamApi;

$api = new SteamApi();

// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

$options = [
'language' => 'english' //optional
];


dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getTradeReceipt(5426374527354625341, $options));
6 changes: 5 additions & 1 deletion examples/my_history.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

dd($api->detailed()->withCookies($cookies)->getMyHistory($options));

dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getMyHistory($options));



Expand Down
6 changes: 5 additions & 1 deletion examples/my_listings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

dd($api->detailed()->withCookies($cookies)->getMyListings($options));

dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getMyListings($options));



Expand Down
6 changes: 5 additions & 1 deletion examples/notification_counts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

dd($api->detailed()->withCookies($cookies)->getNotificationCounts());

dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getNotificationCounts());
6 changes: 5 additions & 1 deletion examples/user_inventory_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
// Cookies for steamcommunity.com
$cookies = 'sessionid=*********; steamCountry=****************; steamLoginSecure=**************;';

dd($api->detailed()->withCookies($cookies)->getUserInventoryAuth(Apps::CSGO_ID, $options));

dd($api->detailed()
->withCustomCurlOpts([CURLOPT_COOKIEFILE => 'absolute_path_to_cookie_file']) // with cookie file
->withCookies($cookies) // or with cookies from string or array
->getUserInventoryAuth(Apps::CSGO_ID, $options));
20 changes: 20 additions & 0 deletions src/Configs/TradeOffersConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace SteamApi\Configs;

class TradeOffersConfig
{
const STATE = [

2 => "",
3 => "Trade Accepted",
4 => "Counter Offer Made",

6 => "Trade Offer Canceled",
7 => "Trade Declined",
8 => "Items Now Unavailable For Trade",
9 => "Awaiting Mobile Confirmation",

11 => "On hold for"
];
}
11 changes: 6 additions & 5 deletions src/Engine/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ private function makeSingleRequest(array $proxy = [], string $cookies = '', bool
if (!isset($this->curl))
$this->curl = curl_init();

$requestMethod = $this->getRequestMethod();

curl_setopt_array($this->curl,
$this->defaultCurlOpts + EngineService::setProxyForSingle($proxy) + $curlOpts + [
CURLOPT_CUSTOMREQUEST => $this->getRequestMethod(),
CURLOPT_CUSTOMREQUEST => $requestMethod,
CURLOPT_HTTPHEADER => self::mergeHeaders($this->getHeaders()),
CURLOPT_URL => $this->getUrl(),
CURLOPT_HEADER => $detailed,
CURLOPT_COOKIE => $cookies
CURLOPT_COOKIE => $cookies,
CURLOPT_POSTFIELDS => ($requestMethod === 'POST') ? http_build_query($this->getFormData()) : ""
]
);

Expand Down Expand Up @@ -111,7 +114,7 @@ private function getCookie($response): array
}

/**
* @param $str
* @param string $header
* @return array
*/
private function headersToArray(string $header): array
Expand Down Expand Up @@ -160,8 +163,6 @@ private function mergeHeaders($headers): array
*/
public function response($data, bool $detailed = false, bool $multiRequest = false)
{
// $class = Engine::RESPONSE_PREFIX . strrev(explode('\\', strrev(get_called_class()), 2)[0]);

$class = self::getResponseClass();

if (!class_exists($class))
Expand Down
8 changes: 8 additions & 0 deletions src/Exception/InvalidFormDataException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace SteamApi\Exception;

class InvalidFormDataException extends \Exception
{

}
8 changes: 8 additions & 0 deletions src/Exception/InvalidTradeLinkException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace SteamApi\Exception;

class InvalidTradeLinkException extends \Exception
{

}
Loading

0 comments on commit c29bcca

Please sign in to comment.