1
0
Fork 0
mirror of synced 2025-04-04 06:13:41 +03:00

Compare commits

...

41 commits

Author SHA1 Message Date
fc78e5897b
Merge pull request #221 from opheugene/offer-site
Added site field to ProductOffer
2025-03-20 16:41:04 +03:00
Opheugene
0a862dd86b Added site field to ProductOffer 2025-03-19 17:51:25 +01:00
5a3547894a
Merge pull request #219 from Neur0toxine/fix-cache-action
fix github workflows (cache action)
2025-03-04 20:00:39 +03:00
1d05f3efeb fix github workflows (cache action) 2025-03-04 19:52:24 +03:00
831ed64871
Merge pull request #218 from Neur0toxine/fix-github-workflows
fix github workflows (checkout action)
2025-03-04 19:48:31 +03:00
502a0c8641 fix github workflows (checkout action) 2025-03-04 19:45:09 +03:00
4a99094294
Merge pull request #217 from curse89/master
Add calling setEventDispatcher method in ClientFactory
2025-03-04 19:42:56 +03:00
Сергей Кривич
c379815f76 Upd GH actions config && add calling setEventDispatcher method in CLientFactory 2025-03-04 19:19:35 +03:00
27e9e8eaa5
Merge pull request #216 from retailcrm/integration-embed-js
Add embedJs field to integrations/edit method
2025-01-14 09:23:27 +03:00
Ilyas Salikhov
c21a89c761 Add embedJs field to integrations/edit method 2025-01-13 22:28:31 +03:00
068a9d0e0b
Add customerSubscriptions to Customer entity 2024-12-20 16:34:11 +03:00
Alex Komarichev
1881dd3499 Add customerSubscriptions to Customer entity. Add subscriptions filter to CustomerFilter filter. 2024-12-18 14:42:35 +03:00
Uryvskiy Dima
47edbda927
Add discount amount for update payment request
Add discount amount for update payment request
2024-12-10 15:07:42 +03:00
ellynoize
91c3ca8ce5 add discount in test 2024-12-10 11:46:19 +03:00
ellynoize
6d05a1af3f add for update payment request 2024-12-09 19:43:10 +06:00
Andrey Belikin
16cdc6ce49
Add contact to store reference model (#213) 2024-10-18 10:08:15 +03:00
cdca2b6d6d
Support for urlLike filter in GET /api/v5/store/products 2024-09-25 11:30:20 +03:00
Vlasov
ecaac435cc Added support for urlLike filter in GET /api/v5/store/products 2024-09-24 17:59:01 +03:00
GrishaginEvgeny
e3cc485873
add customFields in CustomerCorporateFilter.php (#210)
Co-authored-by: Евгений Гришагин <grishagin@retailcrm.ru>
2024-09-10 15:00:32 +03:00
4880ed9930
Resolves #206: /api/v5/loyalty/account/{id}/bonus/charge method support 2024-09-04 13:37:32 +03:00
7b393e961b Resolves #206: /api/v5/loyalty/account/{id}/bonus/charge method support 2024-09-04 13:19:20 +03:00
3a3d00aeb8
update version constraint for symfony/console 2024-09-04 13:04:28 +03:00
60624dad9b
Add support for new filters of GET /api/v5/store/offers method 2024-09-04 12:58:19 +03:00
121dcebb32
Replace abandoned php-http/message-factory with psr/http-factory 2024-09-04 12:57:30 +03:00
Viacheslav Akulov
80396691dd
Update composer.json 2024-09-04 10:29:51 +03:00
Viacheslav Akulov
3d5e3e92e6
Update composer.json 2024-09-04 10:27:30 +03:00
RenCurs
6130b265fe
Add support for new filters of GET /api/v5/store/offers method (#205)
* Add support for new filters of GET /api/v5/store/offers method

- filter[min/maxPrice]
- filter[priceType]
- filter[min/maxQuantity]
- filter[catalogs][]

---------

Co-authored-by: Kirill Sukhorukov <suhorukov@retailcrm.ru>
2024-08-27 09:33:04 +03:00
Kirill Sukhorukov
da8ce13736 Add support for new filters of GET /api/v5/store/offers method
- filter[min/maxPrice]
- filter[priceType]
- filter[min/maxQuantity]
2024-08-22 17:15:24 +03:00
Kirill
1c6ebd819f
Add support for GET /api/v5/store/offers method (#203)
Co-authored-by: Kirill Sukhorukov <suhorukov@retailcrm.ru>
2024-08-19 16:01:35 +03:00
Nikolay Parshakov
a7d071af28 Replace abandoned php-http/message-factory to psr/http-factory 2024-08-12 07:26:15 +03:00
544d16186f
Add support for GET "/api/v5/store/products/properties/values" method 2024-08-09 12:46:31 +03:00
Kirill Sukhorukov
dc9e0a5b39 Add support for GET /api/v5/properties/values method 2024-08-07 17:50:13 +03:00
5b04bd9d8a
Support for filtering product properties by groups and sorting by usage in offers 2024-08-06 12:38:45 +03:00
Kirill Sukhorukov
ca1650d8d9 Add filter by ProductGroups and sort by popular for ProductProperties 2024-08-06 10:08:30 +03:00
54ce958c76
Add customer-interaction 2024-08-01 15:14:15 +03:00
Alex Komarichev
be71f22c65 Change params, add matchPath to test 2024-08-01 12:26:50 +03:00
Alex Komarichev
a7cffe45da Add customer-interaction 2024-07-31 18:24:22 +03:00
8b677de616
Fixed ProductFilter types 2024-07-19 12:06:13 +03:00
Opheugene
0ef461e504 fixed array of string 2024-07-18 18:24:03 +02:00
Opheugene
7d65407c7c fixes for tests 2024-07-18 18:20:25 +02:00
Opheugene
ccbff3aba3 Fixed ProductFilter types 2024-07-18 17:33:02 +02:00
50 changed files with 2254 additions and 36 deletions

View file

@ -17,24 +17,30 @@ jobs:
php-version: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- name: Check out code into the workspace
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
- name: Composer cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.HOME }}/.composer/cache
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
run: composer install -o
- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1
- name: Run tests
run: composer run-script phpunit-ci
- name: Coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
verbose: true

View file

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the workspace
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run PHPCS
uses: chekalsky/phpcs-action@v1
phpmd:
@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the workspace
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run PHPMD
uses: GeneaLabs/action-reviewdog-phpmd@1.0.0
with:
@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the workspace
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run PHPStan
uses: docker://oskarstark/phpstan-ga:1.8.0
with:

View file

@ -19,7 +19,7 @@ jobs:
pages_threshold: major_outage
- name: Check out code into the workspace
if: success() && ${{ github.ref != 'refs/heads/master' }}
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP 8.3
if: ${{ github.ref != 'refs/heads/master' }}
uses: shivammathur/setup-php@v2
@ -27,7 +27,7 @@ jobs:
php-version: "8.3"
- name: Cache phpDocumentor
id: cache-phpdocumentor
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: phpDocumentor.phar
key: phpdocumentor

View file

@ -23,19 +23,19 @@
"psr/http-message": "^1.0 || ^2.0",
"psr/http-message-implementation": "^1.0",
"php-http/client-implementation": "^1.0",
"php-http/message-factory": "^1.0",
"php-http/discovery": "^1.13",
"doctrine/annotations": "^1.13|^2.0",
"liip/serializer": "2.2.* || 2.6.*",
"php-http/httplug": "^2.2",
"civicrm/composer-compile-plugin": "^0.20",
"symfony/console": "^4.0|^5.0|^6.0",
"symfony/console": "^4.0|^5.0|^6.0|^7.0",
"psr/event-dispatcher": "^1.0",
"neur0toxine/psr.http-client-implementation.php-http-curl": "*",
"neur0toxine/psr.http-factory-implementation.nyholm": "*",
"neur0toxine/psr.http-message-implementation.nyholm": "*",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"symfony/cache": ">=v3.1.0"
"symfony/cache": ">=v3.1.0",
"psr/http-factory": "^1.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",

View file

@ -18,6 +18,7 @@ use RetailCrm\Api\Interfaces\RequestTransformerInterface;
use RetailCrm\Api\Interfaces\ResponseTransformerInterface;
use RetailCrm\Api\ResourceGroup\Api;
use RetailCrm\Api\ResourceGroup\Costs;
use RetailCrm\Api\ResourceGroup\CustomerInteraction;
use RetailCrm\Api\ResourceGroup\Customers;
use RetailCrm\Api\ResourceGroup\CustomersCorporate;
use RetailCrm\Api\ResourceGroup\CustomFields;
@ -67,6 +68,9 @@ class Client
/** @var \RetailCrm\Api\ResourceGroup\CustomFields */
public $customFields;
/** @var \RetailCrm\Api\ResourceGroup\CustomerInteraction */
public $customerInteraction;
/** @var \RetailCrm\Api\ResourceGroup\Customers */
public $customers;
@ -187,6 +191,14 @@ class Client
$eventDispatcher,
$logger
);
$this->customerInteraction = new CustomerInteraction(
$url,
$httpClient,
$requestTransformer,
$responseTransformer,
$eventDispatcher,
$logger
);
$this->customers = new Customers(
$url,
$httpClient,

22
src/Enum/BySite.php Normal file
View file

@ -0,0 +1,22 @@
<?php
/**
* PHP version 7.3
*
* @category BySite
* @package RetailCrm\Api\Enum
*/
namespace RetailCrm\Api\Enum;
/**
* Class BySite
*
* @category BySite
* @package RetailCrm\Api\Enum
*/
final class BySite
{
public const ID = 'id';
public const CODE = 'code';
}

View file

@ -285,6 +285,7 @@ class ClientFactory implements ClientFactoryInterface, EventDispatcherAwareInter
->setStreamFactory($this->streamFactory)
->setRequestFactory($this->requestFactory)
->setUriFactory($this->uriFactory)
->setEventDispatcher($this->eventDispatcher)
->appendRequestHandlers($this->requestHandlers)
->appendResponseHandlers($this->responseHandlers)
->build();

View file

@ -0,0 +1,86 @@
<?php
/**
* PHP version 7.3
*
* @category Cart
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
namespace RetailCrm\Api\Model\Entity\CustomerInteraction;
use DateTime;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class Cart
*
* @category Cart
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
class Cart
{
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("currency")
*/
public $currency;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("externalId")
*/
public $externalId;
/**
* @var DateTime
*
* @JMS\Type("DateTime<'Y-m-d H:i:sP'>")
* @JMS\SerializedName("droppedAt")
*/
public $droppedAt;
/**
* @var DateTime
*
* @JMS\Type("DateTime<'Y-m-d H:i:sP'>")
* @JMS\SerializedName("clearedAt")
*/
public $clearedAt;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("link")
*/
public $link;
/**
* @var \RetailCrm\Api\Model\Entity\CustomerInteraction\CartCustomer
*
* @JMS\Type("RetailCrm\Api\Model\Entity\CustomerInteraction\CartCustomer")
* @JMS\SerializedName("customer")
*/
public $customer;
/**
* @var \RetailCrm\Api\Model\Entity\CustomerInteraction\CartItem[]
*
* @JMS\Type("array<RetailCrm\Api\Model\Entity\CustomerInteraction\CartItem>")
* @JMS\SerializedName("items")
*/
public $items;
/**
* @var \RetailCrm\Api\Model\Entity\CustomerInteraction\CartOrder
*
* @JMS\Type("RetailCrm\Api\Model\Entity\CustomerInteraction\CartOrder")
* @JMS\SerializedName("order")
*/
public $order;
}

View file

@ -0,0 +1,61 @@
<?php
/**
* PHP version 7.3
*
* @category CartCustomer
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
namespace RetailCrm\Api\Model\Entity\CustomerInteraction;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class CartCustomer
*
* @category CartCustomer
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
class CartCustomer
{
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("id")
*/
public $id;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("externalId")
*/
public $externalId;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("browserId")
*/
public $browserId;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("site")
*/
public $site;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("gaClientId")
*/
public $gaClientId;
}

View file

@ -0,0 +1,53 @@
<?php
/**
* PHP version 7.3
*
* @category CartItem
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
namespace RetailCrm\Api\Model\Entity\CustomerInteraction;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class CartItem
*
* @category CartItem
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
class CartItem
{
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("id")
*/
public $id;
/**
* @var \RetailCrm\Api\Model\Entity\Orders\Items\Offer
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Orders\Items\Offer")
* @JMS\SerializedName("offer")
*/
public $offer;
/**
* @var float
*
* @JMS\Type("float")
* @JMS\SerializedName("quantity")
*/
public $quantity;
/**
* @var float
*
* @JMS\Type("float")
* @JMS\SerializedName("price")
*/
public $price;
}

View file

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.3
*
* @category CartOrder
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
namespace RetailCrm\Api\Model\Entity\CustomerInteraction;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class CartOrder
*
* @category CartOrder
* @package RetailCrm\Api\Model\Entity\CustomerInteraction
*/
class CartOrder
{
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("id")
*/
public $id;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("externalId")
*/
public $externalId;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("number")
*/
public $number;
}

View file

@ -369,6 +369,14 @@ class Customer implements CustomerInterface
*/
public $subscribed;
/**
* @var \RetailCrm\Api\Model\Entity\Customers\CustomerSubscription[]
*
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Customers\CustomerSubscription>")
* @JMS\SerializedName("customerSubscriptions")
*/
public $customerSubscriptions;
/**
* @var \RetailCrm\Api\Model\Entity\Customers\MGCustomer[]
*

View file

@ -0,0 +1,46 @@
<?php
/**
* PHP version 7.3
*
* @category CustomerSubscription
* @package RetailCrm\Api\Model\Entity\Customers
*/
namespace RetailCrm\Api\Model\Entity\Customers;
use DateTime;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class CustomerSubscription
*
* @category CustomerSubscription
* @package RetailCrm\Api\Model\Entity\Customers
*/
class CustomerSubscription
{
/**
* @var \RetailCrm\Api\Model\Entity\Customers\SubscriptionCategory
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Customers\SubscriptionCategory")
* @JMS\SerializedName("subscription")
*/
public $subscription;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("subscribed")
*/
public $subscribed;
/**
* @var DateTime
*
* @JMS\Type("DateTime<'Y-m-d H:i:s'>")
* @JMS\SerializedName("changedAt")
*/
public $changedAt;
}

View file

@ -0,0 +1,77 @@
<?php
/**
* PHP version 7.3
*
* @category SubscriptionCategory
* @package RetailCrm\Api\Model\Entity\Customers
*/
namespace RetailCrm\Api\Model\Entity\Customers;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class SubscriptionCategory
*
* @category SubscriptionCategory
* @package RetailCrm\Api\Model\Entity\Customers
*/
class SubscriptionCategory
{
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("id")
*/
public $id;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("channel")
*/
public $channel;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("name")
*/
public $name;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("code")
*/
public $code;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("active")
*/
public $active;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("autoSubscribe")
*/
public $autoSubscribe;
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("ordering")
*/
public $ordering;
}

View file

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.3
*
* @category EmbedJsConfiguration
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
*/
namespace RetailCrm\Api\Model\Entity\Integration\EmbedJs;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class EmbedJsConfiguration
*
* @category EmbedJsConfiguration
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
*/
class EmbedJsConfiguration
{
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("entrypoint")
*/
public $entrypoint;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("stylesheet")
*/
public $stylesheet;
/**
* @var string[]
*
* @JMS\Type("array<string>")
* @JMS\SerializedName("targets")
*/
public $targets;
}

View file

@ -74,4 +74,12 @@ class Integrations
* @JMS\SerializedName("mgBot")
*/
public $mgBot;
/**
* @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsConfiguration
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsConfiguration")
* @JMS\SerializedName("embedJs")
*/
public $embedJs;
}

View file

@ -43,6 +43,14 @@ class ApiUpdateInvoiceRequest
*/
public $amount;
/**
* @var float
*
* @JMS\Type("float")
* @JMS\SerializedName("discountAmount")
*/
public $discountAmount;
/**
* @var string
*

View file

@ -91,6 +91,14 @@ class Store
*/
public $phone;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("contact")
*/
public $contact;
/**
* @var string
*

View file

@ -0,0 +1,190 @@
<?php
/**
* PHP version 7.3
*
* @category OfferProduct
* @package RetailCrm\Api\Model\Entity\Store
*/
namespace RetailCrm\Api\Model\Entity\Store;
use DateTime;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class Product
*
* @category OfferProduct
* @package RetailCrm\Api\Model\Entity\Store
*/
class OfferProduct
{
/**
* @var float
*
* @JMS\Type("float")
* @JMS\SerializedName("minPrice")
*/
public $minPrice;
/**
* @var float
*
* @JMS\Type("float")
* @JMS\SerializedName("maxPrice")
*/
public $maxPrice;
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("id")
*/
public $id;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("article")
*/
public $article;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("name")
*/
public $name;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("url")
*/
public $url;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("imageUrl")
*/
public $imageUrl;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("description")
*/
public $description;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("popular")
*/
public $popular;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("stock")
*/
public $stock;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("novelty")
*/
public $novelty;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("recommended")
*/
public $recommended;
/**
* @var array<string, mixed>
*
* @JMS\Type("array")
* @JMS\SerializedName("properties")
*/
public $properties;
/**
* @var \RetailCrm\Api\Model\Entity\FixExternalRow[]
*
* @JMS\Type("array<RetailCrm\Api\Model\Entity\FixExternalRow>")
* @JMS\SerializedName("groups")
*/
public $groups;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("externalId")
*/
public $externalId;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("manufacturer")
*/
public $manufacturer;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("active")
*/
public $active;
/**
* @var float
*
* @JMS\Type("float")
* @JMS\SerializedName("quantity")
*/
public $quantity;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("markable")
*/
public $markable;
/**
* @var DateTime
*
* @JMS\Type("DateTime<'Y-m-d H:i:s'>")
* @JMS\SerializedName("updatedAt")
*/
public $updatedAt;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("type")
*/
public $type;
}

View file

@ -36,6 +36,14 @@ class Product
*/
public $maxPrice;
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("catalogId")
*/
public $catalogId;
/**
* @var int
*

View file

@ -170,4 +170,12 @@ class ProductOffer
* @JMS\SerializedName("barcode")
*/
public $barcode;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("site")
*/
public $site;
}

View file

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.3
*
* @category ProductPropertyValue
* @package RetailCrm\Api\Model\Entity\Store
*/
namespace RetailCrm\Api\Model\Entity\Store;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class ProductPropertyValue
*
* @category ProductPropertyValue
* @package RetailCrm\Api\Model\Entity\Store
*/
class ProductPropertyValue
{
/**
* @var \RetailCrm\Api\Model\Entity\Store\ProductProperty
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Store\ProductProperty")
* @JMS\SerializedName("property")
*/
public $property;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("value")
*/
public $value;
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("offersCount")
*/
public $offersCount;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.3
*
* @category StoreOffer
* @package RetailCrm\Api\Model\Entity\Store
*/
namespace RetailCrm\Api\Model\Entity\Store;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class StoreOffer
*
* @category StoreOffer
* @package RetailCrm\Api\Model\Entity\Store
*/
class StoreOffer extends ProductOffer
{
/**
* @JMS\Exclude()
*/
public $price;
/**
* @var \RetailCrm\Api\Model\Entity\Store\Product
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Store\Product")
* @JMS\SerializedName("product")
*/
public $product;
}

View file

@ -494,4 +494,12 @@ class CustomerFilter
* @Form\SerializedName("attachedTags")
*/
public $attachedTags;
/**
* @var \RetailCrm\Api\Model\Filter\Customers\CustomerSubscriptionFilter[]
*
* @Form\Type("array<RetailCrm\Api\Model\Filter\Customers\CustomerSubscriptionFilter>")
* @Form\SerializedName("subscriptions")
*/
public $subscriptions;
}

View file

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.3
*
* @category CustomerSubscriptionFilter
* @package RetailCrm\Api\Model\Filter\Customers
*/
namespace RetailCrm\Api\Model\Filter\Customers;
use RetailCrm\Api\Component\FormData\Mapping as Form;
/**
* Class CustomerSubscriptionFilter
*
* @category CustomerSubscriptionFilter
* @package RetailCrm\Api\Model\Filter\Customers
*/
class CustomerSubscriptionFilter
{
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("channel")
*/
public $channel;
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("subscription")
*/
public $subscription;
/**
* @var bool
*
* @Form\Type("bool")
* @Form\SerializedName("subscribed")
*/
public $subscribed;
}

View file

@ -357,4 +357,12 @@ class CustomerCorporateFilter
* @Form\SerializedName("companyName")
*/
public $companyName;
/**
* @var array<string, mixed>
*
* @Form\Type("array")
* @Form\SerializedName("customFields")
*/
public $customFields;
}

View file

@ -0,0 +1,142 @@
<?php
/**
* PHP version 7.3
*
* @category OfferFilterType
* @package RetailCrm\Api\Model\Filter\Store
*/
namespace RetailCrm\Api\Model\Filter\Store;
use DateTime;
use RetailCrm\Api\Component\FormData\Mapping as Form;
/**
* Class OfferFilterType
*
* @category OfferFilterType
* @package RetailCrm\Api\Model\Filter\Store
*/
class OfferFilterType
{
/**
* @var int[]
*
* @Form\Type("int[]")
* @Form\SerializedName("ids")
*/
public $ids;
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("name")
*/
public $name;
/**
* @var string
*
* @Form\Type("string[]")
* @Form\SerializedName("externalIds")
*/
public $externalIds;
/**
* @var string
*
* @Form\Type("string[]")
* @Form\SerializedName("xmlIds")
*/
public $xmlIds;
/**
* @var string[]
*
* @Form\Type("string[]")
* @Form\SerializedName("properties")
*/
public $properties;
/**
* @var string[]
*
* @Form\Type("string[]")
* @Form\SerializedName("sites")
*/
public $sites;
/**
* @var int[]
*
* @Form\Type("int[]")
* @Form\SerializedName("catalogs")
*/
public $catalogs;
/**
* @var int
*
* @Form\Type("int")
* @Form\SerializedName("active")
*/
public $active;
/**
* @var int
*
* @Form\Type("int")
* @Form\SerializedName("sinceId")
*/
public $sinceId;
/**
* @var int[]
*
* @Form\Type("int[]")
* @Form\SerializedName("groups")
*/
public $groups;
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("priceType")
*/
public $priceType;
/**
* @var int
*
* @Form\Type("int")
* @Form\SerializedName("minPrice")
*/
public $minPrice;
/**
* @var int
*
* @Form\Type("int")
* @Form\SerializedName("maxPrice")
*/
public $maxPrice;
/**
* @var int
*
* @Form\Type("int")
* @Form\SerializedName("minQuantity")
*/
public $minQuantity;
/**
* @var int
*
* @Form\Type("int")
* @Form\SerializedName("maxQuantity")
*/
public $maxQuantity;
}

View file

@ -37,81 +37,81 @@ class ProductFilterType
public $name;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("minPrice")
*/
public $minPrice;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("maxPrice")
*/
public $maxPrice;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("minPurchasePrice")
*/
public $minPurchasePrice;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("maxPurchasePrice")
*/
public $maxPurchasePrice;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("minQuantity")
*/
public $minQuantity;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("maxQuantity")
*/
public $maxQuantity;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("popular")
*/
public $popular;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("stock")
*/
public $stock;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("novelty")
*/
public $novelty;
/**
* @var string
* @var int
*
* @Form\Type("string")
* @Form\Type("int")
* @Form\SerializedName("recommended")
*/
public $recommended;
@ -124,6 +124,14 @@ class ProductFilterType
*/
public $url;
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("urlLike")
*/
public $urlLike;
/**
* @var string
*
@ -165,9 +173,9 @@ class ProductFilterType
public $offerIds;
/**
* @var string
* @var string[]
*
* @Form\Type("string")
* @Form\Type("string[]")
* @Form\SerializedName("properties")
*/
public $properties;

View file

@ -66,4 +66,12 @@ class ProductPropertiesFilterType
* @Form\SerializedName("catalogs")
*/
public $catalogs;
/**
* @var int[]
*
* @Form\Type("int[]")
* @Form\SerializedName("groups")
*/
public $groups;
}

View file

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.3
*
* @category ProductPropertyValuesFilterType
* @package RetailCrm\Api\Model\Filter\Store
*/
namespace RetailCrm\Api\Model\Filter\Store;
use RetailCrm\Api\Component\FormData\Mapping as Form;
/**
* Class ProductPropertyValuesFilterType
*
* @category ProductPropertyValuesFilterType
* @package RetailCrm\Api\Model\Filter\Store
*/
class ProductPropertyValuesFilterType
{
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("propertyName")
*/
public $propertyName;
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("propertyCode")
*/
public $propertyCode;
/**
* @var int[]
*
* @Form\Type("int[]")
* @Form\SerializedName("groups")
*/
public $groups;
}

View file

@ -0,0 +1,55 @@
<?php
/**
* PHP version 7.3
*
* @category ByAndSiteByRequest
* @package RetailCrm\Api\Model\Request
*/
namespace RetailCrm\Api\Model\Request;
use RetailCrm\Api\Component\FormData\Mapping as Form;
use RetailCrm\Api\Interfaces\RequestInterface;
/**
* Class ByAndSiteByRequest
*
* @category ByAndSiteByRequest
* @package RetailCrm\Api\Model\Request
*/
class ByAndSiteByRequest implements RequestInterface
{
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("by")
*/
public $by;
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("siteBy")
*/
public $siteBy;
/**
* BySiteRequest constructor.
*
* @param string $by
* @param string $siteBy
*/
public function __construct(string $by = '', string $siteBy = '')
{
if ('' !== $by) {
$this->by = $by;
}
if ('' !== $siteBy) {
$this->siteBy = $siteBy;
}
}
}

View file

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.3
*
* @category CustomerInteractionCartClearRequest
* @package RetailCrm\Api\Model\Request\CustomerInteraction
*/
namespace RetailCrm\Api\Model\Request\CustomerInteraction;
use RetailCrm\Api\Component\FormData\Mapping as Form;
use RetailCrm\Api\Interfaces\RequestInterface;
/**
* Class CustomerInteractionCartClearRequest
*
* @category CustomerInteractionCartClearRequest
* @package RetailCrm\Api\Model\Request\CustomerInteraction
*/
class CustomerInteractionCartClearRequest implements RequestInterface
{
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("siteBy")
*/
public $siteBy;
/**
* @var \RetailCrm\Api\Model\Entity\CustomerInteraction\Cart
*
* @Form\Type("RetailCrm\Api\Model\Entity\CustomerInteraction\Cart")
* @Form\SerializedName("cart")
* @Form\JsonField()
*/
public $cart;
}

View file

@ -0,0 +1,20 @@
<?php
/**
* PHP version 7.3
*
* @category CustomerInteractionCartSetRequest
* @package RetailCrm\Api\Model\Request\CustomerInteraction
*/
namespace RetailCrm\Api\Model\Request\CustomerInteraction;
/**
* Class CustomerInteractionCartSetRequest
*
* @category CustomerInteractionCartSetRequest
* @package RetailCrm\Api\Model\Request\CustomerInteraction
*/
class CustomerInteractionCartSetRequest extends CustomerInteractionCartClearRequest
{
}

View file

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.3
*
* @category LoyaltyBonusChargeRequest
* @package RetailCrm\Api\Model\Request\Loyalty
*/
namespace RetailCrm\Api\Model\Request\Loyalty;
use DateTime;
use RetailCrm\Api\Component\FormData\Mapping as Form;
use RetailCrm\Api\Interfaces\RequestInterface;
/**
* Class LoyaltyBonusChargeRequest
*
* @category LoyaltyBonusChargeRequest
* @package RetailCrm\Api\Model\Request\Loyalty
*/
class LoyaltyBonusChargeRequest implements RequestInterface
{
/**
* @var float
*
* @Form\Type("float")
* @Form\SerializedName("amount")
*/
public $amount;
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("comment")
*/
public $comment;
}

View file

@ -0,0 +1,33 @@
<?php
/**
* PHP version 7.3
*
* @category OffersRequest
* @package RetailCrm\Api\Model\Request\Store
*/
namespace RetailCrm\Api\Model\Request\Store;
use RetailCrm\Api\Component\FormData\Mapping as Form;
use RetailCrm\Api\Interfaces\RequestInterface;
use RetailCrm\Api\Model\Request\Traits\PageLimitTrait;
/**
* Class OffersRequest
*
* @category OffersRequest
* @package RetailCrm\Api\Model\Request\Store
*/
class OffersRequest implements RequestInterface
{
use PageLimitTrait;
/**
* @var \RetailCrm\Api\Model\Filter\Store\OfferFilterType
*
* @Form\Type("RetailCrm\Api\Model\Filter\Store\OfferFilterType")
* @Form\SerializedName("filter")
*/
public $filter;
}

View file

@ -23,6 +23,14 @@ class ProductPropertiesRequest implements RequestInterface
{
use PageLimitTrait;
/**
* @var ProductPropertiesSort
*
* @Form\Type("ProductPropertiesSort")
* @Form\SerializedName("sort")
*/
public $sort;
/**
* @var \RetailCrm\Api\Model\Filter\Store\ProductPropertiesFilterType
*

View file

@ -0,0 +1,31 @@
<?php
/**
* PHP version 7.3
*
* @category ProductPropertiesRequest
* @package RetailCrm\Api\Model\Request\Store
*/
namespace RetailCrm\Api\Model\Request\Store;
use RetailCrm\Api\Component\FormData\Mapping as Form;
use RetailCrm\Api\Interfaces\RequestInterface;
use RetailCrm\Api\Model\Request\Traits\PageLimitTrait;
/**
* Class ProductPropertiesSort
*
* @category ProductPropertiesRequest
* @package RetailCrm\Api\Model\Request\Store
*/
class ProductPropertiesSort implements RequestInterface
{
/**
* @var string
*
* @Form\Type("string")
* @Form\SerializedName("offersCount")
*/
public $offersCount;
}

View file

@ -0,0 +1,33 @@
<?php
/**
* PHP version 7.3
*
* @category ProductPropertyValuesRequest
* @package RetailCrm\Api\Model\Request\Store
*/
namespace RetailCrm\Api\Model\Request\Store;
use RetailCrm\Api\Component\FormData\Mapping as Form;
use RetailCrm\Api\Interfaces\RequestInterface;
use RetailCrm\Api\Model\Request\Traits\PageLimitTrait;
/**
* Class ProductPropertyValuesRequest
*
* @category ProductPropertyValuesRequest
* @package RetailCrm\Api\Model\Request\Store
*/
class ProductPropertyValuesRequest implements RequestInterface
{
use PageLimitTrait;
/**
* @var \RetailCrm\Api\Model\Filter\Store\ProductPropertyValuesFilterType
*
* @Form\Type("RetailCrm\Api\Model\Filter\Store\ProductPropertyValuesFilterType")
* @Form\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,30 @@
<?php
/**
* PHP version 7.3
*
* @category CustomerInteractionCartGetResponse
* @package RetailCrm\Api\Model\Response\CustomerInteraction
*/
namespace RetailCrm\Api\Model\Response\CustomerInteraction;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
use RetailCrm\Api\Model\Response\SuccessResponse;
/**
* Class CustomerInteractionCartGetResponse
*
* @category CustomerInteractionCartGetResponse
* @package RetailCrm\Api\Model\Response\CustomerInteraction
*/
class CustomerInteractionCartGetResponse extends SuccessResponse
{
/**
* @var \RetailCrm\Api\Model\Entity\CustomerInteraction\Cart
*
* @JMS\Type("RetailCrm\Api\Model\Entity\CustomerInteraction\Cart")
* @JMS\SerializedName("cart")
*/
public $cart;
}

View file

@ -0,0 +1,30 @@
<?php
/**
* PHP version 7.3
*
* @category OffersResponse
* @package RetailCrm\Api\Model\Response\Store
*/
namespace RetailCrm\Api\Model\Response\Store;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
use RetailCrm\Api\Model\Response\AbstractPaginatedResponse;
/**
* Class OffersResponse
*
* @category OffersResponse
* @package RetailCrm\Api\Model\Response\Store
*/
class OffersResponse extends AbstractPaginatedResponse
{
/**
* @var \RetailCrm\Api\Model\Entity\Store\StoreOffer[]
*
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Store\StoreOffer>")
* @JMS\SerializedName("offers")
*/
public $offers;
}

View file

@ -0,0 +1,31 @@
<?php
/**
* PHP version 7.3
*
* @category ProductPropertyValuesResponse
* @package RetailCrm\Api\Model\Response\Store
*/
namespace RetailCrm\Api\Model\Response\Store;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
use RetailCrm\Api\Model\Response\AbstractPaginatedResponse;
/**
* Class ProductPropertyValuesResponse
*
* @category ProductPropertyValuesResponse
* @package RetailCrm\Api\Model\Response\Store
* @SuppressWarnings(PHPMD.LongVariable)
*/
class ProductPropertyValuesResponse extends AbstractPaginatedResponse
{
/**
* @var \RetailCrm\Api\Model\Entity\Store\ProductPropertyValue[]
*
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Store\ProductPropertyValue>")
* @JMS\SerializedName("productPropertyValues")
*/
public $productPropertyValues;
}

View file

@ -0,0 +1,238 @@
<?php
/**
* PHP version 7.3
*
* @category CustomerInteraction
* @package RetailCrm\Api\ResourceGroup
*/
namespace RetailCrm\Api\ResourceGroup;
use RetailCrm\Api\Enum\RequestMethod;
use RetailCrm\Api\Model\Request\ByAndSiteByRequest;
use RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartClearRequest;
use RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartSetRequest;
use RetailCrm\Api\Model\Response\CustomerInteraction\CustomerInteractionCartGetResponse;
use RetailCrm\Api\Model\Response\SuccessResponse;
/**
* Class CustomerInteraction
*
* @category CustomerInteraction
* @package RetailCrm\Api\ResourceGroup
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CustomerInteraction extends AbstractApiResourceGroup
{
/**
* Makes POST "/api/v5/customer-interaction/{site}/cart/clear" request.
*
* Example:
* ```php
* use RetailCrm\Api\Enum\BySite;
* use RetailCrm\Api\Factory\SimpleClientFactory;
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
* use RetailCrm\Api\Model\Entity\CustomerInteraction\Cart;
* use RetailCrm\Api\Model\Entity\CustomerInteraction\CartCustomer;
* use RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartClearRequest;
*
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
*
* $cart = new Cart();
* $cart->clearedAt = new DateTime('now');
* $cart->customer = new CartCustomer();
* $cart->customer->id = 4770;
* $cart->customer->browserId = 'browserId';
* $cart->customer->gaClientId = 'gaClientId';
*
* $request = new CustomerInteractionCartClearRequest();
* $request->cart = $cart;
* $request->siteBy = BySite::CODE;
*
* try {
* $response = $client->customerInteraction->cartClear('testSite', $request);
* } catch (ApiExceptionInterface $exception) {
* echo sprintf(
* 'Error from RetailCRM API (status code: %d): %s',
* $exception->getStatusCode(),
* $exception->getMessage()
* );
*
* if (count($exception->getErrorResponse()->errors) > 0) {
* echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
* }
*
* return;
* }
* ```
*
* @param \RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartClearRequest $request
* @param string|int $site
*
* @return \RetailCrm\Api\Model\Response\SuccessResponse
* @throws \RetailCrm\Api\Interfaces\ApiExceptionInterface
* @throws \RetailCrm\Api\Interfaces\ClientExceptionInterface
* @throws \RetailCrm\Api\Exception\Api\AccountDoesNotExistException
* @throws \RetailCrm\Api\Exception\Api\ApiErrorException
* @throws \RetailCrm\Api\Exception\Api\MissingCredentialsException
* @throws \RetailCrm\Api\Exception\Api\MissingParameterException
* @throws \RetailCrm\Api\Exception\Api\ValidationException
* @throws \RetailCrm\Api\Exception\Client\HandlerException
* @throws \RetailCrm\Api\Exception\Client\HttpClientException
*/
public function cartClear(CustomerInteractionCartClearRequest $request, $site): SuccessResponse
{
/** @var SuccessResponse $response */
$response = $this->sendRequest(
RequestMethod::POST,
'customer-interaction/' . $site . '/cart/clear',
$request,
SuccessResponse::class
);
return $response;
}
/**
* Makes POST "/api/v5/customer-interaction/{site}/cart/set" request.
*
* Example:
* ```php
* use RetailCrm\Api\Enum\BySite;
* use RetailCrm\Api\Factory\SimpleClientFactory;
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
* use RetailCrm\Api\Model\Entity\CustomerInteraction\Cart;
* use RetailCrm\Api\Model\Entity\CustomerInteraction\CartCustomer;
* use RetailCrm\Api\Model\Entity\CustomerInteraction\CartItem;
* use RetailCrm\Api\Model\Entity\Orders\Items\Offer;
* use RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartSetRequest;
*
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
*
* $customer = new CartCustomer();
* $customer->id = 4770;
*
* $cartItem = new CartItem();
* $cartItem->price = 24.99;
* $cartItem->quantity = 2;
* $cartItem->offer = new Offer();
* $cartItem->offer->externalId = '47701234567890';
*
* $cart = new Cart();
* $cart->items[] = $cartItem;
* $cart->customer = $customer;
*
* $request = new CustomerInteractionCartSetRequest();
* $request->cart = $cart;
* $request->siteBy = BySite::CODE;
*
* try {
* $response = $client->customerInteraction->cartSet('testSite', $request);
* } catch (ApiExceptionInterface $exception) {
* echo sprintf(
* 'Error from RetailCRM API (status code: %d): %s',
* $exception->getStatusCode(),
* $exception->getMessage()
* );
*
* if (count($exception->getErrorResponse()->errors) > 0) {
* echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
* }
*
* return;
* }
* ```
*
* @param \RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartSetRequest $request
* @param string|int $site
*
* @return \RetailCrm\Api\Model\Response\SuccessResponse
* @throws \RetailCrm\Api\Interfaces\ApiExceptionInterface
* @throws \RetailCrm\Api\Interfaces\ClientExceptionInterface
* @throws \RetailCrm\Api\Exception\Api\AccountDoesNotExistException
* @throws \RetailCrm\Api\Exception\Api\ApiErrorException
* @throws \RetailCrm\Api\Exception\Api\MissingCredentialsException
* @throws \RetailCrm\Api\Exception\Api\MissingParameterException
* @throws \RetailCrm\Api\Exception\Api\ValidationException
* @throws \RetailCrm\Api\Exception\Client\HandlerException
* @throws \RetailCrm\Api\Exception\Client\HttpClientException
*/
public function cartSet(CustomerInteractionCartSetRequest $request, $site): SuccessResponse
{
/** @var SuccessResponse $response */
$response = $this->sendRequest(
RequestMethod::POST,
'customer-interaction/' . $site . '/cart/set',
$request,
SuccessResponse::class
);
return $response;
}
/**
* Makes GET "/api/v5/customer-interaction/{site}/cart/{customerId}" request.
*
* Example:
* ```php
* use RetailCrm\Api\Enum\ByIdentifier;
* use RetailCrm\Api\Enum\BySite;
* use RetailCrm\Api\Factory\SimpleClientFactory;
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
* use RetailCrm\Api\Model\Request\ByAndSiteByRequest;
*
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
*
* try {
* $response = $client->customerInteraction->cartGet(
* 'testSite',
* 4200,
* new ByAndSiteByRequest(ByIdentifier::ID, BySite::CODE)
* );
* } catch (ApiExceptionInterface $exception) {
* echo sprintf(
* 'Error from RetailCRM API (status code: %d): %s',
* $exception->getStatusCode(),
* $exception->getMessage()
* );
*
* if (count($exception->getErrorResponse()->errors) > 0) {
* echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
* }
*
* return;
* }
*
* echo 'Cart: ' . print_r($response->cart, true);
* ```
*
* @param string|int $site
* @param string|int $customerId
* @param \RetailCrm\Api\Model\Request\ByAndSiteByRequest|null $request
*
* @return \RetailCrm\Api\Model\Response\CustomerInteraction\CustomerInteractionCartGetResponse
* @throws \RetailCrm\Api\Interfaces\ApiExceptionInterface
* @throws \RetailCrm\Api\Interfaces\ClientExceptionInterface
* @throws \RetailCrm\Api\Exception\Api\AccountDoesNotExistException
* @throws \RetailCrm\Api\Exception\Api\ApiErrorException
* @throws \RetailCrm\Api\Exception\Api\MissingCredentialsException
* @throws \RetailCrm\Api\Exception\Api\MissingParameterException
* @throws \RetailCrm\Api\Exception\Api\ValidationException
* @throws \RetailCrm\Api\Exception\Client\HandlerException
* @throws \RetailCrm\Api\Exception\Client\HttpClientException
*/
public function cartGet(
$site,
$customerId,
?ByAndSiteByRequest $request = null
): CustomerInteractionCartGetResponse {
/** @var CustomerInteractionCartGetResponse $response */
$response = $this->sendRequest(
RequestMethod::GET,
'customer-interaction/' . $site . '/cart/' . $customerId,
$request,
CustomerInteractionCartGetResponse::class
);
return $response;
}
}

View file

@ -16,6 +16,7 @@ use RetailCrm\Api\Model\Request\Loyalty\LoyaltiesRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyAccountCreateRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyAccountEditRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyAccountsRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusChargeRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusCreditRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusOperationsRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyCalculateRequest;
@ -30,6 +31,7 @@ use RetailCrm\Api\Model\Response\Loyalty\LoyaltyBonusCreditResponse;
use RetailCrm\Api\Model\Response\Loyalty\LoyaltyBonusOperationsResponse;
use RetailCrm\Api\Model\Response\Loyalty\LoyaltyCalculateResponse;
use RetailCrm\Api\Model\Response\Loyalty\LoyaltyResponse;
use RetailCrm\Api\Model\Response\SuccessResponse;
/**
* Class Loyalty
@ -163,6 +165,66 @@ class Loyalty extends AbstractApiResourceGroup
return $response;
}
/**
* Makes POST "/api/v5/loyalty/account/{id}/bonus/charge" request.
*
* Example:
* ```php
* use RetailCrm\Api\Factory\SimpleClientFactory;
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
* use RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusChargeRequest;
*
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
*
* $request = new LoyaltyBonusChargeRequest();
* $request->amount = 100;
* $request->comment = 'Payment for the goods.';
*
* try {
* $response = $client->loyalty->accountBonusCharge(159, $request);
* } catch (ApiExceptionInterface $exception) {
* echo sprintf(
* 'Error from RetailCRM API (status code: %d): %s',
* $exception->getStatusCode(),
* $exception->getMessage()
* );
*
* if (count($exception->getErrorResponse()->errors) > 0) {
* echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
* }
*
* return;
* }
*
* echo 'Status: ' . var_export($response->success, true);
* ```
*
* @param int $id
* @param \RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusChargeRequest $request
*
* @return \RetailCrm\Api\Model\Response\Loyalty\LoyaltyBonusCreditResponse
* @throws \RetailCrm\Api\Exception\Api\AccountDoesNotExistException
* @throws \RetailCrm\Api\Exception\Api\ApiErrorException
* @throws \RetailCrm\Api\Exception\Api\MissingCredentialsException
* @throws \RetailCrm\Api\Exception\Api\MissingParameterException
* @throws \RetailCrm\Api\Exception\Api\ValidationException
* @throws \RetailCrm\Api\Exception\Client\HandlerException
* @throws \RetailCrm\Api\Exception\Client\HttpClientException
* @throws \RetailCrm\Api\Interfaces\ApiExceptionInterface
* @throws \RetailCrm\Api\Interfaces\ClientExceptionInterface
*/
public function accountBonusCharge(int $id, LoyaltyBonusChargeRequest $request): SuccessResponse
{
/** @var LoyaltyBonusCreditResponse $response */
$response = $this->sendRequest(
RequestMethod::POST,
'loyalty/account/' . $id . '/bonus/charge',
$request,
SuccessResponse::class
);
return $response;
}
/**
* Makes POST "/api/v5/loyalty/account/{id}/bonus/credit" request.
*

View file

@ -12,21 +12,25 @@ namespace RetailCrm\Api\ResourceGroup;
use RetailCrm\Api\Enum\RequestMethod;
use RetailCrm\Api\Model\Request\Store\InventoriesRequest;
use RetailCrm\Api\Model\Request\Store\InventoriesUploadRequest;
use RetailCrm\Api\Model\Request\Store\OffersRequest;
use RetailCrm\Api\Model\Request\Store\PricesUploadRequest;
use RetailCrm\Api\Model\Request\Store\ProductBatchEditRequest;
use RetailCrm\Api\Model\Request\Store\ProductGroupsCreateRequest;
use RetailCrm\Api\Model\Request\Store\ProductGroupsEditRequest;
use RetailCrm\Api\Model\Request\Store\ProductGroupsRequest;
use RetailCrm\Api\Model\Request\Store\ProductPropertiesRequest;
use RetailCrm\Api\Model\Request\Store\ProductPropertyValuesRequest;
use RetailCrm\Api\Model\Request\Store\ProductsBatchCreateRequest;
use RetailCrm\Api\Model\Request\Store\ProductsRequest;
use RetailCrm\Api\Model\Response\IdResponse;
use RetailCrm\Api\Model\Response\Store\InventoriesResponse;
use RetailCrm\Api\Model\Response\Store\InventoriesUploadResponse;
use RetailCrm\Api\Model\Response\Store\OffersResponse;
use RetailCrm\Api\Model\Response\Store\PricesUploadResponse;
use RetailCrm\Api\Model\Response\Store\ProductBatchEditResponse;
use RetailCrm\Api\Model\Response\Store\ProductGroupsResponse;
use RetailCrm\Api\Model\Response\Store\ProductPropertiesResponse;
use RetailCrm\Api\Model\Response\Store\ProductPropertyValuesResponse;
use RetailCrm\Api\Model\Response\Store\ProductsBatchCreateResponse;
use RetailCrm\Api\Model\Response\Store\ProductsResponse;
@ -690,4 +694,126 @@ class Store extends AbstractApiResourceGroup
return $response;
}
/**
* Makes GET "/api/v5/store/offers" request.
*
* Example:
* ```php
* use RetailCrm\Api\Enum\NumericBoolean;
* use RetailCrm\Api\Factory\SimpleClientFactory;
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
* use RetailCrm\Api\Model\Filter\Store\OfferFilterType;
* use RetailCrm\Api\Model\Request\Store\OffersRequest;
*
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
*
* $request = new OffersRequest();
* $request->filter = new OfferFilterType();
* $request->filter->active = NumericBoolean::TRUE;
* $request->filter->name = 'Test Offer';
*
* try {
* $response = $client->store->offers($request);
* } catch (ApiExceptionInterface $exception) {
* echo sprintf(
* 'Error from RetailCRM API (status code: %d): %s',
* $exception->getStatusCode(),
* $exception->getMessage()
* );
*
* if (count($exception->getErrorResponse()->errors) > 0) {
* echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
* }
*
* return;
* }
*
* echo 'Offers: ' . print_r($response->offers, true);
* ```
*
* @param \RetailCrm\Api\Model\Request\Store\OffersRequest|null $request
*
* @return \RetailCrm\Api\Model\Response\Store\OffersResponse
* @throws \RetailCrm\Api\Interfaces\ApiExceptionInterface
* @throws \RetailCrm\Api\Interfaces\ClientExceptionInterface
* @throws \RetailCrm\Api\Exception\Api\AccountDoesNotExistException
* @throws \RetailCrm\Api\Exception\Api\ApiErrorException
* @throws \RetailCrm\Api\Exception\Api\MissingCredentialsException
* @throws \RetailCrm\Api\Exception\Api\MissingParameterException
* @throws \RetailCrm\Api\Exception\Api\ValidationException
* @throws \RetailCrm\Api\Exception\Client\HandlerException
* @throws \RetailCrm\Api\Exception\Client\HttpClientException
*/
public function offers(?OffersRequest $request = null): OffersResponse
{
/** @var OffersResponse $response */
$response = $this->sendRequest(
RequestMethod::GET,
'store/offers',
$request,
OffersResponse::class
);
return $response;
}
/**
* Makes GET "/api/v5/store/products/properties/values" request.
*
* Example:
* ```php
* use RetailCrm\Api\Factory\SimpleClientFactory;
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
* use RetailCrm\Api\Model\Filter\Store\ProductPropertiesFilterType;
* use RetailCrm\Api\Model\Request\Store\ProductPropertiesRequest;
*
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
*
* $request = new ProductPropertyValuesRequest();
* $request->filter = new ProductPropertyValuesFilterType();
* $request->filter->propertyCode = 'property_code';
*
* try {
* $response = $client->store->productsPropertyValues($request);
* } catch (ApiExceptionInterface $exception) {
* echo sprintf(
* 'Error from RetailCRM API (status code: %d): %s',
* $exception->getStatusCode(),
* $exception->getMessage()
* );
*
* if (count($exception->getErrorResponse()->errors) > 0) {
* echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
* }
*
* return;
* }
*
* echo 'Product property values: ' . print_r($response->productPropertyValues, true);
* ```
*
* @param \RetailCrm\Api\Model\Request\Store\ProductPropertyValuesRequest|null $request
*
* @return \RetailCrm\Api\Model\Response\Store\ProductPropertyValuesResponse
* @throws \RetailCrm\Api\Interfaces\ApiExceptionInterface
* @throws \RetailCrm\Api\Interfaces\ClientExceptionInterface
* @throws \RetailCrm\Api\Exception\Api\AccountDoesNotExistException
* @throws \RetailCrm\Api\Exception\Api\ApiErrorException
* @throws \RetailCrm\Api\Exception\Api\MissingCredentialsException
* @throws \RetailCrm\Api\Exception\Api\MissingParameterException
* @throws \RetailCrm\Api\Exception\Api\ValidationException
* @throws \RetailCrm\Api\Exception\Client\HandlerException
* @throws \RetailCrm\Api\Exception\Client\HttpClientException
*/
public function productsPropertyValues(?ProductPropertyValuesRequest $request = null): ProductPropertyValuesResponse
{
/** @var ProductPropertyValuesResponse $response */
$response = $this->sendRequest(
RequestMethod::GET,
'store/products/properties/values',
$request,
ProductPropertyValuesResponse::class
);
return $response;
}
}

View file

@ -27,7 +27,7 @@ trait EventDispatcherAwareTrait
*
* @param \Psr\EventDispatcher\EventDispatcherInterface|null $eventDispatcher
*
* @return object
* @return static
*/
public function setEventDispatcher(?EventDispatcherInterface $eventDispatcher): object
{

View file

@ -0,0 +1,138 @@
<?php
namespace RetailCrm\Tests\ResourceGroup;
use DateTime;
use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Enum\BySite;
use RetailCrm\Api\Enum\RequestMethod;
use RetailCrm\Api\Model\Entity\CustomerInteraction\Cart;
use RetailCrm\Api\Model\Entity\CustomerInteraction\CartCustomer;
use RetailCrm\Api\Model\Entity\CustomerInteraction\CartItem;
use RetailCrm\Api\Model\Entity\Orders\Items\Offer;
use RetailCrm\Api\Model\Request\ByAndSiteByRequest;
use RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartClearRequest;
use RetailCrm\Api\Model\Request\CustomerInteraction\CustomerInteractionCartSetRequest;
use RetailCrm\TestUtils\Factory\TestClientFactory;
use RetailCrm\TestUtils\TestCase\AbstractApiResourceGroupTestCase;
class CustomerInteractionTest extends AbstractApiResourceGroupTestCase
{
public static function testCustomerInteractionCartClear(): void
{
$json = <<<'EOF'
{
"success": true
}
EOF;
$cart = new Cart();
$cart->clearedAt = new DateTime('now');
$cart->customer = new CartCustomer();
$cart->customer->id = 4770;
$cart->customer->browserId = 'browserId';
$cart->customer->gaClientId = 'gaClientId';
$request = new CustomerInteractionCartClearRequest();
$request->cart = $cart;
$request->siteBy = BySite::CODE;
$mock = static::createApiMockBuilder('customer-interaction/testSite/cart/clear');
$mock->matchMethod(RequestMethod::POST)
->matchPath('/api/v5/customer-interaction/testSite/cart/clear')
->matchBody(static::encodeForm($request))
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->customerInteraction->cartClear($request, 'testSite');
self::assertModelEqualsToResponse($json, $response);
}
public static function testCustomerInteractionCartSet(): void
{
$json = <<<'EOF'
{
"success": true
}
EOF;
$customer = new CartCustomer();
$customer->id = 4770;
$cartItem = new CartItem();
$cartItem->price = 24.99;
$cartItem->quantity = 2;
$cartItem->offer = new Offer();
$cartItem->offer->externalId = '47701234567890';
$cart = new Cart();
$cart->items[] = $cartItem;
$cart->customer = $customer;
$request = new CustomerInteractionCartSetRequest();
$request->cart = $cart;
$request->siteBy = BySite::CODE;
$mock = static::createApiMockBuilder('customer-interaction/testSite/cart/set');
$mock->matchMethod(RequestMethod::POST)
->matchPath('/api/v5/customer-interaction/testSite/cart/set')
->matchBody(static::encodeForm($request))
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->customerInteraction->cartSet($request, 'testSite');
self::assertModelEqualsToResponse($json, $response);
}
public static function testCustomerInteractionCartGet(): void
{
$json = <<<'EOF'
{
"success": true,
"cart": {
"externalId": "12345678901234",
"droppedAt": "2024-05-08 15:10:30-05:00",
"link": "https:/shop.myshopify.com/recover?key=1234",
"items": [
{
"id": "1",
"offer": {
"displayName": "Some sample product",
"id": 11,
"externalId": "01234567890123",
"name": "Some sample product",
"vatRate": "20.00",
"properties": [],
"unit": {
"code": "pc",
"name": "Piece",
"sym": "pc"
}
},
"quantity": 2,
"price": 24.99
}
],
"currency": "EUR"
}
}
EOF;
$request = new ByAndSiteByRequest(ByIdentifier::ID, BySite::CODE);
$mock = static::createApiMockBuilder('customer-interaction/testSite/cart/4770');
$mock->matchMethod(RequestMethod::GET)
->matchPath('/api/v5/customer-interaction/testSite/cart/4770')
->matchQuery(static::encodeFormArray($request))
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->customerInteraction->cartGet('testSite', 4770, $request);
self::assertModelEqualsToResponse($json, $response);
}
}

View file

@ -180,6 +180,33 @@ class CustomersTest extends AbstractApiResourceGroupTestCase
"number": "89229112322"
}
],
"customerSubscriptions": [
{
"subscription": {
"id": 2,
"channel": "email",
"name": "Без тематики",
"code": "default_marketing",
"active": true,
"autoSubscribe": true,
"ordering": 1
},
"subscribed": true
},
{
"subscription": {
"id": 4,
"channel": "waba",
"name": "Без тематики",
"code": "default_marketing",
"active": true,
"autoSubscribe": true,
"ordering": 1
},
"subscribed": false,
"changedAt": "2024-12-17 11:50:43"
}
],
"mgCustomers": [
{
"id": 1,
@ -2670,6 +2697,33 @@ EOF;
"number": "+79094055044"
}
],
"customerSubscriptions": [
{
"subscription": {
"id": 2,
"channel": "email",
"name": "Без тематики",
"code": "default_marketing",
"active": true,
"autoSubscribe": true,
"ordering": 1
},
"subscribed": true
},
{
"subscription": {
"id": 4,
"channel": "waba",
"name": "Без тематики",
"code": "default_marketing",
"active": true,
"autoSubscribe": true,
"ordering": 1
},
"subscribed": false,
"changedAt": "2024-12-17 11:50:43"
}
],
"mgCustomers": [
{
"id": 1,

View file

@ -38,6 +38,7 @@ use RetailCrm\Api\Model\Request\Loyalty\LoyaltiesRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyAccountCreateRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyAccountEditRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyAccountsRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusChargeRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusCreditRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyBonusOperationsRequest;
use RetailCrm\Api\Model\Request\Loyalty\LoyaltyCalculateRequest;
@ -121,6 +122,29 @@ EOF;
self::assertModelEqualsToResponse($json, $response);
}
public function testAccountBonusCharge(): void
{
$json = <<<EOF
{
"success": true
}
EOF;
$request = new LoyaltyBonusChargeRequest();
$request->amount = 100;
$request->comment = 'Monthly membership bonuses.';
$mock = static::createApiMockBuilder('loyalty/account/159/bonus/charge');
$mock->matchMethod(RequestMethod::POST)
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->loyalty->accountBonusCharge(159, $request);
self::assertModelEqualsToResponse($json, $response);
}
public function testAccountBonusCredit(): void
{
$activationDate = new DateTime();

View file

@ -99,6 +99,7 @@ EOF;
$invoiceRequest->paymentId = 'd6458333-fff3-4fd0-9b23-4e6344451f8e';
$invoiceRequest->invoiceUuid = '5b1b2e9d-b7f1-48f4-acb9-4bfce04b30cf';
$invoiceRequest->invoiceUrl = 'https://example.com/newUrl';
$invoiceRequest->discountAmount = 20.0;
$request = new PaymentUpdateInvoiceRequest($invoiceRequest);

View file

@ -22,17 +22,22 @@ use RetailCrm\Api\Model\Entity\Store\ProductEditGroupInput;
use RetailCrm\Api\Model\Entity\Store\ProductEditInput;
use RetailCrm\Api\Model\Entity\Store\SerializedProductGroup;
use RetailCrm\Api\Model\Filter\Store\InventoryFilterType;
use RetailCrm\Api\Model\Filter\Store\OfferFilterType;
use RetailCrm\Api\Model\Filter\Store\ProductFilterType;
use RetailCrm\Api\Model\Filter\Store\ProductGroupFilterType;
use RetailCrm\Api\Model\Filter\Store\ProductPropertiesFilterType;
use RetailCrm\Api\Model\Filter\Store\ProductPropertyValuesFilterType;
use RetailCrm\Api\Model\Request\Store\InventoriesRequest;
use RetailCrm\Api\Model\Request\Store\InventoriesUploadRequest;
use RetailCrm\Api\Model\Request\Store\OffersRequest;
use RetailCrm\Api\Model\Request\Store\PricesUploadRequest;
use RetailCrm\Api\Model\Request\Store\ProductBatchEditRequest;
use RetailCrm\Api\Model\Request\Store\ProductGroupsCreateRequest;
use RetailCrm\Api\Model\Request\Store\ProductGroupsEditRequest;
use RetailCrm\Api\Model\Request\Store\ProductGroupsRequest;
use RetailCrm\Api\Model\Request\Store\ProductPropertiesRequest;
use RetailCrm\Api\Model\Request\Store\ProductPropertiesSort;
use RetailCrm\Api\Model\Request\Store\ProductPropertyValuesRequest;
use RetailCrm\Api\Model\Request\Store\ProductsBatchCreateRequest;
use RetailCrm\Api\Model\Request\Store\ProductsRequest;
use RetailCrm\TestUtils\Factory\TestClientFactory;
@ -446,7 +451,7 @@ EOF;
$request->filter = new ProductFilterType();
$request->filter->active = NumericBoolean::TRUE;
$request->filter->priceType = 'base';
$request->filter->maxPrice = '10000';
$request->filter->maxPrice = 10000;
$request->filter->name = 'Test Product';
$mock = static::createApiMockBuilder('store/products');
@ -548,7 +553,7 @@ EOF;
$request->filter = new ProductFilterType();
$request->filter->active = NumericBoolean::TRUE;
$request->filter->priceType = 'base';
$request->filter->maxPrice = '10000';
$request->filter->maxPrice = 10000;
$request->filter->name = 'Test Product';
$request->filter->sinceId = 828272;
$request->filter->sinceUpdatedAt = DateTimeTransformer::create('2020-01-01 00:00:00');
@ -616,10 +621,14 @@ EOF;
EOF;
$request = new ProductPropertiesRequest();
$request->sort = new ProductPropertiesSort();
$request->sort->offersCount = 'desc';
$request->filter = new ProductPropertiesFilterType();
$request->filter->sites = ['moysklad', 'aliexpress'];
$request->filter->visible = NumericBoolean::TRUE;
$request->filter->variative = NumericBoolean::TRUE;
$request->filter->groups = [3676, 3679, 3680, 3724];
$mock = static::createApiMockBuilder('store/products/properties');
$mock->matchMethod(RequestMethod::GET)
@ -778,4 +787,186 @@ EOF;
self::assertModelEqualsToResponse($json, $response);
}
public function testProductPropertyValues(): void
{
$json = <<<'EOF'
{
"success": true,
"pagination": {
"limit": 20,
"totalCount": 1,
"currentPage": 1,
"totalPageCount": 1
},
"productPropertyValues": [
{
"property": {
"sites": [
"e-mapper",
"sendpulse",
"glavpunkt",
"retailcrm-services-peshkariki",
"vk-com",
"moysklad",
"eftestshop-ru"
],
"groups": [
{
"id": 3676,
"name": "warehouseRoot"
},
{
"id": 3679,
"name": "Входящая в группу"
},
{
"id": 3680,
"name": "test"
},
{
"id": 3724,
"name": "Услуги"
}
],
"code": "code",
"name": "Код",
"isNumeric": false,
"visible": true,
"variative": true
},
"value": "testValue",
"offersCount": 10
}
]
}
EOF;
$request = new ProductPropertyValuesRequest();
$request->filter = new ProductPropertyValuesFilterType();
$request->filter->propertyName = "testName";
$request->filter->propertyCode = "testCode";
$request->filter->groups = [1, 2, 3];
$mock = static::createApiMockBuilder('store/products/properties/values');
$mock->matchMethod(RequestMethod::GET)
->matchQuery(self::encodeFormArray($request))
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->store->productsPropertyValues($request);
self::assertModelEqualsToResponse($json, $response);
}
public function testOffers(): void
{
$json = <<<'EOF'
{
"success": true,
"pagination": {
"limit": 20,
"totalCount": 1,
"currentPage": 1,
"totalPageCount": 1
},
"offers": [
{
"name": "Test Offer",
"images": [
"https://example.com/image.jpg"
],
"id": 1941833,
"externalId": "38311",
"xmlId": "38311",
"article": "38311",
"prices": [
{
"priceType": "base",
"price": 624,
"ordering": 991
}
],
"purchasePrice": 272.64,
"vatRate": "none",
"properties": {
"ves": "33",
"brend": "Test",
"image": "https://example.com/image.jpg",
"ves_g": "33",
"artikul": "38311"
},
"quantity": 0.0,
"weight": 33.0,
"active": true,
"unit": {
"code": "pc",
"name": "Штука",
"sym": "шт."
},
"product": {
"minPrice": 624,
"maxPrice": 624,
"id": 828272,
"article": "38311",
"type": "product",
"name": "Test Product",
"url": "https://example.com",
"imageUrl": "https://example.com/image.jpg",
"description": "Test Description",
"groups": [
{
"id": 4050,
"externalId": "368"
},
{
"id": 4154,
"externalId": "391"
},
{
"id": 4279,
"externalId": "394"
}
],
"externalId": "38311",
"manufacturer": "Test",
"active": true,
"quantity": 0,
"markable": false
}
}
]
}
EOF;
$request = new OffersRequest();
$request->filter = new OfferFilterType();
$request->filter->active = NumericBoolean::TRUE;
$request->filter->minPrice = 1;
$request->filter->maxPrice = 120000;
$request->filter->sites = ['main'];
$request->filter->maxQuantity = 5;
$request->filter->catalogs = [2];
$mock = static::createApiMockBuilder('store/offers');
$mock->matchMethod(RequestMethod::GET)
->matchQuery([
'filter' => [
'sites' => ['main'],
'catalogs' => ['2'],
'active' => '1',
'minPrice' => '1',
'maxPrice' => '120000',
'maxQuantity' => '5',
]
])
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->store->offers($request);
self::assertModelEqualsToResponse($json, $response);
}
}