-
Notifications
You must be signed in to change notification settings - Fork 20
[CHA-536] support campaign user pagination #188
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,11 @@ | |
from stream_chat.async_chat.campaign import Campaign | ||
from stream_chat.async_chat.segment import Segment | ||
from stream_chat.types.base import SortParam | ||
from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions | ||
from stream_chat.types.campaign import ( | ||
CampaignData, | ||
QueryCampaignsOptions, | ||
GetCampaignOptions, | ||
) | ||
from stream_chat.types.segment import ( | ||
QuerySegmentsOptions, | ||
QuerySegmentTargetsOptions, | ||
|
@@ -664,8 +668,13 @@ async def create_campaign( | |
payload.update(cast(dict, data)) | ||
return await self.post("campaigns", data=payload) | ||
|
||
async def get_campaign(self, campaign_id: str) -> StreamResponse: | ||
return await self.get(f"campaigns/{campaign_id}") | ||
async def get_campaign( | ||
self, campaign_id: str, options: Optional[GetCampaignOptions] = None | ||
) -> StreamResponse: | ||
params = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [mypy] reported by reviewdog 🐶 |
||
if options and "users" in options: | ||
params.update(options["users"]) | ||
return await self.get(f"campaigns/{campaign_id}", params) | ||
|
||
async def query_campaigns( | ||
self, | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -8,7 +8,11 @@ | |||
from typing import Any, Awaitable, Dict, Iterable, List, Optional, TypeVar, Union | ||||
|
||||
from stream_chat.types.base import SortParam | ||||
from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions | ||||
from stream_chat.types.campaign import ( | ||||
CampaignData, | ||||
QueryCampaignsOptions, | ||||
GetCampaignOptions, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [flake8] <1> reported by reviewdog 🐶 |
||||
) | ||||
from stream_chat.types.segment import ( | ||||
QuerySegmentsOptions, | ||||
QuerySegmentTargetsOptions, | ||||
|
@@ -1084,10 +1088,14 @@ def create_campaign( | |||
|
||||
@abc.abstractmethod | ||||
def get_campaign( | ||||
self, campaign_id: str | ||||
self, campaign_id: str, options: Optional[GetCampaignOptions] = None | ||||
) -> Union[StreamResponse, Awaitable[StreamResponse]]: | ||||
""" | ||||
Create a campaign | ||||
Get a campaign | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [black] reported by reviewdog 🐶
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||
:param campaign_id: ID of the campaign to get | ||||
:param options: Optional parameters for the request | ||||
:return: Campaign data | ||||
""" | ||||
pass | ||||
|
||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,11 @@ | |
from stream_chat.campaign import Campaign | ||
from stream_chat.segment import Segment | ||
from stream_chat.types.base import SortParam | ||
from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions | ||
from stream_chat.types.campaign import ( | ||
CampaignData, | ||
QueryCampaignsOptions, | ||
GetCampaignOptions, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [flake8] <1> reported by reviewdog 🐶 |
||
) | ||
from stream_chat.types.segment import ( | ||
QuerySegmentsOptions, | ||
QuerySegmentTargetsOptions, | ||
|
@@ -636,8 +640,13 @@ def create_campaign( | |
payload.update(cast(dict, data)) | ||
return self.post("campaigns", data=payload) | ||
|
||
def get_campaign(self, campaign_id: str) -> StreamResponse: | ||
return self.get(f"campaigns/{campaign_id}") | ||
def get_campaign( | ||
self, campaign_id: str, options: Optional[GetCampaignOptions] = None | ||
) -> StreamResponse: | ||
params = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [mypy] reported by reviewdog 🐶 |
||
if options and "users" in options: | ||
params.update(options["users"]) | ||
return self.get(f"campaigns/{campaign_id}", params) | ||
|
||
def query_campaigns( | ||
self, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import sys | ||
from typing import Dict, List, Optional | ||
from typing import Dict, List, Optional, Union | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [flake8] <401> reported by reviewdog 🐶 |
||
|
||
if sys.version_info >= (3, 8): | ||
from typing import TypedDict | ||
|
@@ -76,3 +76,14 @@ class CampaignData(TypedDict, total=False): | |
|
||
class QueryCampaignsOptions(Pager, total=False): | ||
pass | ||
|
||
|
||
class GetCampaignOptions(TypedDict, total=False): | ||
""" | ||
Options for getting a campaign. | ||
|
||
Parameters: | ||
users: Optional Pager containing pagination options for users | ||
""" | ||
|
||
users: Optional[Pager] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position