Releases: swisnl/json-api-client
1.0.0-beta.2
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
1.0.0-beta
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
toItemInterface
. - 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
0.19.0
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
andTypeMapper
. - Added
DocumentParserInterface
andResponseParserInterface
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
andgetRelations
toItemInterface
#53. - Removed
canBeIncluded
andgetIncluded
fromItemInterface
as theDocumentFactory
is now responsible for gathering the included items #53. - Renamed
getRelationship
togetRelation
,hasRelationship
tohasRelation
andremoveRelationship
tounsetRelation
inItem
#53. - Renamed/aligned some parameters in several relation methods in
Item
#53. - Renamed namespace
Swis\JsonApi\Client\Traits
toSwis\JsonApi\Client\Concerns
#53. - Renamed namespace
Swis\JsonApi\Client\JsonApi
toSwis\JsonApi\Client\Parsers
#54. - Renamed
ServiceProvider::registerParser
(singular) toServiceProvider::registerParsers
(plural) #54.
Removed
0.18.0
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 simplydelete
and removed the 'old' implementation inRepositoryInterface
.
N.B. This is a breaking change and all calls todeleteById
should simply be changed todelete
as the signature is unchanged. The old behaviour ofdelete
is not supported any more.
0.17.0
0.16.0
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 theClient
directly, theDocumentClient
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
andResponse
classes #48.
0.15.0
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 toRepository
to allow fetching resources without id. - Added links and meta to
ItemInterface
. - Added
Jsonapi
class. - Added links and meta to
OneRelationInterface
andManyRelationInterface
. - Added
Link
andLinks
classes. - Added links to
Error
.
Changed
Error::getMeta()
now returns aMeta
instance instead of anErrorMeta
instance. TheMeta
class does not have thehas
andget
methods, but uses magic overloading methods (e.g.__get
and__set
) just likeItem
.
N.B. This is a breaking change if you use meta on errors.DocumentInterface::getLinks()
now returns aLinks
instance instead of a plain array. If no links are present, it returnsnull
. 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 aMeta
instance instead of a plain array. If no meta is present, it returnsnull
. 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 aJsonapi
instance instead of a plain array. If no jsonapi is present, it returnsnull
. All implementations have been updated to reflect these changes.- Parameters for
ItemInterface::setRelation()
have changed to include optionalLinks
andMeta
objects. JsonApi\ErrorsParser
,JsonApi\Hydrator
andJsonApi\Parser
have an extra dependency in their constructor.
N.B. Make sure to add this dependency if you've overwrittenServiceProvider::registerParser
or construct theJsonApi\Parser
yourself.
Removed
- Removed
ErrorMeta
class in favor of genericMeta
class.
Fixed
- Fixed parsing of JSON:API object in document.
0.14.0
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
andManyRelationInterface
to differentiate between singular and plural relations. - Added documentation about
ItemDocumentBuilder
,ItemHydrator
andRepository
classes.
Changed
- Moved
setType
andgetType
fromRelationInterface
to a separate interface;TypedRelationInterface
. - Added type hints to
ItemInterface::setRelation
. - Added return type hint to
Item::hasAttribute
.
Removed
- Removed
RelationInterface
in favor ofOneRelationInterface
andManyRelationInterface
. - Removed
setId
andgetId
fromHasOneRelation
andMorphToRelation
. These operations should be performed on the included item. - Removed
setType
andgetType
from morph relations. Use regular relations if you want to set the type.
0.13.0
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 theItemInterface
yourself instead of using the suppliedItem
. - Make sure included is always a plain array so it is serialized as array