json-api-client icon indicating copy to clipboard operation
json-api-client copied to clipboard

Add ability to send headers through repositories

Open rapkis opened this issue 1 year ago • 1 comments

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:

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

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.

  • [x] I have read the CONTRIBUTING document.
  • [x] My pull request addresses exactly one patch/feature.
  • [x] I have created a branch for this patch/feature.
  • [x] Each individual commit in the pull request is meaningful.
  • [x] I have added tests to cover my changes.
  • [x] If my change requires a change to the documentation, I have updated it accordingly.

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

rapkis avatar May 14 '24 08:05 rapkis

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.

rapkis avatar May 14 '24 08:05 rapkis

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

bbrala avatar May 14 '24 21:05 bbrala