Skip to content

Commit

Permalink
Remove attributemetadata (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeek authored Nov 23, 2023
1 parent ae87284 commit 80d2953
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 225 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Все существенные изменения в проекте будут задокументированы в этом файле. Формат основан на [Keep a Changelog](https://keepachangelog.com/), и этот проект придерживается семантического версионирования ([semver](https://semver.org/)).

## v0.11.0[[Upgrade guide](/UPGRADE.md#v0110-changelog)]

### Removed

* Удалён класс `AttributeMetadata` и связанные с ним хелперы. Причина - у разных сущностей он доступен по разному пути, структура тоже отличается, поэтому его текущая реализация некорректна. Также в связи с нестандартным поведением, требует особую логику создания, что будет сделано позднее.

## v0.10.1

### Fixed
Expand Down
36 changes: 36 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Upgrade guide

## v0.11.0 [[Changelog](/CHANGELOG.md#v0110-upgrade-guide)]

### Удалён класс `AttributeMetadata` и связанные с ним хелперы.

Для работы с `attributemetadata` используйте конструктор запросов.

До:

```php
$attribute = AttributeMetadata::make($ms, ['id' => 'cb26a487-0f3a-11ee-0a80-060300137dbf'])->get();
$attributeList = AttributeMetadata::collection($ms)->get()->rows;
$meta = Meta::attributemetadata('cb26a487-0f3a-11ee-0a80-060300137dbf');
```

После:

```php
$attribute = $ms->query()
->entity()
->variant()
->metadata()
->characteristics()
->byId('cb26a487-0f3a-11ee-0a80-060300137dbf')
->get();
$attributeList = $ms->query()
->entity()
->variant()
->metadata()
->get()
->characteristics;
$meta = Meta::create(
['entity', 'variant', 'metadata', 'characteristics', 'cb26a487-0f3a-11ee-0a80-060300137dbf'],
'attributemetadata',
);
```

## v0.10.0 [[Changelog](/CHANGELOG.md#v0100-upgrade-guide)]

### Имена классов Query и Record приведены к PascalCase.
Expand Down
12 changes: 12 additions & 0 deletions docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* [Meta](/docs/tools.md#meta)
* [Методы сущностей](/docs/formatters.md#методы-сущностей)
* [Вложенные сущности](/docs/formatters.md#вложенные-сущности)
* [Форматирование](/docs/formatters.md#форматирование)
* [Альтернатива](/docs/formatters.md#альтернатива)
* [Guid](/docs/tools.md#guid)
Expand Down Expand Up @@ -51,6 +52,17 @@ var_dump($serviceMeta);
//}
```

### Вложенные сущности

Для создания меты сущностей, зависящих от других (файлы, изображения, сохранённые фильтры и др.), требуется указать родительскую сущность. Возможные форматы родительских сущностей подробно расписаны во [вложенных объектов Record](/docs/active_record.md#вложенные-сущности).

Пример:

```php
$product = Product::make($ms, ['id' => '8325d6cc-0838-11ee-0a80-08d500275db5']);
$productImageMeta = Meta::image($product, 'c2ecd338-015e-11e6-9464-e4de0000008f');
```

### Форматирование

При использовании хелпера через `$ms->meta()`, результат возвращается в [формате](/docs/formatters.md), заданном в `$ms`. При использовани через статические методы, ответ возвращается в формате `stdClass`. Как правило, менять формат нет необходимости - однако, это можно сделать, передав желаемый форматтер в метод сущности.
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Query/Segments/ById/AbstractByIdSegment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

abstract class AbstractByIdSegment extends AbstractCommonSegment
{
use ByIdCommonTrait;
use DeleteTrait;
use UpdateTrait;
use ByIdCommonTrait;
}
13 changes: 0 additions & 13 deletions src/Api/Record/Builders/CollectionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use Evgeek\Moysklad\Api\Record\Collections\Documents\SupplyCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AccumulationDiscountCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AssortmentCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AttributeMetadataCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BonusProgramCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BonusTransactionCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BundleCollection;
Expand Down Expand Up @@ -637,18 +636,6 @@ public function files(ObjectInterface|array|string $parent): AbstractNestedColle
return $this->resolveNestedCollection(Type::FILES, $parent);
}

/**
* Коллекция Характеристик модификации
*
* @see https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-harakteristiki-modifikacij
*
* @return AttributeMetadataCollection
*/
public function attributemetadata(): AbstractConcreteCollection
{
return $this->resolveCollection(Type::ATTRIBUTEMETADATA);
}

/**
* Коллекция Стандартных шаблонов
*
Expand Down
13 changes: 0 additions & 13 deletions src/Api/Record/Builders/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
use Evgeek\Moysklad\Api\Record\Objects\Documents\SalesReturn;
use Evgeek\Moysklad\Api\Record\Objects\Documents\Supply;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AccumulationDiscount;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AttributeMetadata;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusProgram;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusTransaction;
use Evgeek\Moysklad\Api\Record\Objects\Entities\Bundle;
Expand Down Expand Up @@ -639,18 +638,6 @@ public function files(ObjectInterface|array|string $parent, mixed $content = [])
return $this->resolveNestedObject(Type::FILES, $parent, $content);
}

/**
* Характеристика модификации
*
* @see https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-harakteristiki-modifikacij
*
* @return AttributeMetadata
*/
public function attributemetadata(mixed $content = []): AbstractConcreteObject
{
return $this->resolveObject(Type::ATTRIBUTEMETADATA, $content);
}

/**
* Стандартный шаблон
*
Expand Down

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions src/Api/Record/Objects/Entities/AttributeMetadata.php

This file was deleted.

4 changes: 0 additions & 4 deletions src/Formatters/RecordMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
use Evgeek\Moysklad\Api\Record\Collections\Documents\SupplyCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AccumulationDiscountCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AssortmentCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AttributeMetadataCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BonusProgramCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BonusTransactionCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BundleCollection;
Expand Down Expand Up @@ -130,7 +129,6 @@
use Evgeek\Moysklad\Api\Record\Objects\Documents\Supply;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AccumulationDiscount;
use Evgeek\Moysklad\Api\Record\Objects\Entities\Assortment;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AttributeMetadata;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusProgram;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusTransaction;
use Evgeek\Moysklad\Api\Record\Objects\Entities\Bundle;
Expand Down Expand Up @@ -239,7 +237,6 @@ class RecordMapping
Type::RETAILSTORE => RetailStore::class,
Type::SERVICE => Service::class,
Type::FILES => Files::class,
Type::ATTRIBUTEMETADATA => AttributeMetadata::class,
Type::EMBEDDEDTEMPLATE => EmbeddedTemplate::class,
Type::CUSTOMTEMPLATE => CustomTemplate::class,
Type::ORGANIZATION => Organization::class,
Expand Down Expand Up @@ -326,7 +323,6 @@ class RecordMapping
Type::RETAILSTORE => RetailStoreCollection::class,
Type::SERVICE => ServiceCollection::class,
Type::FILES => FilesCollection::class,
Type::ATTRIBUTEMETADATA => AttributeMetadataCollection::class,
Type::EMBEDDEDTEMPLATE => EmbeddedTemplateCollection::class,
Type::CUSTOMTEMPLATE => CustomTemplateCollection::class,
Type::ORGANIZATION => OrganizationCollection::class,
Expand Down
10 changes: 0 additions & 10 deletions src/Meta/MetaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,16 +458,6 @@ public function files(ObjectInterface|array|string $parent, string $guid)
return Meta::files($parent, $guid, $this->formatter);
}

/**
* Метаданные Характеристики модификации
*
* @see https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-harakteristiki-modifikacij
*/
public function attributemetadata(string $guid)
{
return Meta::attributemetadata($guid, $this->formatter);
}

/**
* Метаданные Стандартного шаблона
*
Expand Down
11 changes: 0 additions & 11 deletions src/Tools/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use Evgeek\Moysklad\Api\Record\Objects\Documents\SalesReturn;
use Evgeek\Moysklad\Api\Record\Objects\Documents\Supply;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AccumulationDiscount;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AttributeMetadata;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusProgram;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusTransaction;
use Evgeek\Moysklad\Api\Record\Objects\Entities\Bundle;
Expand Down Expand Up @@ -533,16 +532,6 @@ public static function files(ObjectInterface|array|string $parent, string $guid,
return static::createNested($parent, [...Files::PATH, $guid], Files::TYPE, $formatter);
}

/**
* Метаданные Характеристики модификации
*
* @see https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-harakteristiki-modifikacij
*/
public static function attributemetadata(string $guid, JsonFormatterInterface $formatter = null)
{
return static::create([...AttributeMetadata::PATH, $guid], AttributeMetadata::TYPE, $formatter);
}

/**
* Метаданные Стандартного шаблона
*
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Api/Record/Builders/CollectionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
use Evgeek\Moysklad\Api\Record\Collections\Documents\SupplyCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AccumulationDiscountCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AssortmentCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\AttributeMetadataCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BonusProgramCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BonusTransactionCollection;
use Evgeek\Moysklad\Api\Record\Collections\Entities\BundleCollection;
Expand Down Expand Up @@ -201,7 +200,6 @@ public static function methodsWithCorrespondingObjectClass(): array
Type::RETAILSTORE => ['retailstore', RetailStoreCollection::class],
Type::SERVICE => ['service', ServiceCollection::class],
Type::FILES => ['files', FilesCollection::class, true],
Type::ATTRIBUTEMETADATA => ['attributemetadata', AttributeMetadataCollection::class],
Type::EMBEDDEDTEMPLATE => ['embeddedtemplate', EmbeddedTemplateCollection::class, true],
Type::CUSTOMTEMPLATE => ['customtemplate', CustomTemplateCollection::class, true],
Type::ORGANIZATION => ['organization', OrganizationCollection::class],
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Api/Record/Builders/ObjectBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use Evgeek\Moysklad\Api\Record\Objects\Documents\SalesReturn;
use Evgeek\Moysklad\Api\Record\Objects\Documents\Supply;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AccumulationDiscount;
use Evgeek\Moysklad\Api\Record\Objects\Entities\AttributeMetadata;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusProgram;
use Evgeek\Moysklad\Api\Record\Objects\Entities\BonusTransaction;
use Evgeek\Moysklad\Api\Record\Objects\Entities\Bundle;
Expand Down Expand Up @@ -201,7 +200,6 @@ public static function methodsWithCorrespondingObjectClass(): array
Type::RETAILSTORE => ['retailstore', RetailStore::class],
Type::SERVICE => ['service', Service::class],
Type::FILES => ['files', Files::class, true],
Type::ATTRIBUTEMETADATA => ['attributemetadata', AttributeMetadata::class],
Type::EMBEDDEDTEMPLATE => ['embeddedtemplate', EmbeddedTemplate::class, true],
Type::CUSTOMTEMPLATE => ['customtemplate', CustomTemplate::class, true],
Type::ORGANIZATION => ['organization', Organization::class],
Expand Down
Loading

0 comments on commit 80d2953

Please sign in to comment.