Add functionality from recent updates to the library
This commit is contained in:
parent
6515e39144
commit
2b02c0e116
@ -116,4 +116,12 @@ class SerializedLoyaltyOrder
|
|||||||
* @JMS\SerializedName("items")
|
* @JMS\SerializedName("items")
|
||||||
*/
|
*/
|
||||||
public $items;
|
public $items;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("currency")
|
||||||
|
*/
|
||||||
|
public $currency;
|
||||||
}
|
}
|
||||||
|
39
src/Model/Entity/Orders/LinkedOrder.php
Normal file
39
src/Model/Entity/Orders/LinkedOrder.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category LinkedOrder
|
||||||
|
* @package RetailCrm\Api\Model\Entity\Orders
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RetailCrm\Api\Model\Entity\Orders;
|
||||||
|
|
||||||
|
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
|
||||||
|
|
||||||
|
class LinkedOrder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
@ -416,6 +416,14 @@ class Order
|
|||||||
*/
|
*/
|
||||||
public $payments;
|
public $payments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \RetailCrm\Api\Model\Entity\Orders\OrderLink[]
|
||||||
|
*
|
||||||
|
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Orders\OrderLink>")
|
||||||
|
* @JMS\SerializedName("links")
|
||||||
|
*/
|
||||||
|
public $links;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*
|
*
|
||||||
|
40
src/Model/Entity/Orders/OrderLink.php
Normal file
40
src/Model/Entity/Orders/OrderLink.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category OrderLink
|
||||||
|
* @package RetailCrm\Api\Model\Entity\Orders
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RetailCrm\Api\Model\Entity\Orders;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
|
||||||
|
|
||||||
|
class OrderLink
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("comment")
|
||||||
|
*/
|
||||||
|
public $comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \RetailCrm\Api\Model\Entity\Orders\LinkedOrder
|
||||||
|
*
|
||||||
|
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Delivery\SerializedEntityOrder>")
|
||||||
|
* @JMS\SerializedName("order")
|
||||||
|
*/
|
||||||
|
public $order;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DateTime
|
||||||
|
*
|
||||||
|
* @JMS\Type("DateTime<'Y-m-d H:i:s'>")
|
||||||
|
* @JMS\SerializedName("createdAt")
|
||||||
|
*/
|
||||||
|
public $createdAt;
|
||||||
|
}
|
@ -75,6 +75,14 @@ class PriceType
|
|||||||
*/
|
*/
|
||||||
public $filterExpression;
|
public $filterExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("currency")
|
||||||
|
*/
|
||||||
|
public $currency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \RetailCrm\Api\Model\Entity\References\GeoHierarchyRow[]
|
* @var \RetailCrm\Api\Model\Entity\References\GeoHierarchyRow[]
|
||||||
*
|
*
|
||||||
|
@ -42,4 +42,12 @@ class OfferPrice
|
|||||||
* @JMS\SerializedName("ordering")
|
* @JMS\SerializedName("ordering")
|
||||||
*/
|
*/
|
||||||
public $ordering;
|
public $ordering;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("currency")
|
||||||
|
*/
|
||||||
|
public $currency;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,14 @@ class User
|
|||||||
*/
|
*/
|
||||||
public $patronymic;
|
public $patronymic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("position")
|
||||||
|
*/
|
||||||
|
public $position;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
|
@ -512,6 +512,14 @@ class OrderFilter
|
|||||||
*/
|
*/
|
||||||
public $deliveryTypes;
|
public $deliveryTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
*
|
||||||
|
* @Form\Type("string[]")
|
||||||
|
* @Form\SerializedName("deliveryServices")
|
||||||
|
*/
|
||||||
|
public $deliveryServices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*
|
*
|
||||||
|
@ -15,6 +15,7 @@ use RetailCrm\Api\Model\Request\WebAnalytics\SourcesUploadRequest;
|
|||||||
use RetailCrm\Api\Model\Response\WebAnalytics\ClientIdUploadResponse;
|
use RetailCrm\Api\Model\Response\WebAnalytics\ClientIdUploadResponse;
|
||||||
use RetailCrm\Api\Model\Response\WebAnalytics\SourcesUploadResponse;
|
use RetailCrm\Api\Model\Response\WebAnalytics\SourcesUploadResponse;
|
||||||
|
|
||||||
|
// TODO комментарий + тест
|
||||||
/**
|
/**
|
||||||
* Class WebAnalytics
|
* Class WebAnalytics
|
||||||
*
|
*
|
||||||
@ -26,6 +27,56 @@ use RetailCrm\Api\Model\Response\WebAnalytics\SourcesUploadResponse;
|
|||||||
class WebAnalytics extends AbstractApiResourceGroup
|
class WebAnalytics extends AbstractApiResourceGroup
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* Makes POST "/api/v5/web-analytics/client-ids/upload" request.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ```php
|
||||||
|
* use RetailCrm\Api\Factory\SimpleClientFactory;
|
||||||
|
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
|
||||||
|
* use RetailCrm\Api\Model\Entity\WebAnalytics\Customer;
|
||||||
|
* use RetailCrm\Api\Model\Entity\WebAnalytics\Order;
|
||||||
|
* use RetailCrm\Api\Model\Entity\WebAnalytics\Source;
|
||||||
|
* use RetailCrm\Api\Model\Request\WebAnalytics\SourcesUploadRequest;
|
||||||
|
*
|
||||||
|
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
|
||||||
|
*
|
||||||
|
* $entity = new Source();
|
||||||
|
* $entity->source = "sourse";
|
||||||
|
* $entity->medium = "medium";
|
||||||
|
* $entity->campaign = "campaign";
|
||||||
|
* $entity->keyword = "keyword";
|
||||||
|
* $entity->content = "content";
|
||||||
|
* $entity->clientId = "10";
|
||||||
|
* $entity->order = new Order();
|
||||||
|
* $entity->order->id = 10;
|
||||||
|
* $entity->order->externalId = "externalId";
|
||||||
|
* $entity->order->number = "number";
|
||||||
|
* $entity->customer = new Customer();
|
||||||
|
* $entity->customer->id = 10;
|
||||||
|
* $entity->customer->externalId = 'externalId';
|
||||||
|
*
|
||||||
|
* $request = new SourcesUploadRequest([$entity]);
|
||||||
|
*
|
||||||
|
* try {
|
||||||
|
* $response = $client->webAnalytics->sourcesUpload($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 'Upload is successful';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
* @param \RetailCrm\Api\Model\Request\WebAnalytics\SourcesUploadRequest $request
|
* @param \RetailCrm\Api\Model\Request\WebAnalytics\SourcesUploadRequest $request
|
||||||
*
|
*
|
||||||
* @return \RetailCrm\Api\Model\Response\WebAnalytics\SourcesUploadResponse
|
* @return \RetailCrm\Api\Model\Response\WebAnalytics\SourcesUploadResponse
|
||||||
@ -53,6 +104,51 @@ class WebAnalytics extends AbstractApiResourceGroup
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* Makes POST "/api/v5/web-analytics/client-ids/upload" request.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ```php
|
||||||
|
* use RetailCrm\Api\Factory\SimpleClientFactory;
|
||||||
|
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
|
||||||
|
* use RetailCrm\Api\Model\Entity\WebAnalytics\ClientId;
|
||||||
|
* use RetailCrm\Api\Model\Entity\WebAnalytics\Customer;
|
||||||
|
* use RetailCrm\Api\Model\Entity\WebAnalytics\Order;
|
||||||
|
* use RetailCrm\Api\Model\Request\WebAnalytics\ClientIdUploadRequest;
|
||||||
|
*
|
||||||
|
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
|
||||||
|
*
|
||||||
|
* $entity = new ClientId();
|
||||||
|
* $entity->value = 'value';
|
||||||
|
* $entity->order = new Order();
|
||||||
|
* $entity->order->id = 10;
|
||||||
|
* $entity->order->externalId = 'externalId';
|
||||||
|
* $entity->order->number = 'number';
|
||||||
|
* $entity->customer = new Customer();
|
||||||
|
* $entity->customer->id = 10;
|
||||||
|
* $entity->customer->externalId = 'externalId';
|
||||||
|
*
|
||||||
|
* $request = new ClientIdUploadRequest([$entity]);
|
||||||
|
*
|
||||||
|
* try {
|
||||||
|
* $response = $client->webAnalytics->clientIdsUpload($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 'Upload is successful';
|
||||||
|
* ```
|
||||||
|
*
|
||||||
* @param \RetailCrm\Api\Model\Request\WebAnalytics\ClientIdUploadRequest $request
|
* @param \RetailCrm\Api\Model\Request\WebAnalytics\ClientIdUploadRequest $request
|
||||||
*
|
*
|
||||||
* @return \RetailCrm\Api\Model\Response\WebAnalytics\ClientIdUploadResponse
|
* @return \RetailCrm\Api\Model\Response\WebAnalytics\ClientIdUploadResponse
|
||||||
|
100
tests/src/ResourceGroup/WebAnalyticsTest.php
Normal file
100
tests/src/ResourceGroup/WebAnalyticsTest.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category WebAnalyticsTest
|
||||||
|
* @package RetailCrm\Tests\ResourceGroup
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RetailCrm\Tests\ResourceGroup;
|
||||||
|
|
||||||
|
use RetailCrm\Api\Enum\RequestMethod;
|
||||||
|
use RetailCrm\Api\Factory\SimpleClientFactory;
|
||||||
|
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
|
||||||
|
use RetailCrm\Api\Model\Entity\WebAnalytics\ClientId;
|
||||||
|
use RetailCrm\Api\Model\Entity\WebAnalytics\Customer;
|
||||||
|
use RetailCrm\Api\Model\Entity\WebAnalytics\Order;
|
||||||
|
use RetailCrm\Api\Model\Entity\WebAnalytics\Source;
|
||||||
|
use RetailCrm\Api\Model\Request\WebAnalytics\ClientIdUploadRequest;
|
||||||
|
use RetailCrm\Api\Model\Request\WebAnalytics\SourcesUploadRequest;
|
||||||
|
use RetailCrm\TestUtils\Factory\TestClientFactory;
|
||||||
|
use RetailCrm\TestUtils\TestCase\AbstractApiResourceGroupTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class WebAnalyticsTest
|
||||||
|
*
|
||||||
|
* @category WebAnalyticsTest
|
||||||
|
* @package RetailCrm\Tests\ResourceGroup
|
||||||
|
*/
|
||||||
|
class WebAnalyticsTest extends AbstractApiResourceGroupTestCase
|
||||||
|
{
|
||||||
|
public function testClientIdsUpload(): void
|
||||||
|
{
|
||||||
|
$json = <<<'EOF'
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
$entity = new ClientId();
|
||||||
|
$entity->value = 'value';
|
||||||
|
$entity->order = new Order();
|
||||||
|
$entity->order->id = 10;
|
||||||
|
$entity->order->externalId = 'externalId';
|
||||||
|
$entity->order->number = 'number';
|
||||||
|
$entity->customer = new Customer();
|
||||||
|
$entity->customer->id = 10;
|
||||||
|
$entity->customer->externalId = 'externalId';
|
||||||
|
|
||||||
|
$request = new ClientIdUploadRequest([$entity]);
|
||||||
|
|
||||||
|
$mock = static::createApiMockBuilder('web-analytics/client-ids/upload');
|
||||||
|
$mock->matchMethod(RequestMethod::POST)
|
||||||
|
->matchBody(self::encodeForm($request))
|
||||||
|
->reply(201)
|
||||||
|
->withBody($json);
|
||||||
|
|
||||||
|
$client = TestClientFactory::createClient($mock->getClient());
|
||||||
|
$response = $client->webAnalytics->clientIdsUpload($request);
|
||||||
|
|
||||||
|
self::assertModelEqualsToResponse($json, $response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSourcesUpload(): void
|
||||||
|
{
|
||||||
|
$json = <<<'EOF'
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
$entity = new Source();
|
||||||
|
$entity->source = "sourse";
|
||||||
|
$entity->medium = "medium";
|
||||||
|
$entity->campaign = "campaign";
|
||||||
|
$entity->keyword = "keyword";
|
||||||
|
$entity->content = "content";
|
||||||
|
$entity->clientId = "10";
|
||||||
|
$entity->order = new Order();
|
||||||
|
$entity->order->id = 10;
|
||||||
|
$entity->order->externalId = "externalId";
|
||||||
|
$entity->order->number = "number";
|
||||||
|
$entity->customer = new Customer();
|
||||||
|
$entity->customer->id = 10;
|
||||||
|
$entity->customer->externalId = 'externalId';
|
||||||
|
|
||||||
|
$request = new SourcesUploadRequest([$entity]);
|
||||||
|
|
||||||
|
$mock = static::createApiMockBuilder('web-analytics/sources/upload');
|
||||||
|
$mock->matchMethod(RequestMethod::POST)
|
||||||
|
->matchBody(self::encodeForm($request))
|
||||||
|
->reply(201)
|
||||||
|
->withBody($json);
|
||||||
|
|
||||||
|
$client = TestClientFactory::createClient($mock->getClient());
|
||||||
|
$response = $client->webAnalytics->sourcesUpload($request);
|
||||||
|
|
||||||
|
self::assertModelEqualsToResponse($json, $response);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user