🔥 WORK IN PROGRESS
Use Composer to install the package:
$ composer require mamoot/cardmarket-php-sdk
use Mamoot\CardMarket\Cardmarket;
use Mamoot\CardMarket\HttpClient\HttpClientCreator;
$httpCreator = new HttpClientCreator();
$httpCreator->setApplicationToken('your_application_token')
->setApplicationSecret('your_application_secret')
->setAccessToken('your_access_token')
->setAccessSecret('your_access_secret');
$cardmarket = new Cardmarket($httpCreator);
Retrieve all TCG Games from CardMarket
$cardmarket->games()->getGamesList());
Retrieve all expansions by game.
// All pokemon expansions
$cardmarket->expansions()->getExpansionsListByGame(6);
// All Magic The Gathering expansions
$cardmarket->expansions()->getExpansionsListByGame(1);
Retrieve all cards for a given expansion.
// All Pokemon cards of the Jungle expansion
$cardmarket->expansions()->getCardsListByExpansion(1525);
Retrieve the details and price guide of a single card
// Cards details for "Electrode (Holo) - Jungle expansion"
$cardmarket->cards()->getCardsDetails(273799);
It's not really a part of the Cardmarket SDK but if want to organize your work, it can be a good place!
namespace Vendor\MyNamespace;
use Mamoot\CardMarket\Resources\HttpCaller;
class MyPokemonResource extends HttpCaller
{
public function getOrderedExpansions(): array
{
// do stuff
}
}
use Vendor\MyNamespace\MyPokemonResource;
$cardmarket = new Cardmarket($httpCreator);
$cardmarket->registerResources('pokemon', MyPokemonResource::class);
Now you can manipulate your resource like the default provided :
$cardmarket->pokemon()->getOrderedExpansions();
You can't redefined default resources
Get your MTG CSV file from CardMarket into your disk
// 1 = (gameId) Magic The Gathering
$magicStock = $cardmarket->stock()->getStockFile(1);
Now, you can use the Helper CsvStockFileHelper
to store data on your disk.
use \Mamoot\CardMarket\Helper\CsvStockFileHelper;
$stockHelper = new CsvStockFileHelper($magicStock['stock']);
$stockHelper->storeStockFileOnDisk("./mtg.csv");
If you want to run the tests you should run the following commands:
git clone git@github.com:mamoot64/cardmarket-php-sdk.git
cd cardmarket-php-sdk
composer install
composer test
If you want to generate coverage with HTML report, run:
composer test-coverage-html