PHP code example of radowoj / yaah

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


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

$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'
]);

$localId = 1;

$auction = new Auction([
    AuctionFids::FID_TITLE => 'Test auction',
    AuctionFids::FID_CATEGORY => 26319,
    AuctionFids::FID_TIMESPAN => AuctionTimespans::TIMESPAN_7_DAYS,
    AuctionFids::FID_QUANTITY => 1,
    AuctionFids::FID_BUY_NOW_PRICE => 10.00,
    AuctionFids::FID_COUNTRY => 1,
    AuctionFids::FID_REGION => 15,
    AuctionFids::FID_CITY => 'Poznan',
    AuctionFids::FID_SHIPPING_PAID_BY => ShippingPaidBy::SHIPPING_PAID_BY_BUYER,
    AuctionFids::FID_PAYMENT_FORMS => PaymentForms::PAYMENT_FORM_VAT_INVOICE,
    AuctionFids::FID_DESCRIPTION => 'Test auction description',
    AuctionFids::FID_POSTCODE => '12-345',
    AuctionFids::FID_SALE_FORMAT => SaleFormats::SALE_FORMAT_NON_SHOP,
    AuctionFids::FID_POST_PACKAGE_PRIORITY_PRICE => 11.00
]);

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

$allegroItemId = $helper->newAuction($auction, $localId);

echo "Created auction with itemId = {$allegroItemId}\n";



use Radowoj\Yaah\HelperFactory\Factory;

try {
    $helper = (new Factory())->create(- in this case echo details of every journal
     * item that creates a deal
     */
    array_map(function($deal){
        if ($deal->isTypeCreateDeal()) {
            echo "Deal {$deal->getId()} (itemId {$deal->getItemId()} - quantity {$deal->getQuantity()}) created at {$deal->getEventTime()}\n";
        }
    }, $deals);

} catch (Exception $e) {
    echo "Exception: {$e->getMessage()}\nFile: {$e->getFile()}; Line: {$e->getLine()}\n\n";
}