swisnl / json-api-client

A PHP package for mapping remote {json:api} resources to Eloquent like models and collections.
MIT License
205 stars 24 forks source link

Add ability to send headers through repositories #103

Closed rapkis closed 6 months ago

rapkis commented 6 months ago

Description

Accept a new array $headers = [] argument for every method used in repositories (default to an empty array for backward compatibility). Then forward those arguments to the underlying DocumentClient class, which already accepts them.

Motivation and context

Closes https://github.com/swisnl/json-api-client/issues/102

How has this been tested?

Tested the headers inputs in RepositoryTest

Screenshots (if appropriate)

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.

If you're unsure about any of these, don't hesitate to ask. We're here to help!

rapkis commented 6 months ago

By the way, I've noticed that there's an unrelated styling issue in UtilTest.php (caught by composer check-style), but didn't want to make any unrelated changes. Let me know if you'd like me to, or if that should be solved separately.

bbrala commented 6 months ago

Thanks for the pr. A thought, shouldn't there be a test with and without a header?