Skip to content

Moving away from Spatie Data Transfer Objects

Compare
Choose a tag to compare
@keithbrink keithbrink released this 18 Apr 13:51
· 42 commits to main since this release
ac4d692

BREAKING CHANGES

Since Spatie's data transfer objects package is abandoned, we wanted to move away from using their data transfer objects eventually. In preparing for implementing the new fulfilment inbound API, we decided it was the right time to make the switch. There are a lot of changes in this release, but most of them involve that change.

If you're using any of the data objects directly, you should get the exact same functionality by using the new from static method.

Change from instantiating the class directly:

new InboundShipmentPlanSchema(...)

To the static method:

InboundShipmentPlanSchema::from(...)

This change will be the majority of the adjustments required in your code. Some additional minor breaking changes:

  • Renaming the DataTransferObjects folder to Data
  • Renaming AuthTokensDTO, ApplicationKeysDTO, GrantlessTokenDTO, and RestrictedDataTokenDTO to AuthTokens, ApplicationKeys, GrantlessToken and RestrictedDataToken
  • If you were using functionality that belonged to the underlying data transfer objects package, that will no longer be available.
  • Collections of schemas are strongly typed, so they cannot be instantiated with a different class or item type
  • If you are using a strongly typed collection, it might behave differently compared to a normal collection. Please ensure any code that is using a typed collection directly is working properly.
  • Nullable properties of data objects will now be set to null if they are not a collection and an empty array is returned for that property, rather than being set as an empty object

Improvements

  • The data classes are much closer to plain old PHP objects, so if you want to work with them directly they will act in a familiar manner.
  • Since collections are strongly typed, you should be able to get the correct type with accessing their items in your IDE
  • Since we are mapping our own data, we were able to remove several hacks and replace it with casting or changing the behaviour with contracts on that particular class
  • Class casing has been made more consistent