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

Added method to update person data #84

Merged
merged 10 commits into from
Aug 20, 2022
Merged

Conversation

stollr
Copy link
Collaborator

@stollr stollr commented Aug 17, 2022

Currently there is no way to update a person's data with this adapter. This PR adds a new update method to the PersonRequestand PersonRequestBuilder classes.

This PR also contains user documentation and unit tests.

This is how the method can be used:

$person = PersonRequest::findOrFail(21);
$person->setEmail('new-mail@example.com');

PersonRequest::update($person);

In the doc you'll find some more explanations.

I'll be happy to see this getting merged, soon :-)

@stollr
Copy link
Collaborator Author

stollr commented Aug 17, 2022

@DumbergerL I am not sure what to do with the failed Doc-Generator check "Inconsistent Docs. Please run DocGenerator and check in changed Files.".

I suspect that the added code blocks in the docs/PersonAPI.md file are the reason. But how can I chaeck that?

When I run omposer run-script docs-generator there are no errors.

@DumbergerL
Copy link
Contributor

@Naitsirch Thank's for your contribution. I have thought of this "writing to api"-topic quite a lot. But i think it's not that big thing because ChurchTools don't offer many PATCH-Routes. So i think your approach is great!

We should consider to add some Code-Checks to validate if all MODIFIABLE_ATTRIBUTES are contained in the Model-Class. This could also include to check if all Model-Attributes have Setters and Getter.

@stollr
Copy link
Collaborator Author

stollr commented Aug 17, 2022

Can you explain your last paragraph a little bit more?
If not all MODIFIABLE_ATTRIBUTES are contained in the model class it won't have any negative effect.

@DumbergerL
Copy link
Contributor

DumbergerL commented Aug 18, 2022

@Naitsirch Yes you are right! If the modifiableAttributes contains a key that does not exists in the Class it won't be exposed to the REST-API. I wrote a Unit-Test for this case: 73db4f4

@DumbergerL
Copy link
Contributor

@Naitsirch I refactored your implementation a little bit. Can you check if it still faces your needs? Does it work for you this way? If yes i would merge the PR.

@stollr
Copy link
Collaborator Author

stollr commented Aug 18, 2022

I hope I'll have time in the next days. Then I will test it and give feedback.

@stollr
Copy link
Collaborator Author

stollr commented Aug 20, 2022

@DumbergerL I have tested it now and it works fine :-)

@DumbergerL DumbergerL merged commit 717174f into 5pm-HDH:master Aug 20, 2022
@stollr stollr deleted the update_person branch August 22, 2022 19:27
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.

2 participants