paddle-python-sdk 1.17.0__py3-none-any.whl → 1.18.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- paddle_billing/Client.py +1 -1
- paddle_billing/Entities/Metrics/MetricsExplore.py +40 -0
- paddle_billing/Entities/Metrics/MetricsExplorePagination.py +33 -0
- paddle_billing/Entities/Metrics/MetricsExploreResponse.py +4 -0
- paddle_billing/Entities/Metrics/__init__.py +2 -0
- paddle_billing/Resources/Metrics/MetricsClient.py +12 -0
- paddle_billing/Resources/Metrics/Operations/ExploreMetrics.py +71 -0
- paddle_billing/Resources/Metrics/Operations/RunExploreMetricsQuery.py +10 -64
- paddle_billing/Resources/Metrics/Operations/__init__.py +3 -2
- {paddle_python_sdk-1.17.0.dist-info → paddle_python_sdk-1.18.0.dist-info}/METADATA +1 -1
- {paddle_python_sdk-1.17.0.dist-info → paddle_python_sdk-1.18.0.dist-info}/RECORD +15 -12
- tests/Functional/Resources/Metrics/test_MetricsExplore.py +97 -0
- {paddle_python_sdk-1.17.0.dist-info → paddle_python_sdk-1.18.0.dist-info}/WHEEL +0 -0
- {paddle_python_sdk-1.17.0.dist-info → paddle_python_sdk-1.18.0.dist-info}/licenses/LICENSE +0 -0
- {paddle_python_sdk-1.17.0.dist-info → paddle_python_sdk-1.18.0.dist-info}/top_level.txt +0 -0
paddle_billing/Client.py
CHANGED
|
@@ -217,7 +217,7 @@ class Client:
|
|
|
217
217
|
"Authorization": f"Bearer {self.__api_key}",
|
|
218
218
|
"Content-Type": "application/json",
|
|
219
219
|
"Paddle-Version": str(self.use_api_version),
|
|
220
|
-
"User-Agent": "PaddleSDK/python 1.
|
|
220
|
+
"User-Agent": "PaddleSDK/python 1.18.0",
|
|
221
221
|
}
|
|
222
222
|
)
|
|
223
223
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from paddle_billing.Entities.Metrics.MetricEntity import MetricEntity
|
|
7
|
+
from paddle_billing.Entities.Metrics.MetricsBucketInterval import MetricsBucketInterval
|
|
8
|
+
from paddle_billing.Entities.Metrics.MetricsExploreFields import MetricsExploreFields
|
|
9
|
+
from paddle_billing.Entities.Metrics.MetricsExplorePagination import MetricsExplorePagination
|
|
10
|
+
from paddle_billing.Entities.Metrics.MetricsExploreSeries import MetricsExploreSeries
|
|
11
|
+
from paddle_billing.Entities.Shared import CurrencyCode
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class MetricsExplore:
|
|
16
|
+
entity: MetricEntity
|
|
17
|
+
interval: MetricsBucketInterval
|
|
18
|
+
starts_at: datetime
|
|
19
|
+
ends_at: datetime
|
|
20
|
+
updated_at: datetime
|
|
21
|
+
fields: MetricsExploreFields
|
|
22
|
+
series: list[MetricsExploreSeries]
|
|
23
|
+
pagination: MetricsExplorePagination
|
|
24
|
+
currency_code: CurrencyCode | None = None
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def from_dict(body: dict[str, Any]) -> MetricsExplore:
|
|
28
|
+
data = body["data"]
|
|
29
|
+
|
|
30
|
+
return MetricsExplore(
|
|
31
|
+
entity=MetricEntity(data["entity"]),
|
|
32
|
+
interval=MetricsBucketInterval(data["interval"]),
|
|
33
|
+
starts_at=datetime.fromisoformat(data["starts_at"]),
|
|
34
|
+
ends_at=datetime.fromisoformat(data["ends_at"]),
|
|
35
|
+
updated_at=datetime.fromisoformat(data["updated_at"]),
|
|
36
|
+
fields=MetricsExploreFields.from_dict(data["fields"]),
|
|
37
|
+
series=[MetricsExploreSeries.from_dict(series) for series in data["series"]],
|
|
38
|
+
pagination=MetricsExplorePagination.from_dict(body["meta"]["pagination"]),
|
|
39
|
+
currency_code=CurrencyCode(data["currency_code"]) if data.get("currency_code") else None,
|
|
40
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Any
|
|
4
|
+
from urllib.parse import parse_qs, urlparse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class MetricsExplorePagination:
|
|
9
|
+
per_page: int
|
|
10
|
+
next: str
|
|
11
|
+
has_more: bool
|
|
12
|
+
estimated_total: int
|
|
13
|
+
# Explore pages by re-POSTing to `next`, which the SDK can't target, so pass this to explore() instead.
|
|
14
|
+
after: str | None
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def from_dict(data: dict[str, Any]) -> MetricsExplorePagination:
|
|
18
|
+
return MetricsExplorePagination(
|
|
19
|
+
per_page=data["per_page"],
|
|
20
|
+
next=data["next"],
|
|
21
|
+
has_more=data["has_more"],
|
|
22
|
+
estimated_total=data["estimated_total"],
|
|
23
|
+
after=MetricsExplorePagination._after(data["next"], data["has_more"]),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def _after(next_url: str, has_more: bool) -> str | None:
|
|
28
|
+
if not has_more or not next_url:
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
after = parse_qs(urlparse(next_url).query).get("after")
|
|
32
|
+
|
|
33
|
+
return after[0] if after else None
|
|
@@ -9,6 +9,10 @@ from paddle_billing.Entities.Shared import MetaPaginated
|
|
|
9
9
|
|
|
10
10
|
@dataclass
|
|
11
11
|
class MetricsExploreResponse:
|
|
12
|
+
"""
|
|
13
|
+
Deprecated: Returned by the deprecated run_explore_query(). Use explore(), which returns MetricsExplore.
|
|
14
|
+
"""
|
|
15
|
+
|
|
12
16
|
data: MetricsExploreData
|
|
13
17
|
meta: MetaPaginated
|
|
14
18
|
|
|
@@ -27,3 +27,5 @@ from paddle_billing.Entities.Metrics.MetricsExploreDataPoint import MetricsExplo
|
|
|
27
27
|
from paddle_billing.Entities.Metrics.MetricsExploreSeries import MetricsExploreSeries
|
|
28
28
|
from paddle_billing.Entities.Metrics.MetricsExploreData import MetricsExploreData
|
|
29
29
|
from paddle_billing.Entities.Metrics.MetricsExploreResponse import MetricsExploreResponse
|
|
30
|
+
from paddle_billing.Entities.Metrics.MetricsExplorePagination import MetricsExplorePagination
|
|
31
|
+
from paddle_billing.Entities.Metrics.MetricsExplore import MetricsExplore
|
|
@@ -4,6 +4,7 @@ from paddle_billing.Entities.Metrics.MetricEntityDefinition import MetricEntityD
|
|
|
4
4
|
from paddle_billing.Entities.Metrics.MetricsActiveSubscribers import MetricsActiveSubscribers
|
|
5
5
|
from paddle_billing.Entities.Metrics.MetricsChargebacks import MetricsChargebacks
|
|
6
6
|
from paddle_billing.Entities.Metrics.MetricsCheckoutConversion import MetricsCheckoutConversion
|
|
7
|
+
from paddle_billing.Entities.Metrics.MetricsExplore import MetricsExplore
|
|
7
8
|
from paddle_billing.Entities.Metrics.MetricsExploreResponse import MetricsExploreResponse
|
|
8
9
|
from paddle_billing.Entities.Metrics.MetricsMonthlyRecurringRevenue import MetricsMonthlyRecurringRevenue
|
|
9
10
|
from paddle_billing.Entities.Metrics.MetricsMonthlyRecurringRevenueChange import MetricsMonthlyRecurringRevenueChange
|
|
@@ -11,6 +12,7 @@ from paddle_billing.Entities.Metrics.MetricsRefunds import MetricsRefunds
|
|
|
11
12
|
from paddle_billing.Entities.Metrics.MetricsRevenue import MetricsRevenue
|
|
12
13
|
|
|
13
14
|
from paddle_billing.Resources.Metrics.Operations import (
|
|
15
|
+
ExploreMetrics,
|
|
14
16
|
GetMetrics,
|
|
15
17
|
ListExploreMetricEntities,
|
|
16
18
|
RunExploreMetricsQuery,
|
|
@@ -78,7 +80,17 @@ class MetricsClient:
|
|
|
78
80
|
|
|
79
81
|
return [MetricEntityDefinition.from_dict(entity) for entity in parser.get_list()]
|
|
80
82
|
|
|
83
|
+
def explore(self, operation: ExploreMetrics, after: str | None = None) -> MetricsExplore:
|
|
84
|
+
"""Pass the previous result's `pagination.after` as `after` to fetch the next page."""
|
|
85
|
+
parameters = {"after": after} if after else None
|
|
86
|
+
self.response = self.client.post_raw("/metrics/explore", operation, parameters)
|
|
87
|
+
|
|
88
|
+
return MetricsExplore.from_dict(self.response.json())
|
|
89
|
+
|
|
81
90
|
def run_explore_query(self, operation: RunExploreMetricsQuery, after: str | None = None) -> MetricsExploreResponse:
|
|
91
|
+
"""
|
|
92
|
+
Deprecated: Use explore() instead.
|
|
93
|
+
"""
|
|
82
94
|
parameters = {"after": after} if after else None
|
|
83
95
|
self.response = self.client.post_raw("/metrics/explore", operation, parameters)
|
|
84
96
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from datetime import date, datetime
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.DateTime import DateTime
|
|
6
|
+
from paddle_billing.Entities.Metrics import (
|
|
7
|
+
MetricEntity,
|
|
8
|
+
MetricsAggregation,
|
|
9
|
+
MetricsBucketInterval,
|
|
10
|
+
MetricsFilterOperator,
|
|
11
|
+
MetricsSortDirection,
|
|
12
|
+
)
|
|
13
|
+
from paddle_billing.Operation import Operation
|
|
14
|
+
from paddle_billing.Undefined import Undefined
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class ExploreMeasure:
|
|
19
|
+
field: str
|
|
20
|
+
agg: MetricsAggregation | None | Undefined = Undefined()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class ExploreFilter:
|
|
25
|
+
field: str
|
|
26
|
+
op: MetricsFilterOperator
|
|
27
|
+
value: list[str]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class ExploreOrderBy:
|
|
32
|
+
field: str
|
|
33
|
+
dir: MetricsSortDirection
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class ExploreMetrics(Operation):
|
|
38
|
+
entity: MetricEntity
|
|
39
|
+
date_from: DateTime | datetime | date | str
|
|
40
|
+
date_to: DateTime | datetime | date | str
|
|
41
|
+
measures: list[ExploreMeasure]
|
|
42
|
+
interval: MetricsBucketInterval | Undefined = Undefined()
|
|
43
|
+
dimensions: list[str] | Undefined = Undefined()
|
|
44
|
+
filters: list[ExploreFilter] | Undefined = Undefined()
|
|
45
|
+
order_by: list[ExploreOrderBy] | Undefined = Undefined()
|
|
46
|
+
per_page: int | Undefined = Undefined()
|
|
47
|
+
|
|
48
|
+
def to_json(self) -> dict[str, Any]:
|
|
49
|
+
payload = {
|
|
50
|
+
"entity": self.entity,
|
|
51
|
+
"from": self._format_boundary(self.date_from),
|
|
52
|
+
"to": self._format_boundary(self.date_to),
|
|
53
|
+
"measures": self.measures,
|
|
54
|
+
"interval": self.interval,
|
|
55
|
+
"dimensions": self.dimensions,
|
|
56
|
+
"filters": self.filters,
|
|
57
|
+
"order_by": self.order_by,
|
|
58
|
+
"per_page": self.per_page,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {key: value for key, value in payload.items() if not isinstance(value, Undefined)}
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def _format_boundary(value: DateTime | datetime | date | str) -> str:
|
|
65
|
+
if isinstance(value, datetime):
|
|
66
|
+
return str(DateTime.from_datetime(value))
|
|
67
|
+
|
|
68
|
+
if isinstance(value, date):
|
|
69
|
+
return value.isoformat()
|
|
70
|
+
|
|
71
|
+
return str(value)
|
|
@@ -1,71 +1,17 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from datetime import date, datetime
|
|
3
|
-
from typing import Any
|
|
4
2
|
|
|
5
|
-
from paddle_billing.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
MetricsFilterOperator,
|
|
11
|
-
MetricsSortDirection,
|
|
3
|
+
from paddle_billing.Resources.Metrics.Operations.ExploreMetrics import (
|
|
4
|
+
ExploreFilter,
|
|
5
|
+
ExploreMeasure,
|
|
6
|
+
ExploreMetrics,
|
|
7
|
+
ExploreOrderBy,
|
|
12
8
|
)
|
|
13
|
-
from paddle_billing.Operation import Operation
|
|
14
|
-
from paddle_billing.Undefined import Undefined
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
@dataclass
|
|
18
|
-
class ExploreMeasure:
|
|
19
|
-
field: str
|
|
20
|
-
agg: MetricsAggregation | None | Undefined = Undefined()
|
|
10
|
+
__all__ = ["ExploreFilter", "ExploreMeasure", "ExploreOrderBy", "RunExploreMetricsQuery"]
|
|
21
11
|
|
|
22
12
|
|
|
23
13
|
@dataclass
|
|
24
|
-
class
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@dataclass
|
|
31
|
-
class ExploreOrderBy:
|
|
32
|
-
field: str
|
|
33
|
-
dir: MetricsSortDirection
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@dataclass
|
|
37
|
-
class RunExploreMetricsQuery(Operation):
|
|
38
|
-
entity: MetricEntity
|
|
39
|
-
date_from: DateTime | datetime | date | str
|
|
40
|
-
date_to: DateTime | datetime | date | str
|
|
41
|
-
measures: list[ExploreMeasure]
|
|
42
|
-
interval: MetricsBucketInterval | Undefined = Undefined()
|
|
43
|
-
dimensions: list[str] | Undefined = Undefined()
|
|
44
|
-
filters: list[ExploreFilter] | Undefined = Undefined()
|
|
45
|
-
order_by: list[ExploreOrderBy] | Undefined = Undefined()
|
|
46
|
-
per_page: int | Undefined = Undefined()
|
|
47
|
-
|
|
48
|
-
def to_json(self) -> dict[str, Any]:
|
|
49
|
-
payload = {
|
|
50
|
-
"entity": self.entity,
|
|
51
|
-
"from": self._format_boundary(self.date_from),
|
|
52
|
-
"to": self._format_boundary(self.date_to),
|
|
53
|
-
"measures": self.measures,
|
|
54
|
-
"interval": self.interval,
|
|
55
|
-
"dimensions": self.dimensions,
|
|
56
|
-
"filters": self.filters,
|
|
57
|
-
"order_by": self.order_by,
|
|
58
|
-
"per_page": self.per_page,
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return {key: value for key, value in payload.items() if not isinstance(value, Undefined)}
|
|
62
|
-
|
|
63
|
-
@staticmethod
|
|
64
|
-
def _format_boundary(value: DateTime | datetime | date | str) -> str:
|
|
65
|
-
if isinstance(value, datetime):
|
|
66
|
-
return str(DateTime.from_datetime(value))
|
|
67
|
-
|
|
68
|
-
if isinstance(value, date):
|
|
69
|
-
return value.isoformat()
|
|
70
|
-
|
|
71
|
-
return str(value)
|
|
14
|
+
class RunExploreMetricsQuery(ExploreMetrics):
|
|
15
|
+
"""
|
|
16
|
+
Deprecated: Use ExploreMetrics with Client.metrics.explore() instead.
|
|
17
|
+
"""
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from paddle_billing.Resources.Metrics.Operations.GetMetrics import GetMetrics
|
|
2
2
|
from paddle_billing.Resources.Metrics.Operations.ListExploreMetricEntities import ListExploreMetricEntities
|
|
3
|
-
from paddle_billing.Resources.Metrics.Operations.
|
|
3
|
+
from paddle_billing.Resources.Metrics.Operations.ExploreMetrics import (
|
|
4
4
|
ExploreFilter,
|
|
5
5
|
ExploreMeasure,
|
|
6
|
+
ExploreMetrics,
|
|
6
7
|
ExploreOrderBy,
|
|
7
|
-
RunExploreMetricsQuery,
|
|
8
8
|
)
|
|
9
|
+
from paddle_billing.Resources.Metrics.Operations.RunExploreMetricsQuery import RunExploreMetricsQuery
|
|
@@ -5,7 +5,7 @@ examples/event_polling.py,sha256=580dg_8CFrSCA89Mr1ny4V1gtB3-hk-LfePTbI7DT5w,217
|
|
|
5
5
|
examples/get_products.py,sha256=9jLvKZlWLCpyYEt3voWjy50961-Uhdr0JlWD34ILxeQ,2176
|
|
6
6
|
examples/logger.py,sha256=nt7COp_4ChaIP-dhJ4rGHmj981-N4O41FDFzI8VlAFc,1041
|
|
7
7
|
examples/webhook_verification.py,sha256=qkNscNdNZUAgxEIk83tCiljN2VmfePZ_k8zTliKz2QY,1205
|
|
8
|
-
paddle_billing/Client.py,sha256=
|
|
8
|
+
paddle_billing/Client.py,sha256=4jPNqDWnBDgPPXf6JekO92CIcl-hgSkdVzCQc6w5Dww,10342
|
|
9
9
|
paddle_billing/EnumStringify.py,sha256=iDvKULZat3jx9A-_PhvoN6CbFGf2pyxrQeYZxqX9n8M,48
|
|
10
10
|
paddle_billing/Environment.py,sha256=sY4nrJUwlTugsZKncieAnvfCojqCcKWi4X7rFzjFeSQ,417
|
|
11
11
|
paddle_billing/FiltersNone.py,sha256=ErOjaTfxtELXrXdxUvFF9DJI_Yl31iseO4K56qTDR54,303
|
|
@@ -140,12 +140,14 @@ paddle_billing/Entities/Metrics/MetricsChargebacks.py,sha256=VRYSPjqsZfiFLXrUpac
|
|
|
140
140
|
paddle_billing/Entities/Metrics/MetricsCheckoutConversion.py,sha256=CjcLyEnEHS6PjTk_g-JkrhAPztTZYmLJvY1xtBxHUS0,1077
|
|
141
141
|
paddle_billing/Entities/Metrics/MetricsCheckoutConversionDatapoint.py,sha256=UkzdmMSmel0CFAq7PZqr5f-JR9FEBNw4pLDoMdE2P-s,596
|
|
142
142
|
paddle_billing/Entities/Metrics/MetricsCountDatapoint.py,sha256=_LCtQud3fwB0PP7JlwVL7HzqfzBFgWMU2vGt_NDL5A8,434
|
|
143
|
+
paddle_billing/Entities/Metrics/MetricsExplore.py,sha256=514_LdmBB2aqFe568NGXa8Z9UIrZh3NV_RpNqo73r20,1727
|
|
143
144
|
paddle_billing/Entities/Metrics/MetricsExploreData.py,sha256=I3hgEg8fXjuC_xvPcO2RHVPF6pK4t91AGhLUXOlgXd8,1546
|
|
144
145
|
paddle_billing/Entities/Metrics/MetricsExploreDataPoint.py,sha256=yS_CYXplFpxRYe429KPHoIeTyznWXg0EUk0q61a6aww,372
|
|
145
146
|
paddle_billing/Entities/Metrics/MetricsExploreFieldDimension.py,sha256=kGr6_4LT_5-L1yZIg6Angf-jOFFo273KLgFTicLipy8,453
|
|
146
147
|
paddle_billing/Entities/Metrics/MetricsExploreFieldMeasure.py,sha256=z6ZPV8LeEwmdmNRxCNDQq7LN9yYHvEYHX1go-3ICACE,750
|
|
147
148
|
paddle_billing/Entities/Metrics/MetricsExploreFields.py,sha256=YjheOVNGfIqYB0-2dTHNWsWdPg6s1nRIaUkDtRtGUCg,777
|
|
148
|
-
paddle_billing/Entities/Metrics/
|
|
149
|
+
paddle_billing/Entities/Metrics/MetricsExplorePagination.py,sha256=zbl_rR5cxX9vMCtuvndBtHzbdXKeaMUuSeUJ_peIA-M,1025
|
|
150
|
+
paddle_billing/Entities/Metrics/MetricsExploreResponse.py,sha256=d0ReQv9nfGqBz2Ohh-W-vCFKrd4rykvIBLOrDjWv3Ws,1213
|
|
149
151
|
paddle_billing/Entities/Metrics/MetricsExploreSeries.py,sha256=4F49Xa5KxBshRfG7vU7s_t_IaQLQSCufnh_3_lieACo,582
|
|
150
152
|
paddle_billing/Entities/Metrics/MetricsFieldType.py,sha256=eue5Ulozlh54vjPkotpjPwFPom5WDTSdhAWD5P0OQdY,320
|
|
151
153
|
paddle_billing/Entities/Metrics/MetricsFilterOperator.py,sha256=KV2IqhyAeACzK16xWd__9dRei_gv4YA9IrHRvhsfLp4,188
|
|
@@ -156,7 +158,7 @@ paddle_billing/Entities/Metrics/MetricsRefunds.py,sha256=Y9Z2g8-4FLQXjoAnQPJgW4s
|
|
|
156
158
|
paddle_billing/Entities/Metrics/MetricsRevenue.py,sha256=g_V9QLVRCJESV0unm4bFOsjd62u8bYi_m_wbRN_tdIY,1151
|
|
157
159
|
paddle_billing/Entities/Metrics/MetricsRevenueDatapoint.py,sha256=iIYXRi8qOxPk1IQ3HwbBh7caByCOrkXtkdftb9_EpI4,491
|
|
158
160
|
paddle_billing/Entities/Metrics/MetricsSortDirection.py,sha256=HtkXgxaB6O6HTWUsFltB1UZAMk_fnmK6YzHlu8YhC8c,230
|
|
159
|
-
paddle_billing/Entities/Metrics/__init__.py,sha256=
|
|
161
|
+
paddle_billing/Entities/Metrics/__init__.py,sha256=z4_aGRXWn0xse2NlIn20ssmYGaqSGbuqpJnJdAY38Bs,2758
|
|
160
162
|
paddle_billing/Entities/NotificationSettings/NotificationSettingTrafficSource.py,sha256=5jga7qMivQXyU55XOPMGvwsLO1wEPA0Mur40knDgEks,340
|
|
161
163
|
paddle_billing/Entities/NotificationSettings/NotificationSettingType.py,sha256=zm3kpN5T5QkKp3-3JUpZphUrXCD992OkClAIahqxbns,241
|
|
162
164
|
paddle_billing/Entities/NotificationSettings/__init__.py,sha256=OTmdXcuJiirwGjTvUkz5ZnT3wLPCszzUcbskRpMdYhU,237
|
|
@@ -719,12 +721,13 @@ paddle_billing/Resources/Events/Operations/ListEvents.py,sha256=7kag3MNV4qlCn9on
|
|
|
719
721
|
paddle_billing/Resources/Events/Operations/__init__.py,sha256=Nfec716BOJ20W54RBd3DGLB0tzhjrCHY2t_Ym_LcO58,77
|
|
720
722
|
paddle_billing/Resources/IPAddresses/IPAddressesClient.py,sha256=k9Z-dusJ-ASguBqxbvDQzUZgg_oL0rQLrSnPVIsoYZo,547
|
|
721
723
|
paddle_billing/Resources/IPAddresses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
722
|
-
paddle_billing/Resources/Metrics/MetricsClient.py,sha256=
|
|
724
|
+
paddle_billing/Resources/Metrics/MetricsClient.py,sha256=DeqoKcjzOlEYszkG7Jdh0_zpHNGClf0iqDOh_nL6-8k,4721
|
|
723
725
|
paddle_billing/Resources/Metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
726
|
+
paddle_billing/Resources/Metrics/Operations/ExploreMetrics.py,sha256=pFfkN60QOZQUbKrX3UwhXpxho2aV2Jcv7ZV7-87jmMI,2025
|
|
724
727
|
paddle_billing/Resources/Metrics/Operations/GetMetrics.py,sha256=ENwwNy0FA8cO8JJH0dSUMeSH-oKfpDI6aTPXrhGU62M,975
|
|
725
728
|
paddle_billing/Resources/Metrics/Operations/ListExploreMetricEntities.py,sha256=upYYVJ6XLO2qyIUjC5nrR3P_jNchs7p7r3_QL5aVsPo,400
|
|
726
|
-
paddle_billing/Resources/Metrics/Operations/RunExploreMetricsQuery.py,sha256=
|
|
727
|
-
paddle_billing/Resources/Metrics/Operations/__init__.py,sha256=
|
|
729
|
+
paddle_billing/Resources/Metrics/Operations/RunExploreMetricsQuery.py,sha256=xOklrb1CxKHR5EcvjWR6A03lsbqxVo2HO7q3Tw9qb2k,429
|
|
730
|
+
paddle_billing/Resources/Metrics/Operations/__init__.py,sha256=6LADKijhxyBX0YO2Bpnzesr8mH4ukvGRzGFgkhIxing,442
|
|
728
731
|
paddle_billing/Resources/NotificationLogs/NotificationLogsClient.py,sha256=ZZh5MSJsfexbYDmraK-ieaU8jk9Wb0TFGAvPkiAUOYg,985
|
|
729
732
|
paddle_billing/Resources/NotificationLogs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
730
733
|
paddle_billing/Resources/NotificationLogs/Operations/ListNotificationLogs.py,sha256=DVLNrxY7C2ZVv2MT6SrxjdHbjV5fJPWa7Ay5fk3Asw8,354
|
|
@@ -929,7 +932,7 @@ paddle_billing/Resources/Verifications/VerificationsClient.py,sha256=p6xajJs57aH
|
|
|
929
932
|
paddle_billing/Resources/Verifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
930
933
|
paddle_billing/Resources/Verifications/Operations/ListVerifications.py,sha256=w5kll1AvI1xKaWRLmub7Y9U00v8PP39zylXnAFgLflQ,1402
|
|
931
934
|
paddle_billing/Resources/Verifications/Operations/__init__.py,sha256=UQG2dz1bt1ulku5Bv4mt1aKpG9BksKh4Jv-SeemZ5nQ,98
|
|
932
|
-
paddle_python_sdk-1.
|
|
935
|
+
paddle_python_sdk-1.18.0.dist-info/licenses/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
|
|
933
936
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
934
937
|
tests/conftest.py,sha256=K_rWFm4jOBGVpoQP9llOwQwyYrXThbF3CBvood_hNRU,127
|
|
935
938
|
tests/Functional/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -970,7 +973,7 @@ tests/Functional/Resources/IPAddresses/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JC
|
|
|
970
973
|
tests/Functional/Resources/IPAddresses/test_IPAddressesClient.py,sha256=XpEdHyjdJcT9dokUGiTHhLBff7tgzfxf2KsE7kCtfaU,1113
|
|
971
974
|
tests/Functional/Resources/Metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
972
975
|
tests/Functional/Resources/Metrics/test_MetricsClient.py,sha256=4mIX3D-uKk2B2M9CJgRTToCH3ou37otpoBwWMPx2Qwo,4582
|
|
973
|
-
tests/Functional/Resources/Metrics/test_MetricsExplore.py,sha256=
|
|
976
|
+
tests/Functional/Resources/Metrics/test_MetricsExplore.py,sha256=S61x5gREs7Bl4xS_EDvoEGhPqj-9xCP_sllX_Zmr52E,13411
|
|
974
977
|
tests/Functional/Resources/NotificationLogs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
975
978
|
tests/Functional/Resources/NotificationLogs/test_NotificationLogsClient.py,sha256=w_MQFU2rxZ6Cg8sHL9Yra4w7l5-Te1qfq5VPisD5PZ0,2665
|
|
976
979
|
tests/Functional/Resources/NotificationSettings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -1015,7 +1018,7 @@ tests/Utils/ReadsFixture.py,sha256=3CQ_8XHji3kuR28Ktlmw1Kip565UycocUytldWtuAyw,1
|
|
|
1015
1018
|
tests/Utils/TestClient.py,sha256=-wc7hJMuR6WC-ukw0c7I59b5-8hj_-nzq__-2M81elg,1453
|
|
1016
1019
|
tests/Utils/TestLogger.py,sha256=pFO9x711buRmg-8DAqpzIJP_hr21JPty1_ZQRcwoGKk,554
|
|
1017
1020
|
tests/Utils/__init__.py,sha256=JtqJNPKqbNZ9exlpXlF3yj_9cfylPGlvopjQYi7yYTA,37
|
|
1018
|
-
paddle_python_sdk-1.
|
|
1019
|
-
paddle_python_sdk-1.
|
|
1020
|
-
paddle_python_sdk-1.
|
|
1021
|
-
paddle_python_sdk-1.
|
|
1021
|
+
paddle_python_sdk-1.18.0.dist-info/METADATA,sha256=9YROoqDYt2OWEVbmQPo35K_JRgFg6Dqt0UElDOF6bqs,8977
|
|
1022
|
+
paddle_python_sdk-1.18.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
1023
|
+
paddle_python_sdk-1.18.0.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
|
|
1024
|
+
paddle_python_sdk-1.18.0.dist-info/RECORD,,
|
|
@@ -6,6 +6,7 @@ from paddle_billing.Entities.Metrics import (
|
|
|
6
6
|
MetricEntityDefinition,
|
|
7
7
|
MetricsAggregation,
|
|
8
8
|
MetricsBucketInterval,
|
|
9
|
+
MetricsExplore,
|
|
9
10
|
MetricsExploreResponse,
|
|
10
11
|
MetricsFieldType,
|
|
11
12
|
MetricsFilterOperator,
|
|
@@ -15,6 +16,7 @@ from paddle_billing.Entities.Shared import CurrencyCode
|
|
|
15
16
|
from paddle_billing.Resources.Metrics.Operations import (
|
|
16
17
|
ExploreFilter,
|
|
17
18
|
ExploreMeasure,
|
|
19
|
+
ExploreMetrics,
|
|
18
20
|
ExploreOrderBy,
|
|
19
21
|
ListExploreMetricEntities,
|
|
20
22
|
RunExploreMetricsQuery,
|
|
@@ -187,3 +189,98 @@ class TestMetricsExploreQuery:
|
|
|
187
189
|
assert second.data.series[0].dimensions == {"product": "pro_01h1vjfevh5etwq3rb416a23h3"}
|
|
188
190
|
assert second.has_more is False
|
|
189
191
|
assert second.next_cursor is None
|
|
192
|
+
|
|
193
|
+
def test_explore_sends_full_body_and_parses_flat_response(self, test_client, mock_requests):
|
|
194
|
+
body = ReadsFixtures.read_raw_json_fixture("response/explore")
|
|
195
|
+
url = f"{test_client.base_url}/metrics/explore"
|
|
196
|
+
mock_requests.post(url, status_code=200, text=body)
|
|
197
|
+
|
|
198
|
+
result = test_client.client.metrics.explore(
|
|
199
|
+
ExploreMetrics(
|
|
200
|
+
entity=MetricEntity.TransactionsCompleted,
|
|
201
|
+
date_from=datetime(2026, 5, 1, tzinfo=timezone.utc),
|
|
202
|
+
date_to=date(2026, 8, 1),
|
|
203
|
+
measures=[ExploreMeasure(field="gross_revenue", agg=MetricsAggregation.Sum)],
|
|
204
|
+
interval=MetricsBucketInterval.Month,
|
|
205
|
+
dimensions=["product"],
|
|
206
|
+
order_by=[ExploreOrderBy(field="gross_revenue", dir=MetricsSortDirection.Desc)],
|
|
207
|
+
per_page=5,
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
request = mock_requests.last_request
|
|
212
|
+
assert request.method == "POST"
|
|
213
|
+
assert request.url == url
|
|
214
|
+
assert loads(request.text) == {
|
|
215
|
+
"entity": "transactions.completed",
|
|
216
|
+
"from": "2026-05-01T00:00:00.000000Z",
|
|
217
|
+
"to": "2026-08-01",
|
|
218
|
+
"measures": [{"field": "gross_revenue", "agg": "sum"}],
|
|
219
|
+
"interval": "month",
|
|
220
|
+
"dimensions": ["product"],
|
|
221
|
+
"order_by": [{"field": "gross_revenue", "dir": "desc"}],
|
|
222
|
+
"per_page": 5,
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
assert isinstance(result, MetricsExplore)
|
|
226
|
+
assert result.entity == MetricEntity.TransactionsCompleted
|
|
227
|
+
assert result.interval == MetricsBucketInterval.Month
|
|
228
|
+
assert result.currency_code == CurrencyCode.USD
|
|
229
|
+
assert result.starts_at == datetime(2026, 5, 1, tzinfo=timezone.utc)
|
|
230
|
+
assert result.ends_at == datetime(2026, 8, 1, tzinfo=timezone.utc)
|
|
231
|
+
assert result.updated_at == datetime(2026, 8, 1, 3, tzinfo=timezone.utc)
|
|
232
|
+
assert result.fields.measures[0].name == "sum_gross_revenue"
|
|
233
|
+
assert result.series[0].dimensions == {"product": "pro_01h1vjfevh5etwq3rb416a23h2"}
|
|
234
|
+
assert result.series[0].timeseries[2].measures == {"sum_gross_revenue": "142000"}
|
|
235
|
+
|
|
236
|
+
assert result.pagination.per_page == 5
|
|
237
|
+
assert result.pagination.has_more is True
|
|
238
|
+
assert result.pagination.estimated_total == 42
|
|
239
|
+
assert result.pagination.next == f"https://api.paddle.com/metrics/explore?after={FIRST_CURSOR}"
|
|
240
|
+
assert result.pagination.after == FIRST_CURSOR
|
|
241
|
+
|
|
242
|
+
def test_explore_follows_pagination_after(self, test_client, mock_requests):
|
|
243
|
+
first_page = ReadsFixtures.read_raw_json_fixture("response/explore")
|
|
244
|
+
last_page = ReadsFixtures.read_raw_json_fixture("response/explore_last_page")
|
|
245
|
+
url = f"{test_client.base_url}/metrics/explore"
|
|
246
|
+
mock_requests.post(url, status_code=200, text=first_page)
|
|
247
|
+
mock_requests.post(f"{url}?after={FIRST_CURSOR}", status_code=200, text=last_page)
|
|
248
|
+
|
|
249
|
+
operation = ExploreMetrics(
|
|
250
|
+
entity=MetricEntity.TransactionsCompleted,
|
|
251
|
+
date_from="2026-05-01",
|
|
252
|
+
date_to="2026-08-01",
|
|
253
|
+
measures=[ExploreMeasure(field="gross_revenue", agg=MetricsAggregation.Sum)],
|
|
254
|
+
dimensions=["product"],
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
first = test_client.client.metrics.explore(operation)
|
|
258
|
+
assert mock_requests.last_request.url == url
|
|
259
|
+
|
|
260
|
+
second = test_client.client.metrics.explore(operation, after=first.pagination.after)
|
|
261
|
+
|
|
262
|
+
assert mock_requests.last_request.url == f"{url}?after={FIRST_CURSOR}"
|
|
263
|
+
assert second.series[0].dimensions == {"product": "pro_01h1vjfevh5etwq3rb416a23h3"}
|
|
264
|
+
assert second.pagination.has_more is False
|
|
265
|
+
assert second.pagination.after is None
|
|
266
|
+
|
|
267
|
+
def test_explore_accepts_deprecated_run_explore_metrics_query(self, test_client, mock_requests):
|
|
268
|
+
body = ReadsFixtures.read_raw_json_fixture("response/explore")
|
|
269
|
+
mock_requests.post(f"{test_client.base_url}/metrics/explore", status_code=200, text=body)
|
|
270
|
+
|
|
271
|
+
result = test_client.client.metrics.explore(
|
|
272
|
+
RunExploreMetricsQuery(
|
|
273
|
+
entity=MetricEntity.Checkouts,
|
|
274
|
+
date_from="2026-05-01",
|
|
275
|
+
date_to="2026-08-01",
|
|
276
|
+
measures=[ExploreMeasure(field="count")],
|
|
277
|
+
)
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
assert isinstance(result, MetricsExplore)
|
|
281
|
+
assert loads(mock_requests.last_request.text) == {
|
|
282
|
+
"entity": "checkouts",
|
|
283
|
+
"from": "2026-05-01",
|
|
284
|
+
"to": "2026-08-01",
|
|
285
|
+
"measures": [{"field": "count"}],
|
|
286
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|