1. Go to this page and download the library: Download marmozist/steam-gifts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marmozist / steam-gifts example snippets
use Marmozist\SteamGifts\Application\ClientFactory;
use Marmozist\SteamGifts\Application\UserProvider\Factory\HttpUserProviderFactory;
use Marmozist\SteamGifts\Application\GiveawayProvider\Factory\HttpGiveawayProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\UserProvider\HttpUserProcessor\Factory\CompositeUserProcessorFactory;
use Marmozist\SteamGifts\Application\GiveawayProvider\HttpGiveawayProcessor\Factory\CompositeGiveawayProcessorFactory;
use Marmozist\SteamGifts\UseCase\GetUser;
$userProvider = HttpUserProviderFactory::createProvider(
HttpClientType::Curl(),
CompositeUserProcessorFactory::createProcessor()
);
$giveawayProvider = HttpGiveawayProviderFactory::createProvider(
HttpClientType::Curl(),
CompositeGiveawayProcessorFactory::createProcessor(new GetUser\Interactor($userProvider))
);
$client = ClientFactory::createClient($userProvider, $giveawayProvider);
use Marmozist\SteamGifts\Application\UserProvider\Factory\HttpUserProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\UserProvider\HttpUserProcessor\Factory\CompositeUserProcessorFactory;
$userProvider = HttpUserProviderFactory::createProvider(
HttpClientType::Curl(),
CompositeUserProcessorFactory::createProcessor()
);
use Marmozist\SteamGifts\Application\UserProvider\Factory\HttpUserProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\UserProvider\HttpUserProcessor\Factory\CompositeUserProcessorFactory;
$userProvider = HttpUserProviderFactory::createProvider(
HttpClientType::Guzzle(),
CompositeUserProcessorFactory::createProcessor()
);
use Marmozist\SteamGifts\Application\UserProvider\Factory\HttpUserProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\UserProvider\HttpUserProcessor\Factory\CompositeUserProcessorFactory;
$userProvider = HttpUserProviderFactory::createProvider(
HttpClientType::Buzz(),
CompositeUserProcessorFactory::createProcessor()
);
use Marmozist\SteamGifts\Application\UserProvider\Factory\HttpUserProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\UserProvider\HttpUserProcessor\Factory\CompositeUserProcessorFactory;
use Http\Client\HttpClient;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\RequestInterface;
/**
* @method static self Custom()
*/
class ExtendedHttpClientType extends HttpClientType
{
const Custom = 'Custom';
}
class CustomHttpClient implements HttpClient
{
public function sendRequest(RequestInterface $request): ResponseInterface
{
// your logic of processing request
}
}
class ExtendedHttpUserProviderFactory extends HttpUserProviderFactory
{
protected static function getClient(HttpClientType $type): HttpClient
{
if ($type->equals(ExtendedHttpClientType::Custom())) {
return new CustomHttpClient();
}
return parent::getClient($type);
}
}
$userProvider = ExtendedHttpUserProviderFactory::createProvider(
ExtendedHttpClientType::Custom(),
CompositeUserProcessorFactory::createProcessor()
);
use Marmozist\SteamGifts\Application\GiveawayProvider\Factory\HttpGiveawayProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\GiveawayProvider\HttpGiveawayProcessor\Factory\CompositeGiveawayProcessorFactory;
use Marmozist\SteamGifts\UseCase\GetUser;
$giveawayProvider = HttpGiveawayProviderFactory::createProvider(
HttpClientType::Curl(),
CompositeGiveawayProcessorFactory::createProcessor(new GetUser\Interactor($userProvider))
);
use Marmozist\SteamGifts\Application\GiveawayProvider\Factory\HttpGiveawayProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\GiveawayProvider\HttpGiveawayProcessor\Factory\CompositeGiveawayProcessorFactory;
use Marmozist\SteamGifts\UseCase\GetUser;
$giveawayProvider = HttpGiveawayProviderFactory::createProvider(
HttpClientType::Guzzle(),
CompositeGiveawayProcessorFactory::createProcessor(new GetUser\Interactor($userProvider))
);
use Marmozist\SteamGifts\Application\GiveawayProvider\Factory\HttpGiveawayProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\GiveawayProvider\HttpGiveawayProcessor\Factory\CompositeGiveawayProcessorFactory;
use Marmozist\SteamGifts\UseCase\GetUser;
$giveawayProvider = HttpGiveawayProviderFactory::createProvider(
HttpClientType::Buzz(),
CompositeGiveawayProcessorFactory::createProcessor(new GetUser\Interactor($userProvider))
);
use Marmozist\SteamGifts\Application\GiveawayProvider\Factory\HttpGiveawayProviderFactory;
use Marmozist\SteamGifts\Application\Utils\Http\HttpClientType;
use Marmozist\SteamGifts\Application\GiveawayProvider\HttpGiveawayProcessor\Factory\CompositeGiveawayProcessorFactory;
use Http\Client\HttpClient;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\RequestInterface;
use Marmozist\SteamGifts\UseCase\GetUser;
/**
* @method static self Custom()
*/
class ExtendedHttpClientType extends HttpClientType
{
const Custom = 'Custom';
}
class CustomHttpClient implements HttpClient
{
public function sendRequest(RequestInterface $request): ResponseInterface
{
// your logic of processing request
}
}
class ExtendedHttpGiveawayProviderFactory extends HttpGiveawayProviderFactory
{
protected static function getClient(HttpClientType $type): HttpClient
{
if ($type->equals(ExtendedHttpClientType::Custom())) {
return new CustomHttpClient();
}
return parent::getClient($type);
}
}
$giveawayProvider = ExtendedHttpGiveawayProviderFactory::createProvider(
ExtendedHttpClientType::Custom(),
CompositeGiveawayProcessorFactory::createProcessor(new GetUser\Interactor($userProvider))
);