PHP code example of radowoj / yaah-mtg

1. Go to this page and download the library: Download radowoj/yaah-mtg 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/ */

    

radowoj / yaah-mtg example snippets


use Radowoj\Yaah\Auction;
use Radowoj\Yaah\Constants\AuctionTimespans;
use Radowoj\Yaah\Constants\AuctionFids;
use Radowoj\Yaah\Constants\Conditions;
use Radowoj\Yaah\Constants\SaleFormats;
use Radowoj\Yaah\Constants\ShippingPaidBy;
use Radowoj\Yaah\HelperFactory\Factory;

use Radowoj\Yaah\AuctionDecorators\Mtg\RedAuction;
use Radowoj\Yaah\AuctionDecorators\Mtg\BlueAuction;

$helper = (new Factory())->create([
    'apiKey'        => 'your-allegro-api-key',
    'login'         => 'your-allegro-login',
    'passwordHash'  => 'your-sha-256-hashed-and-then-base64-encoded-allegro-password',
    'countryCode'   => 'your-country-code',
    'isSandbox'     => 'true-if-you-intend-to-use-sandbox'
]);

$redAuction = new RedAuction(new Auction());
$redAuction->fromArray([
    'title' => 'Test auction for a Red card',
    'description' => 'Test auction description',
    'timespan' => AuctionTimespans::TIMESPAN_3_DAYS,
    'quantity' => 100,
    'country' => 1,
    'region' => 15,
    'city' => 'SomeCity',
    'postcode' => '12-345',
    'condition' => Conditions::CONDITION_NEW,
    'sale_format' => SaleFormats::SALE_FORMAT_SHOP,
    'buy_now_price' => 43.21,
    'shipping_paid_by' => ShippingPaidBy::SHIPPING_PAID_BY_BUYER,
    'post_package_priority_price' => 12.34,
]);

$redAuction->setPhotos([
    //array of (no more than 8) paths to photo files
]);

$blueAuction = new BlueAuction(new Auction());
$blueAuction->fromArray([
    'title' => 'Test auction for a Blue card',
    'description' => 'Test auction description',
    'timespan' => AuctionTimespans::TIMESPAN_3_DAYS,
    'quantity' => 100,
    'country' => 1,
    'region' => 15,
    'city' => 'SomeCity',
    'postcode' => '12-345',
    'condition' => Conditions::CONDITION_NEW,
    'sale_format' => SaleFormats::SALE_FORMAT_SHOP,
    'buy_now_price' => 43.21,
    'shipping_paid_by' => ShippingPaidBy::SHIPPING_PAID_BY_BUYER,
    'post_package_priority_price' => 12.34,
]);

$blueAuction->setPhotos([
    //array of (no more than 8) paths to photo files
]);

$localId = 1;

$allegroItemId = $helper->newAuction($redAuction, $localId++);
echo "Created auction with itemId = {$allegroItemId}\n";

$allegroItemId = $helper->newAuction($blueAuction, $localId++);
echo "Created auction with itemId = {$allegroItemId}\n";