Skip to content

Commit

Permalink
feat: utc_offset_hours
Browse files Browse the repository at this point in the history
chore: version bump
  • Loading branch information
peku33 committed Dec 6, 2023
1 parent 5f89bcd commit fccec61
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 11.1.0
- Added `utc_offset_hours` parameter for `get_rtb_stats` and `get_summary_stats`

# v11.0.0
- Added support for Pydantic v2
- [breaking change] `cookie_hash`, `last_click_time` and `last_impression_time` fields in `Conversion` schema are now nullable
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rtbhouse-sdk"
version = "11.0.0"
version = "11.1.0"
description = "RTB House SDK"
authors = ["RTB House Apps Team <[email protected]>"]
license = "BSD License"
Expand Down
2 changes: 1 addition & 1 deletion rtbhouse_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""RTB House Python SDK."""
__version__ = "11.0.0"
__version__ = "11.1.0"
42 changes: 36 additions & 6 deletions rtbhouse_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,21 @@ def get_rtb_stats(
group_by: List[schema.StatsGroupBy],
metrics: List[schema.StatsMetric],
count_convention: Optional[schema.CountConvention] = None,
utc_offset_hours: int = 0,
subcampaigns: Optional[List[str]] = None,
user_segments: Optional[List[schema.UserSegment]] = None,
device_types: Optional[List[schema.DeviceType]] = None,
) -> List[schema.Stats]:
params = _build_rtb_stats_params(
day_from, day_to, group_by, metrics, count_convention, subcampaigns, user_segments, device_types
day_from,
day_to,
group_by,
metrics,
count_convention,
utc_offset_hours,
subcampaigns,
user_segments,
device_types,
)

data = self._get_list_of_dicts(f"/advertisers/{adv_hash}/rtb-stats", params)
Expand All @@ -221,9 +230,12 @@ def get_summary_stats(
group_by: List[schema.StatsGroupBy],
metrics: List[schema.StatsMetric],
count_convention: Optional[schema.CountConvention] = None,
utc_offset_hours: int = 0,
subcampaigns: Optional[List[str]] = None,
) -> List[schema.Stats]:
params = _build_summary_stats_params(day_from, day_to, group_by, metrics, count_convention, subcampaigns)
params = _build_summary_stats_params(
day_from, day_to, group_by, metrics, count_convention, utc_offset_hours, subcampaigns
)

data = self._get_list_of_dicts(f"/advertisers/{adv_hash}/summary-stats", params)
return [schema.Stats(**st) for st in data]
Expand Down Expand Up @@ -377,12 +389,21 @@ async def get_rtb_stats(
group_by: List[schema.StatsGroupBy],
metrics: List[schema.StatsMetric],
count_convention: Optional[schema.CountConvention] = None,
utc_offset_hours: int = 0,
subcampaigns: Optional[List[str]] = None,
user_segments: Optional[List[schema.UserSegment]] = None,
device_types: Optional[List[schema.DeviceType]] = None,
) -> List[schema.Stats]:
params = _build_rtb_stats_params(
day_from, day_to, group_by, metrics, count_convention, subcampaigns, user_segments, device_types
day_from,
day_to,
group_by,
metrics,
count_convention,
utc_offset_hours,
subcampaigns,
user_segments,
device_types,
)

data = await self._get_list_of_dicts(f"/advertisers/{adv_hash}/rtb-stats", params)
Expand All @@ -396,9 +417,12 @@ async def get_summary_stats(
group_by: List[schema.StatsGroupBy],
metrics: List[schema.StatsMetric],
count_convention: Optional[schema.CountConvention] = None,
utc_offset_hours: int = 0,
subcampaigns: Optional[List[str]] = None,
) -> List[schema.Stats]:
params = _build_summary_stats_params(day_from, day_to, group_by, metrics, count_convention, subcampaigns)
params = _build_summary_stats_params(
day_from, day_to, group_by, metrics, count_convention, utc_offset_hours, subcampaigns
)

data = await self._get_list_of_dicts(f"/advertisers/{adv_hash}/summary-stats", params)
return [schema.Stats(**st) for st in data]
Expand Down Expand Up @@ -495,18 +519,21 @@ def _build_rtb_stats_params(
group_by: List[schema.StatsGroupBy],
metrics: List[schema.StatsMetric],
count_convention: Optional[schema.CountConvention] = None,
utc_offset_hours: int = 0,
subcampaigns: Optional[List[str]] = None,
user_segments: Optional[List[schema.UserSegment]] = None,
device_types: Optional[List[schema.DeviceType]] = None,
) -> Dict[str, Any]:
params = {
params: Dict[str, Any] = {
"dayFrom": day_from,
"dayTo": day_to,
"groupBy": "-".join(gb.value for gb in group_by),
"metrics": "-".join(m.value for m in metrics),
}
if count_convention is not None:
params["countConvention"] = count_convention.value
if utc_offset_hours != 0:
params["utcOffsetHours"] = utc_offset_hours
if subcampaigns is not None:
params["subcampaigns"] = "-".join(str(sub) for sub in subcampaigns)
if user_segments is not None:
Expand All @@ -523,16 +550,19 @@ def _build_summary_stats_params(
group_by: List[schema.StatsGroupBy],
metrics: List[schema.StatsMetric],
count_convention: Optional[schema.CountConvention] = None,
utc_offset_hours: int = 0,
subcampaigns: Optional[List[str]] = None,
) -> Dict[str, Any]:
params = {
params: Dict[str, Any] = {
"dayFrom": day_from,
"dayTo": day_to,
"groupBy": "-".join(gb.value for gb in group_by),
"metrics": "-".join(m.value for m in metrics),
}
if count_convention is not None:
params["countConvention"] = count_convention.value
if utc_offset_hours != 0:
params["utcOffsetHours"] = utc_offset_hours
if subcampaigns is not None:
params["subcampaigns"] = "-".join(str(sub) for sub in subcampaigns)

Expand Down

0 comments on commit fccec61

Please sign in to comment.