PHP code example of tourze / youzan-api-bundle

1. Go to this page and download the library: Download tourze/youzan-api-bundle 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/ */

    

tourze / youzan-api-bundle example snippets




return [
    // ...
    YouzanApiBundle\YouzanApiBundle::class => ['all' => true],
];



use YouzanApiBundle\Service\YouzanClientService;

// Inject the service
public function __construct(
    private readonly YouzanClientService $youzanClientService
) {
}

// Create a new account
$account = $this->youzanClientService->createAccount(
    'Account Name',
    'your_client_id',
    'your_client_secret'
);

// Get API client
$client = $this->youzanClientService->getClient($account);

// Or get client by client ID
$client = $this->youzanClientService->getClientByClientId('your_client_id');



// Use the client to make API calls
$response = $client->get('/youzan.shop.get', ['version' => '3.0.0']);



use YouzanApiBundle\Entity\Account;
use YouzanApiBundle\Entity\Shop;

// Custom account with additional properties
class ExtendedAccount extends Account
{
    private string $description;
    
    // Additional methods...
}

// Custom shop repository
class CustomShopRepository extends ShopRepository
{
    public function findActiveShops(): array
    {
        return $this->createQueryBuilder('s')
            ->where('s.active = :active')
            ->setParameter('active', true)
            ->getQuery()
            ->getResult();
    }
}