Skip to content

feat: ring individual members + updates #75

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,41 @@ call.get_or_create(
)
```

#### Ringing Individual Members

In some cases, you may want to ring individual members instead of the whole call, or you want to ring a member into an existing call. You can do this by using the `ring` method:

```python
import uuid
from getstream import Stream

# Initialize client
client = Stream(api_key="your_api_key", api_secret="your_api_secret")

# Create a call
call = client.video.call("default", str(uuid.uuid4()))

# Create or get a call with members
call.get_or_create(
data=CallRequest(
created_by_id="myself",
members=[
MemberRequest(user_id= "myself"),
MemberRequest(user_id="my-friend")
],
)
)

# Ring an existing member
call.ring(member_ids=["my-friend"])

# Add a new member to the call and ring them
call.update_call_members(
update_members=[{"user_id": "my-other-friend"}]
)
call.ring(member_ids=["my-other-friend"])
```

### App configuration

```python
Expand Down
2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi

if ! uv -V &> /dev/null
then
echo "cannot find poetry in path, did you setup this repo correctly?";
echo "cannot find uv in path, did you setup this repo correctly?";
exit 1;
fi

Expand Down
3 changes: 2 additions & 1 deletion getstream/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def __init__(self, response: httpx.Response) -> None:

def __str__(self) -> str:
if self.api_error:
return f'Stream error code {self.api_error.code}: {self.api_error.message}"'
message = self.api_error.message or f"Error code {self.api_error.code}"
return f'Stream error code {self.api_error.code}: {message}"'
else:
return f"Stream error HTTP code: {self.status_code}"
4 changes: 4 additions & 0 deletions getstream/chat/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ def create_channel_type(
read_events: Optional[bool] = None,
replies: Optional[bool] = None,
search: Optional[bool] = None,
shared_locations: Optional[bool] = None,
skip_last_msg_update_for_system_msgs: Optional[bool] = None,
typing_events: Optional[bool] = None,
uploads: Optional[bool] = None,
Expand Down Expand Up @@ -671,6 +672,7 @@ def create_channel_type(
read_events=read_events,
replies=replies,
search=search,
shared_locations=shared_locations,
skip_last_msg_update_for_system_msgs=skip_last_msg_update_for_system_msgs,
typing_events=typing_events,
uploads=uploads,
Expand Down Expand Up @@ -728,6 +730,7 @@ def update_channel_type(
reminders: Optional[bool] = None,
replies: Optional[bool] = None,
search: Optional[bool] = None,
shared_locations: Optional[bool] = None,
skip_last_msg_update_for_system_msgs: Optional[bool] = None,
typing_events: Optional[bool] = None,
uploads: Optional[bool] = None,
Expand Down Expand Up @@ -763,6 +766,7 @@ def update_channel_type(
reminders=reminders,
replies=replies,
search=search,
shared_locations=shared_locations,
skip_last_msg_update_for_system_msgs=skip_last_msg_update_for_system_msgs,
typing_events=typing_events,
uploads=uploads,
Expand Down
36 changes: 36 additions & 0 deletions getstream/common/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,42 @@ def delete_users(

return self.post("/api/v2/users/delete", DeleteUsersResponse, json=json)

def get_user_live_locations(
self, user_id: Optional[str] = None
) -> StreamResponse[SharedLocationsResponse]:
query_params = build_query_param(user_id=user_id)

return self.get(
"/api/v2/users/live_locations",
SharedLocationsResponse,
query_params=query_params,
)

def update_live_location(
self,
created_by_device_id: str,
message_id: str,
end_at: Optional[datetime] = None,
latitude: Optional[float] = None,
longitude: Optional[float] = None,
user_id: Optional[str] = None,
) -> StreamResponse[SharedLocationResponse]:
query_params = build_query_param(user_id=user_id)
json = build_body_dict(
created_by_device_id=created_by_device_id,
message_id=message_id,
end_at=end_at,
latitude=latitude,
longitude=longitude,
)

return self.put(
"/api/v2/users/live_locations",
SharedLocationResponse,
query_params=query_params,
json=json,
)

def reactivate_users(
self,
user_ids: List[str],
Expand Down
Loading
Loading