feat: legg til get_posts() for å hente innlegg fra gruppevegger#219
feat: legg til get_posts() for å hente innlegg fra gruppevegger#219Starefossen wants to merge 2 commits intoOlen:mainfrom
Conversation
- Add rsvpDate (svarfrist) display in event summaries - Add meetupTimestamp display as oppmøte time - Add matchInfo display (hjemme/borte) - Add cancelledReason display - Refactor event fetching to single all-groups API call - Filter events client-side by kid/group using recipients.group.id - Remove posts code (waiting for upstream PR Olen/Spond#219) - 99 tests passing
|
Ping @Olen - any chance we can get this merged? |
|
Please fix the ruff issues, other than that, it looks fine to me. |
Add a new get_posts() method to the Spond class that retrieves posts from group walls via the /core/v1/posts API endpoint. Posts are announcements/messages posted to group walls, distinct from chat messages (get_messages) and events (get_events). Supports filtering by group_id, setting max_posts limit, and toggling comment inclusion. Closes Olen#67
ca34ca5 to
9d3b6d5
Compare
|
Should be better now? |
There was a problem hiding this comment.
Pull request overview
Adds support in the Spond client to fetch “posts” (group wall announcements) from the /core/v1/posts endpoint, addressing the use case in #67.
Changes:
- Introduces
Spond.get_posts()with support forgroup_id,max_posts, andinclude_commentsquery params. - Adds
self.postsstorage on the client instance. - Adds a dedicated test suite covering happy path, parameter handling, and API error behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
spond/spond.py |
Adds posts state and the new get_posts() API method. |
tests/test_spond.py |
Adds 5 tests validating request parameters, response handling, and error raising for get_posts(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| url = f"{self.api_url}posts" | ||
| params: dict[str, str] = { | ||
| "type": "PLAIN", | ||
| "max": str(max_posts), | ||
| "includeComments": str(include_comments).lower(), |
| mock_url = "https://api.spond.com/core/v1/posts" | ||
| mock_get.assert_called_once_with( | ||
| mock_url, | ||
| headers={ | ||
| "content-type": "application/json", | ||
| "Authorization": f"Bearer {mock_token}", | ||
| }, | ||
| params={ | ||
| "type": "PLAIN", | ||
| "max": "20", | ||
| "includeComments": "true", | ||
| }, | ||
| ) |
There was a problem hiding this comment.
Fine with me, but would be nice to include that suggested minor consistency issue.
@Olen forgot to add, I have used the code to successfully retrieve live posts.
Thanks @Starefossen.
Beskrivelse
Legger til en ny
get_posts()-metode iSpond-klassen for å hente innlegg (posts) fra gruppevegger via API-endepunktet/core/v1/posts.Innlegg er kunngjøringer/meldinger som publiseres på gruppevegger, og er forskjellig fra chatmeldinger (
get_messages) og hendelser (get_events).Parametere
group_idstr | NoneNonemax_postsint20include_commentsboolTrueEksempel
Tester
5 nye tester er lagt til i
tests/test_spond.py:group_idmax_postsinclude_comments=FalseAlle eksisterende og nye tester bestått.
Closes #67