Skip to content

feat: legg til get_posts() for å hente innlegg fra gruppevegger#219

Open
Starefossen wants to merge 2 commits intoOlen:mainfrom
Starefossen:feature/get-posts
Open

feat: legg til get_posts() for å hente innlegg fra gruppevegger#219
Starefossen wants to merge 2 commits intoOlen:mainfrom
Starefossen:feature/get-posts

Conversation

@Starefossen
Copy link

Beskrivelse

Legger til en ny get_posts()-metode i Spond-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

Parameter Type Standard Beskrivelse
group_id str | None None Filtrer etter gruppe
max_posts int 20 Maks antall innlegg som returneres
include_comments bool True Inkluder kommentarer på innlegg

Eksempel

s = Spond(username="user", password="pass")
posts = await s.get_posts(group_id="ABC123", max_posts=10)
for post in posts:
    print(post["title"], post["body"])

Tester

5 nye tester er lagt til i tests/test_spond.py:

  • Henting av innlegg (happy path)
  • Filtrering etter group_id
  • Egendefinert max_posts
  • include_comments=False
  • Feilhåndtering ved API-feil

Alle eksisterende og nye tester bestått.

Closes #67

Starefossen added a commit to Starefossen/spond-no-match-mcp that referenced this pull request Mar 3, 2026
- 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
@Starefossen
Copy link
Author

Ping @Olen - any chance we can get this merged?

@Olen
Copy link
Owner

Olen commented Mar 11, 2026

Please fix the ruff issues, other than that, it looks fine to me.
Any objections, @elliot-100 ?

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
@Starefossen
Copy link
Author

Should be better now?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 for group_id, max_posts, and include_comments query params.
  • Adds self.posts storage 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.

Comment on lines +174 to +178
url = f"{self.api_url}posts"
params: dict[str, str] = {
"type": "PLAIN",
"max": str(max_posts),
"includeComments": str(include_comments).lower(),
Comment on lines +253 to +265
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",
},
)
Copy link
Collaborator

@elliot-100 elliot-100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

Is it possible to retrieve posts as opposed to messages?

4 participants