Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue causing failures when assigning values from API to php entity classes. #90

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

CharlesBarone
Copy link

All instances of "Rgb" need to be changed to "RGB" so that they match what ends up in the data transfer class. (The property names are case sensitive).

Initially I thought it was caused by the property not being null-able so I made the int null-able, but it turns out that it is a required field, just the original variable names in the class definitions followed camel case rather than the casing used by the folks over at Datto who decided to be inconsistent...(who would've thought...)

I then checked to see if there was any other classes with issue and fixed those as well. 😄

Example of an error I recieved that this pull request resolves:

PHP Fatal error:  Uncaught TypeError: Cannot assign null to property Anteris\Autotask\API\CompanyCategories\CompanyCategoryEntity::$displayColorRgb of type int in /home/cbarone/autotask-migration/vendor/spatie/data-transfer-object/src/Reflection/DataTransferObjectProperty.php:48
Stack trace:
#0 /home/cbarone/autotask-migration/vendor/spatie/data-transfer-object/src/Reflection/DataTransferObjectProperty.php(48): ReflectionProperty->setValue()
#1 /home/cbarone/autotask-migration/vendor/spatie/data-transfer-object/src/DataTransferObject.php(29): Spatie\DataTransferObject\Reflection\DataTransferObjectProperty->setValue()
#2 /home/cbarone/autotask-migration/vendor/anteris-dev/autotask-client/src/API/CompanyCategories/CompanyCategoryEntity.php(31): Spatie\DataTransferObject\DataTransferObject->__construct()
#3 /home/cbarone/autotask-migration/vendor/spatie/data-transfer-object/src/DataTransferObject.php(44): Anteris\Autotask\API\CompanyCategories\CompanyCategoryEntity->__construct()
#4 [internal function]: Spatie\DataTransferObject\DataTransferObject::Spatie\DataTransferObject\{closure}()
#5 /home/cbarone/autotask-migration/vendor/spatie/data-transfer-object/src/DataTransferObject.php(44): array_map()
#6 /home/cbarone/autotask-migration/vendor/anteris-dev/autotask-client/src/API/CompanyCategories/CompanyCategoryCollection.php(46): Spatie\DataTransferObject\DataTransferObject::arrayOf()
#7 /home/cbarone/autotask-migration/vendor/anteris-dev/autotask-client/src/API/CompanyCategories/CompanyCategoryQueryBuilder.php(101): Anteris\Autotask\API\CompanyCategories\CompanyCategoryCollection::fromResponse()
#8 /home/cbarone/autotask-migration/run.php(257): Anteris\Autotask\API\CompanyCategories\CompanyCategoryQueryBuilder->get()
#9 /home/cbarone/autotask-migration/run.php(407): exportEntity()
#10 {main}
  thrown in /home/cbarone/autotask-migration/vendor/spatie/data-transfer-object/src/Reflection/DataTransferObjectProperty.php on line 48

@CharlesBarone
Copy link
Author

CharlesBarone commented Apr 22, 2024

image

Found another one. This time Autotask fields endpoint says this one is required, but in practice its null-able... Adding another commit to address this. (parentCategoryID)

@CharlesBarone
Copy link
Author

image
image
Fixed null-able issue on PurchaseApprovals too. isApproved as you can see is supposed to be required yet here we see again its clearly null-able... I love that Datto doesn't even follow their own rules...

@CharlesBarone
Copy link
Author

image
image
Another example of a field that is nullable that shouldn't be... (contactID on SalesOrders)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant