Skip to content

Releases: swisnl/json-api-client

1.0.0-beta.2

20 Sep 08:57
Compare
Choose a tag to compare

This release includes a small breaking change because we switched from PHP-HTTP to PSR-18, its successor. Almost all PHP-HTTP clients now implement PSR-18, so this should not be a big problem. This also means for example that PSR exceptions are thrown instead of PHP-HTTP exceptions. If you are relying on some PHP-HTTP classes yourself, make sure to review your code and change those to their PSR equivalent. If you are using this package within a Laravel application, it is important to note that we also changed the way how you can bind your own HTTP client. Please see the documentation and compare all code changes for more details!

Added

  • Added support for Laravel 6 #61.

Changed

  • Switched from PHP-HTTP to PSR-18, its successor #60.
  • The \Swis\JsonApi\Client\Client now uses php-http/discovery itself instead of the service provider. This should make usage without Laravel easier #60.
  • Removed the $baseUri parameter from \Swis\JsonApi\Client\Client::__construct(), use \Swis\JsonApi\Client\Client::setBaseUri() instead #60.

Removed

  • Removed \Swis\JsonApi\Client\Providers\ServiceProvider::getHttpClient() and \Swis\JsonApi\Client\Providers\ServiceProvider::getMessageFactory() as the client now discovers these classes itself. Custom HTTP clients must now be registered within your own service provider using a custom container binding #60.

Fixed

  • Self and related links can not be null #59.
  • Error links MUST have about link. Relationship links MUST have either self or related link #59.
  • Links has to be an object.

1.0.0-beta

22 Jul 14:02
Compare
Choose a tag to compare

Changed

  • Drop art4/json-api-client dependency and validate the JSON ourselves #58.
  • \Swis\JsonApi\Client\Exceptions\ValidationException is thrown instead of \Art4\JsonApiClient\Exception\ValidationException #58.
  • Added hasAttribute to ItemInterface.
  • All exceptions thrown by this package now implement \Swis\JsonApi\Client\Exceptions\Exception.

Fixed

  • Empty (null) links are correctly parsed.
  • Empty (null) singular relationships are correctly parsed.

0.20.0

11 Jul 14:38
Compare
Choose a tag to compare

Changed

  • Changed signature of RepositoryInterface::save(). It should now receive an ItemInterface instead of a ItemDocumentInterface #55.
    N.B. This is a breaking change!

0.19.0

10 Jul 13:57
Compare
Choose a tag to compare

This is a big release to improve the overall code quality and align some inconsistencies. Please note it includes several breaking changes so read through all changes carefully when upgrading!

Added

  • Added DocumentFactory #52.
  • Added facades for DocumentFactory, DocumentParser, ItemHydrator, ResponseParser and TypeMapper.
  • Added DocumentParserInterface and ResponseParserInterface interfaces and implementations #54.

Changed

  • The TypeMapper now checks if the class exists in the setter instead of the getter.
  • The ItemHydrator now also hydrates the id if provided #53.
  • Added hasType, hasAttributes, hasRelationships and getRelations to ItemInterface #53.
  • Removed canBeIncluded and getIncluded from ItemInterface as the DocumentFactory is now responsible for gathering the included items #53.
  • Renamed getRelationship to getRelation, hasRelationship to hasRelation and removeRelationship to unsetRelation in Item #53.
  • Renamed/aligned some parameters in several relation methods in Item #53.
  • Renamed namespace Swis\JsonApi\Client\Traits to Swis\JsonApi\Client\Concerns #53.
  • Renamed namespace Swis\JsonApi\Client\JsonApi to Swis\JsonApi\Client\Parsers #54.
  • Renamed ServiceProvider::registerParser (singular) to ServiceProvider::registerParsers (plural) #54.

Removed

  • Removed CollectionDocumentBuilder and ItemDocumentBuilder in favor of DocumentFactory #52.
  • Removed ParserInterface in favor of DocumentParserInterface and ResponseParserInterface #54.

0.18.0

01 Jul 12:04
Compare
Choose a tag to compare

This release includes changes to some interfaces. This is a breaking change if you use these interfaces in your own code.

Added

  • The id of an item can be set/get using magic accessors just like the attributes #51.

Changed

  • Added (optional) type hints to several interfaces.
    N.B. This is a breaking change if you implement some of the interfaces yourself. Please look at the interfaces and make the appropriate changes in your implementation.
  • Renamed deleteById method to simply delete and removed the 'old' implementation in RepositoryInterface.
    N.B. This is a breaking change and all calls to deleteById should simply be changed to delete as the signature is unchanged. The old behaviour of delete is not supported any more.

0.17.0

19 Mar 14:34
Compare
Choose a tag to compare

Added

  • Added support for Laravel 5.8 #50.

Changed

  • Dropped Laravel <5.5 support #50.
  • Dropped PHP <7.1 support #50.

0.16.0

14 Mar 14:06
Compare
Choose a tag to compare

Added

  • Added DocumentInterface::getResponse() so every document instance can have its corresponding response. This allows access to the underlying response to check headers or status codes etc #48.
  • Added ParserInterface::deserializeResponse($reponse) to deserialize a \Psr\Http\Message\ResponseInterface.

Changed

  • ClientInterface must now return a \Psr\Http\Message\ResponseInterface for requests instead of our own (removed) ResponseInterface #48.
    N.B. This is a breaking change if you use the Client directly, the DocumentClient isn't affected.
  • Changed namespace of error classes:
\Swis\JsonApi\Client\Errors\Error -> \Swis\JsonApi\Client\Error
\Swis\JsonApi\Client\Errors\ErrorCollection -> \Swis\JsonApi\Client\ErrorCollection
\Swis\JsonApi\Client\Errors\ErrorSource -> \Swis\JsonApi\Client\ErrorSource

Removed

  • Removed ResponseInterface and Response classes #48.

0.15.0

21 Feb 12:58
Compare
Choose a tag to compare

This release includes changes to some interfaces #47. This is a breaking change if you use these interfaces in your own code.

Added

  • Added take method to Repository to allow fetching resources without id.
  • Added links and meta to ItemInterface.
  • Added Jsonapi class.
  • Added links and meta to OneRelationInterface and ManyRelationInterface.
  • Added Link and Links classes.
  • Added links to Error.

Changed

  • Error::getMeta() now returns a Meta instance instead of an ErrorMeta instance. The Meta class does not have the has and get methods, but uses magic overloading methods (e.g. __get and __set) just like Item.
    N.B. This is a breaking change if you use meta on errors.
  • DocumentInterface::getLinks() now returns a Links instance instead of a plain array. If no links are present, it returns null. All implementations have been updated to reflect these changes.
    N.B. This is a minor breaking change if you use links on documents.
  • DocumentInterface::getMeta() now returns a Meta instance instead of a plain array. If no meta is present, it returns null. All implementations have been updated to reflect these changes.
    N.B. This is a minor breaking change if you use meta on documents.
  • DocumentInterface::getJsonapi() now returns a Jsonapi instance instead of a plain array. If no jsonapi is present, it returns null. All implementations have been updated to reflect these changes.
  • Parameters for ItemInterface::setRelation() have changed to include optional Links and Meta objects.
  • JsonApi\ErrorsParser, JsonApi\Hydrator and JsonApi\Parser have an extra dependency in their constructor.
    N.B. Make sure to add this dependency if you've overwritten ServiceProvider::registerParser or construct the JsonApi\Parser yourself.

Removed

  • Removed ErrorMeta class in favor of generic Meta class.

Fixed

0.14.0

23 Jan 15:45
Compare
Choose a tag to compare

This release includes changes to some interfaces #45. This is a breaking change if you use these interfaces in your own code.

Added

  • Added OneRelationInterface and ManyRelationInterface to differentiate between singular and plural relations.
  • Added documentation about ItemDocumentBuilder, ItemHydrator and Repository classes.

Changed

  • Moved setType and getType from RelationInterface to a separate interface; TypedRelationInterface.
  • Added type hints to ItemInterface::setRelation.
  • Added return type hint to Item::hasAttribute.

Removed

  • Removed RelationInterface in favor of OneRelationInterface and ManyRelationInterface.
  • Removed setId and getId from HasOneRelation and MorphToRelation. These operations should be performed on the included item.
  • Removed setType and getType from morph relations. Use regular relations if you want to set the type.

0.13.0

14 Jan 15:38
Compare
Choose a tag to compare

Fixed

  • Omit item from included when it has no attributes or relationships (only type and id)
    N.B. This is a breaking change if you implement the ItemInterface yourself instead of using the supplied Item.
  • Make sure included is always a plain array so it is serialized as array