Skip to content

fix(api): CircleMembers add/remove target the wrong endpoints; members.list() unwraps a key the API does not send #42

Description

@nycomp

Description

The circle members sub-resource (campus_python/api/v1/circles.py) does not conform to the Campus API for membership mutations. After #41 fixed the nested-path construction, members now resolves to /api/v1/circles/<id>/members, but add()/remove() still hit the wrong endpoints with a wrong payload key, and list() unwraps a response key the API does not send.

Steps to Reproduce

from campus_python import Campus
c = Campus(timeout=10, mode="device")
c.api.circles["circle-1"].members.add("circle-2", 7)   # 405

Expected Behavior

Per the Campus API routes (campus-suite, weekly branch, campus/api/routes/circles.py):

  • GET /api/v1/circles/<id>/members/ — returns the flat {member_id: access_value} mapping directly
  • POST /api/v1/circles/<id>/members/add — request body {"member_id": ..., "access_value": ...}
  • DELETE /api/v1/circles/<id>/members/remove — request body {"member_id": ...}

Actual Behavior

  • add() POSTs to /api/v1/circles/<id>/members with {"member_id": ..., "access": ...} — the trailing-slash redirect lands on /members/ which only allows GET/PATCH (405), and the payload uses "access" where the API expects "access_value"
  • remove() DELETEs /api/v1/circles/<id>/members — same 405
  • list() does resp.json()["members"], but the API returns the flat member mapping as the body, so this raises KeyError

Suggested Fix

In CircleMembers:

  • add(): self.client.post(self.make_path("add"), json={"member_id": member_id, "access_value": access_value})
  • remove(): self.client.delete(self.make_path("remove"), json={"member_id": member_id})
  • list(): return resp.json() directly, requesting self.make_path(end_slash=True) to hit the canonical /members/ route

Regression tests for these request targets already exist as a pattern in tests/unit/test_nested_resources.py (see test_members_list_gets_members_endpoint) and should be updated to the corrected endpoints.

Environment

Spun out of #41 ("Out of scope" section).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions