PHP code example of uplinestudio / moysklad

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

    

uplinestudio / moysklad example snippets


use MoySklad\ApiClient;

$api = new ApiClient('host', true, [
    'login' => 'your_login',
    'password' => 'your_password',
]);

//or

$api = new ApiClient('host', true, [
   'token' => 'your_token',
]);


$counterpartyList = $api->entity()->counterparty()->getList();
$counterparty = $api->entity()->counterparty()->get('id');

use MoySklad\Util\Param\Limit;
use MoySklad\Util\Param\Offset;
use MoySklad\Util\Param\Order;
use MoySklad\Util\Param\Search;
use MoySklad\Util\Param\EntityFilter;
use MoySklad\Util\Param\StandardFilter;

$params = [
    Limit::eq(50),
    Offset::eq(10),
    Order::asc('name'),
    Order::desc('date'),
    Search::eq('some interesting thing'),
    EntityFilter::eq('product', $product),
    EntityFilter::neq('pricetype', $pricetype),
    StandardFilter::eq('region_id', $regionId),
    StandardFilter::gte('created', $createdDate),
    StandardFilter::like('name', 'ame'),
];

$counterpartyList = $api->entity()->counterparty()->getList($params);

$product = new Product();
$product->name = 'Новый продукт';

$product = $api->entity()->product()->create($product);

$product->name = 'new name';
$product = $api->entity()->product()->update($product);

$counterpartyAccountsList = $api->entity()->counterparty()->getAccountsList('counterparty_id');

$counterpartyAccount = $api->entity()->counterparty()->getAccount('counterparty_id', 'account_id');


$counterparty = $api->entity()->counterparty()->get('id');
$addressCity = $counterparty->legalAddressFull->city; // null

$counterparty->legalAddressFull->fetch();
$addressCity = $counterparty->legalAddressFull->city; // название города