dub 0.24.0__py3-none-any.whl → 0.25.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.
- dub/_version.py +3 -3
- dub/commissions.py +600 -0
- dub/models/__init__.py +0 -1
- dub/models/components/__init__.py +422 -196
- dub/models/components/folderschema.py +1 -7
- dub/models/errors/__init__.py +136 -58
- dub/models/operations/__init__.py +729 -360
- dub/models/operations/createpartner.py +3 -3
- dub/models/operations/listcommissions.py +252 -0
- dub/models/operations/listfolders.py +0 -9
- dub/models/operations/updatecommission.py +150 -0
- dub/partners.py +0 -310
- dub/sdk.py +71 -40
- dub/utils/__init__.py +130 -46
- {dub-0.24.0.dist-info → dub-0.25.0.dist-info}/METADATA +6 -2
- {dub-0.24.0.dist-info → dub-0.25.0.dist-info}/RECORD +18 -16
- dub/models/operations/updatepartnersale.py +0 -121
- {dub-0.24.0.dist-info → dub-0.25.0.dist-info}/LICENSE +0 -0
- {dub-0.24.0.dist-info → dub-0.25.0.dist-info}/WHEEL +0 -0
dub/partners.py
CHANGED
|
@@ -1504,313 +1504,3 @@ class Partners(BaseSDK):
|
|
|
1504
1504
|
http_res_text,
|
|
1505
1505
|
http_res,
|
|
1506
1506
|
)
|
|
1507
|
-
|
|
1508
|
-
def update_sale(
|
|
1509
|
-
self,
|
|
1510
|
-
*,
|
|
1511
|
-
request: Optional[
|
|
1512
|
-
Union[
|
|
1513
|
-
operations.UpdatePartnerSaleRequestBody,
|
|
1514
|
-
operations.UpdatePartnerSaleRequestBodyTypedDict,
|
|
1515
|
-
]
|
|
1516
|
-
] = None,
|
|
1517
|
-
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1518
|
-
server_url: Optional[str] = None,
|
|
1519
|
-
timeout_ms: Optional[int] = None,
|
|
1520
|
-
http_headers: Optional[Mapping[str, str]] = None,
|
|
1521
|
-
) -> Optional[operations.UpdatePartnerSaleResponseBody]:
|
|
1522
|
-
r"""Update a sale for a partner.
|
|
1523
|
-
|
|
1524
|
-
Update an existing sale amount. This is useful for handling refunds (partial or full) or fraudulent sales.
|
|
1525
|
-
|
|
1526
|
-
:param request: The request object to send.
|
|
1527
|
-
:param retries: Override the default retry configuration for this method
|
|
1528
|
-
:param server_url: Override the default server URL for this method
|
|
1529
|
-
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1530
|
-
:param http_headers: Additional headers to set or replace on requests.
|
|
1531
|
-
"""
|
|
1532
|
-
base_url = None
|
|
1533
|
-
url_variables = None
|
|
1534
|
-
if timeout_ms is None:
|
|
1535
|
-
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1536
|
-
|
|
1537
|
-
if server_url is not None:
|
|
1538
|
-
base_url = server_url
|
|
1539
|
-
else:
|
|
1540
|
-
base_url = self._get_url(base_url, url_variables)
|
|
1541
|
-
|
|
1542
|
-
if not isinstance(request, BaseModel):
|
|
1543
|
-
request = utils.unmarshal(
|
|
1544
|
-
request, Optional[operations.UpdatePartnerSaleRequestBody]
|
|
1545
|
-
)
|
|
1546
|
-
request = cast(Optional[operations.UpdatePartnerSaleRequestBody], request)
|
|
1547
|
-
|
|
1548
|
-
req = self._build_request(
|
|
1549
|
-
method="PATCH",
|
|
1550
|
-
path="/partners/sales",
|
|
1551
|
-
base_url=base_url,
|
|
1552
|
-
url_variables=url_variables,
|
|
1553
|
-
request=request,
|
|
1554
|
-
request_body_required=False,
|
|
1555
|
-
request_has_path_params=False,
|
|
1556
|
-
request_has_query_params=True,
|
|
1557
|
-
user_agent_header="user-agent",
|
|
1558
|
-
accept_header_value="application/json",
|
|
1559
|
-
http_headers=http_headers,
|
|
1560
|
-
security=self.sdk_configuration.security,
|
|
1561
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1562
|
-
request,
|
|
1563
|
-
False,
|
|
1564
|
-
True,
|
|
1565
|
-
"json",
|
|
1566
|
-
Optional[operations.UpdatePartnerSaleRequestBody],
|
|
1567
|
-
),
|
|
1568
|
-
timeout_ms=timeout_ms,
|
|
1569
|
-
)
|
|
1570
|
-
|
|
1571
|
-
if retries == UNSET:
|
|
1572
|
-
if self.sdk_configuration.retry_config is not UNSET:
|
|
1573
|
-
retries = self.sdk_configuration.retry_config
|
|
1574
|
-
|
|
1575
|
-
retry_config = None
|
|
1576
|
-
if isinstance(retries, utils.RetryConfig):
|
|
1577
|
-
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1578
|
-
|
|
1579
|
-
http_res = self.do_request(
|
|
1580
|
-
hook_ctx=HookContext(
|
|
1581
|
-
base_url=base_url or "",
|
|
1582
|
-
operation_id="updatePartnerSale",
|
|
1583
|
-
oauth2_scopes=[],
|
|
1584
|
-
security_source=self.sdk_configuration.security,
|
|
1585
|
-
),
|
|
1586
|
-
request=req,
|
|
1587
|
-
error_status_codes=[
|
|
1588
|
-
"400",
|
|
1589
|
-
"401",
|
|
1590
|
-
"403",
|
|
1591
|
-
"404",
|
|
1592
|
-
"409",
|
|
1593
|
-
"410",
|
|
1594
|
-
"422",
|
|
1595
|
-
"429",
|
|
1596
|
-
"4XX",
|
|
1597
|
-
"500",
|
|
1598
|
-
"5XX",
|
|
1599
|
-
],
|
|
1600
|
-
retry_config=retry_config,
|
|
1601
|
-
)
|
|
1602
|
-
|
|
1603
|
-
response_data: Any = None
|
|
1604
|
-
if utils.match_response(http_res, "200", "application/json"):
|
|
1605
|
-
return utils.unmarshal_json(
|
|
1606
|
-
http_res.text, Optional[operations.UpdatePartnerSaleResponseBody]
|
|
1607
|
-
)
|
|
1608
|
-
if utils.match_response(http_res, "400", "application/json"):
|
|
1609
|
-
response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
|
|
1610
|
-
raise errors.BadRequest(data=response_data)
|
|
1611
|
-
if utils.match_response(http_res, "401", "application/json"):
|
|
1612
|
-
response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
|
|
1613
|
-
raise errors.Unauthorized(data=response_data)
|
|
1614
|
-
if utils.match_response(http_res, "403", "application/json"):
|
|
1615
|
-
response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
|
|
1616
|
-
raise errors.Forbidden(data=response_data)
|
|
1617
|
-
if utils.match_response(http_res, "404", "application/json"):
|
|
1618
|
-
response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
|
|
1619
|
-
raise errors.NotFound(data=response_data)
|
|
1620
|
-
if utils.match_response(http_res, "409", "application/json"):
|
|
1621
|
-
response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
|
|
1622
|
-
raise errors.Conflict(data=response_data)
|
|
1623
|
-
if utils.match_response(http_res, "410", "application/json"):
|
|
1624
|
-
response_data = utils.unmarshal_json(
|
|
1625
|
-
http_res.text, errors.InviteExpiredData
|
|
1626
|
-
)
|
|
1627
|
-
raise errors.InviteExpired(data=response_data)
|
|
1628
|
-
if utils.match_response(http_res, "422", "application/json"):
|
|
1629
|
-
response_data = utils.unmarshal_json(
|
|
1630
|
-
http_res.text, errors.UnprocessableEntityData
|
|
1631
|
-
)
|
|
1632
|
-
raise errors.UnprocessableEntity(data=response_data)
|
|
1633
|
-
if utils.match_response(http_res, "429", "application/json"):
|
|
1634
|
-
response_data = utils.unmarshal_json(
|
|
1635
|
-
http_res.text, errors.RateLimitExceededData
|
|
1636
|
-
)
|
|
1637
|
-
raise errors.RateLimitExceeded(data=response_data)
|
|
1638
|
-
if utils.match_response(http_res, "500", "application/json"):
|
|
1639
|
-
response_data = utils.unmarshal_json(
|
|
1640
|
-
http_res.text, errors.InternalServerErrorData
|
|
1641
|
-
)
|
|
1642
|
-
raise errors.InternalServerError(data=response_data)
|
|
1643
|
-
if utils.match_response(http_res, "4XX", "*"):
|
|
1644
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
1645
|
-
raise errors.SDKError(
|
|
1646
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1647
|
-
)
|
|
1648
|
-
if utils.match_response(http_res, "5XX", "*"):
|
|
1649
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
1650
|
-
raise errors.SDKError(
|
|
1651
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1652
|
-
)
|
|
1653
|
-
|
|
1654
|
-
content_type = http_res.headers.get("Content-Type")
|
|
1655
|
-
http_res_text = utils.stream_to_text(http_res)
|
|
1656
|
-
raise errors.SDKError(
|
|
1657
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1658
|
-
http_res.status_code,
|
|
1659
|
-
http_res_text,
|
|
1660
|
-
http_res,
|
|
1661
|
-
)
|
|
1662
|
-
|
|
1663
|
-
async def update_sale_async(
|
|
1664
|
-
self,
|
|
1665
|
-
*,
|
|
1666
|
-
request: Optional[
|
|
1667
|
-
Union[
|
|
1668
|
-
operations.UpdatePartnerSaleRequestBody,
|
|
1669
|
-
operations.UpdatePartnerSaleRequestBodyTypedDict,
|
|
1670
|
-
]
|
|
1671
|
-
] = None,
|
|
1672
|
-
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1673
|
-
server_url: Optional[str] = None,
|
|
1674
|
-
timeout_ms: Optional[int] = None,
|
|
1675
|
-
http_headers: Optional[Mapping[str, str]] = None,
|
|
1676
|
-
) -> Optional[operations.UpdatePartnerSaleResponseBody]:
|
|
1677
|
-
r"""Update a sale for a partner.
|
|
1678
|
-
|
|
1679
|
-
Update an existing sale amount. This is useful for handling refunds (partial or full) or fraudulent sales.
|
|
1680
|
-
|
|
1681
|
-
:param request: The request object to send.
|
|
1682
|
-
:param retries: Override the default retry configuration for this method
|
|
1683
|
-
:param server_url: Override the default server URL for this method
|
|
1684
|
-
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1685
|
-
:param http_headers: Additional headers to set or replace on requests.
|
|
1686
|
-
"""
|
|
1687
|
-
base_url = None
|
|
1688
|
-
url_variables = None
|
|
1689
|
-
if timeout_ms is None:
|
|
1690
|
-
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1691
|
-
|
|
1692
|
-
if server_url is not None:
|
|
1693
|
-
base_url = server_url
|
|
1694
|
-
else:
|
|
1695
|
-
base_url = self._get_url(base_url, url_variables)
|
|
1696
|
-
|
|
1697
|
-
if not isinstance(request, BaseModel):
|
|
1698
|
-
request = utils.unmarshal(
|
|
1699
|
-
request, Optional[operations.UpdatePartnerSaleRequestBody]
|
|
1700
|
-
)
|
|
1701
|
-
request = cast(Optional[operations.UpdatePartnerSaleRequestBody], request)
|
|
1702
|
-
|
|
1703
|
-
req = self._build_request_async(
|
|
1704
|
-
method="PATCH",
|
|
1705
|
-
path="/partners/sales",
|
|
1706
|
-
base_url=base_url,
|
|
1707
|
-
url_variables=url_variables,
|
|
1708
|
-
request=request,
|
|
1709
|
-
request_body_required=False,
|
|
1710
|
-
request_has_path_params=False,
|
|
1711
|
-
request_has_query_params=True,
|
|
1712
|
-
user_agent_header="user-agent",
|
|
1713
|
-
accept_header_value="application/json",
|
|
1714
|
-
http_headers=http_headers,
|
|
1715
|
-
security=self.sdk_configuration.security,
|
|
1716
|
-
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1717
|
-
request,
|
|
1718
|
-
False,
|
|
1719
|
-
True,
|
|
1720
|
-
"json",
|
|
1721
|
-
Optional[operations.UpdatePartnerSaleRequestBody],
|
|
1722
|
-
),
|
|
1723
|
-
timeout_ms=timeout_ms,
|
|
1724
|
-
)
|
|
1725
|
-
|
|
1726
|
-
if retries == UNSET:
|
|
1727
|
-
if self.sdk_configuration.retry_config is not UNSET:
|
|
1728
|
-
retries = self.sdk_configuration.retry_config
|
|
1729
|
-
|
|
1730
|
-
retry_config = None
|
|
1731
|
-
if isinstance(retries, utils.RetryConfig):
|
|
1732
|
-
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1733
|
-
|
|
1734
|
-
http_res = await self.do_request_async(
|
|
1735
|
-
hook_ctx=HookContext(
|
|
1736
|
-
base_url=base_url or "",
|
|
1737
|
-
operation_id="updatePartnerSale",
|
|
1738
|
-
oauth2_scopes=[],
|
|
1739
|
-
security_source=self.sdk_configuration.security,
|
|
1740
|
-
),
|
|
1741
|
-
request=req,
|
|
1742
|
-
error_status_codes=[
|
|
1743
|
-
"400",
|
|
1744
|
-
"401",
|
|
1745
|
-
"403",
|
|
1746
|
-
"404",
|
|
1747
|
-
"409",
|
|
1748
|
-
"410",
|
|
1749
|
-
"422",
|
|
1750
|
-
"429",
|
|
1751
|
-
"4XX",
|
|
1752
|
-
"500",
|
|
1753
|
-
"5XX",
|
|
1754
|
-
],
|
|
1755
|
-
retry_config=retry_config,
|
|
1756
|
-
)
|
|
1757
|
-
|
|
1758
|
-
response_data: Any = None
|
|
1759
|
-
if utils.match_response(http_res, "200", "application/json"):
|
|
1760
|
-
return utils.unmarshal_json(
|
|
1761
|
-
http_res.text, Optional[operations.UpdatePartnerSaleResponseBody]
|
|
1762
|
-
)
|
|
1763
|
-
if utils.match_response(http_res, "400", "application/json"):
|
|
1764
|
-
response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
|
|
1765
|
-
raise errors.BadRequest(data=response_data)
|
|
1766
|
-
if utils.match_response(http_res, "401", "application/json"):
|
|
1767
|
-
response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
|
|
1768
|
-
raise errors.Unauthorized(data=response_data)
|
|
1769
|
-
if utils.match_response(http_res, "403", "application/json"):
|
|
1770
|
-
response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
|
|
1771
|
-
raise errors.Forbidden(data=response_data)
|
|
1772
|
-
if utils.match_response(http_res, "404", "application/json"):
|
|
1773
|
-
response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
|
|
1774
|
-
raise errors.NotFound(data=response_data)
|
|
1775
|
-
if utils.match_response(http_res, "409", "application/json"):
|
|
1776
|
-
response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
|
|
1777
|
-
raise errors.Conflict(data=response_data)
|
|
1778
|
-
if utils.match_response(http_res, "410", "application/json"):
|
|
1779
|
-
response_data = utils.unmarshal_json(
|
|
1780
|
-
http_res.text, errors.InviteExpiredData
|
|
1781
|
-
)
|
|
1782
|
-
raise errors.InviteExpired(data=response_data)
|
|
1783
|
-
if utils.match_response(http_res, "422", "application/json"):
|
|
1784
|
-
response_data = utils.unmarshal_json(
|
|
1785
|
-
http_res.text, errors.UnprocessableEntityData
|
|
1786
|
-
)
|
|
1787
|
-
raise errors.UnprocessableEntity(data=response_data)
|
|
1788
|
-
if utils.match_response(http_res, "429", "application/json"):
|
|
1789
|
-
response_data = utils.unmarshal_json(
|
|
1790
|
-
http_res.text, errors.RateLimitExceededData
|
|
1791
|
-
)
|
|
1792
|
-
raise errors.RateLimitExceeded(data=response_data)
|
|
1793
|
-
if utils.match_response(http_res, "500", "application/json"):
|
|
1794
|
-
response_data = utils.unmarshal_json(
|
|
1795
|
-
http_res.text, errors.InternalServerErrorData
|
|
1796
|
-
)
|
|
1797
|
-
raise errors.InternalServerError(data=response_data)
|
|
1798
|
-
if utils.match_response(http_res, "4XX", "*"):
|
|
1799
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1800
|
-
raise errors.SDKError(
|
|
1801
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1802
|
-
)
|
|
1803
|
-
if utils.match_response(http_res, "5XX", "*"):
|
|
1804
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1805
|
-
raise errors.SDKError(
|
|
1806
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1807
|
-
)
|
|
1808
|
-
|
|
1809
|
-
content_type = http_res.headers.get("Content-Type")
|
|
1810
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1811
|
-
raise errors.SDKError(
|
|
1812
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1813
|
-
http_res.status_code,
|
|
1814
|
-
http_res_text,
|
|
1815
|
-
http_res,
|
|
1816
|
-
)
|
dub/sdk.py
CHANGED
|
@@ -7,40 +7,60 @@ from .utils.logger import Logger, get_default_logger
|
|
|
7
7
|
from .utils.retries import RetryConfig
|
|
8
8
|
from dub import utils
|
|
9
9
|
from dub._hooks import SDKHooks
|
|
10
|
-
from dub.analytics import Analytics
|
|
11
|
-
from dub.customers import Customers
|
|
12
|
-
from dub.domains import Domains
|
|
13
|
-
from dub.embed_tokens import EmbedTokens
|
|
14
|
-
from dub.events import Events
|
|
15
|
-
from dub.folders import Folders
|
|
16
|
-
from dub.links import Links
|
|
17
10
|
from dub.models import components
|
|
18
|
-
from dub.partners import Partners
|
|
19
|
-
from dub.qr_codes import QRCodes
|
|
20
|
-
from dub.tags import Tags
|
|
21
|
-
from dub.track import Track
|
|
22
11
|
from dub.types import OptionalNullable, UNSET
|
|
23
|
-
from dub.workspaces import Workspaces
|
|
24
12
|
import httpx
|
|
25
|
-
|
|
13
|
+
import importlib
|
|
14
|
+
from typing import Any, Callable, Dict, Optional, TYPE_CHECKING, Union, cast
|
|
26
15
|
import weakref
|
|
27
16
|
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from dub.analytics import Analytics
|
|
19
|
+
from dub.commissions import Commissions
|
|
20
|
+
from dub.customers import Customers
|
|
21
|
+
from dub.domains import Domains
|
|
22
|
+
from dub.embed_tokens import EmbedTokens
|
|
23
|
+
from dub.events import Events
|
|
24
|
+
from dub.folders import Folders
|
|
25
|
+
from dub.links import Links
|
|
26
|
+
from dub.partners import Partners
|
|
27
|
+
from dub.qr_codes import QRCodes
|
|
28
|
+
from dub.tags import Tags
|
|
29
|
+
from dub.track import Track
|
|
30
|
+
from dub.workspaces import Workspaces
|
|
31
|
+
|
|
28
32
|
|
|
29
33
|
class Dub(BaseSDK):
|
|
30
34
|
r"""Dub API: Dub is link management infrastructure for companies to create marketing campaigns, link sharing features, and referral programs."""
|
|
31
35
|
|
|
32
|
-
links: Links
|
|
33
|
-
analytics: Analytics
|
|
34
|
-
events: Events
|
|
35
|
-
tags: Tags
|
|
36
|
-
folders: Folders
|
|
37
|
-
domains: Domains
|
|
38
|
-
track: Track
|
|
39
|
-
customers: Customers
|
|
40
|
-
partners: Partners
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
links: "Links"
|
|
37
|
+
analytics: "Analytics"
|
|
38
|
+
events: "Events"
|
|
39
|
+
tags: "Tags"
|
|
40
|
+
folders: "Folders"
|
|
41
|
+
domains: "Domains"
|
|
42
|
+
track: "Track"
|
|
43
|
+
customers: "Customers"
|
|
44
|
+
partners: "Partners"
|
|
45
|
+
commissions: "Commissions"
|
|
46
|
+
workspaces: "Workspaces"
|
|
47
|
+
embed_tokens: "EmbedTokens"
|
|
48
|
+
qr_codes: "QRCodes"
|
|
49
|
+
_sub_sdk_map = {
|
|
50
|
+
"links": ("dub.links", "Links"),
|
|
51
|
+
"analytics": ("dub.analytics", "Analytics"),
|
|
52
|
+
"events": ("dub.events", "Events"),
|
|
53
|
+
"tags": ("dub.tags", "Tags"),
|
|
54
|
+
"folders": ("dub.folders", "Folders"),
|
|
55
|
+
"domains": ("dub.domains", "Domains"),
|
|
56
|
+
"track": ("dub.track", "Track"),
|
|
57
|
+
"customers": ("dub.customers", "Customers"),
|
|
58
|
+
"partners": ("dub.partners", "Partners"),
|
|
59
|
+
"commissions": ("dub.commissions", "Commissions"),
|
|
60
|
+
"workspaces": ("dub.workspaces", "Workspaces"),
|
|
61
|
+
"embed_tokens": ("dub.embed_tokens", "EmbedTokens"),
|
|
62
|
+
"qr_codes": ("dub.qr_codes", "QRCodes"),
|
|
63
|
+
}
|
|
44
64
|
|
|
45
65
|
def __init__(
|
|
46
66
|
self,
|
|
@@ -135,21 +155,32 @@ class Dub(BaseSDK):
|
|
|
135
155
|
self.sdk_configuration.async_client_supplied,
|
|
136
156
|
)
|
|
137
157
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
158
|
+
def __getattr__(self, name: str):
|
|
159
|
+
if name in self._sub_sdk_map:
|
|
160
|
+
module_path, class_name = self._sub_sdk_map[name]
|
|
161
|
+
try:
|
|
162
|
+
module = importlib.import_module(module_path)
|
|
163
|
+
klass = getattr(module, class_name)
|
|
164
|
+
instance = klass(self.sdk_configuration)
|
|
165
|
+
setattr(self, name, instance)
|
|
166
|
+
return instance
|
|
167
|
+
except ImportError as e:
|
|
168
|
+
raise AttributeError(
|
|
169
|
+
f"Failed to import module {module_path} for attribute {name}: {e}"
|
|
170
|
+
) from e
|
|
171
|
+
except AttributeError as e:
|
|
172
|
+
raise AttributeError(
|
|
173
|
+
f"Failed to find class {class_name} in module {module_path} for attribute {name}: {e}"
|
|
174
|
+
) from e
|
|
175
|
+
|
|
176
|
+
raise AttributeError(
|
|
177
|
+
f"'{type(self).__name__}' object has no attribute '{name}'"
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
def __dir__(self):
|
|
181
|
+
default_attrs = list(super().__dir__())
|
|
182
|
+
lazy_attrs = list(self._sub_sdk_map.keys())
|
|
183
|
+
return sorted(list(set(default_attrs + lazy_attrs)))
|
|
153
184
|
|
|
154
185
|
def __enter__(self):
|
|
155
186
|
return self
|
dub/utils/__init__.py
CHANGED
|
@@ -1,51 +1,55 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from .
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
from .
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from .annotations import get_discriminator
|
|
8
|
+
from .datetimes import parse_datetime
|
|
9
|
+
from .enums import OpenEnumMeta
|
|
10
|
+
from .headers import get_headers, get_response_headers
|
|
11
|
+
from .metadata import (
|
|
12
|
+
FieldMetadata,
|
|
13
|
+
find_metadata,
|
|
14
|
+
FormMetadata,
|
|
15
|
+
HeaderMetadata,
|
|
16
|
+
MultipartFormMetadata,
|
|
17
|
+
PathParamMetadata,
|
|
18
|
+
QueryParamMetadata,
|
|
19
|
+
RequestMetadata,
|
|
20
|
+
SecurityMetadata,
|
|
21
|
+
)
|
|
22
|
+
from .queryparams import get_query_params
|
|
23
|
+
from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
|
|
24
|
+
from .requestbodies import serialize_request_body, SerializedRequestBody
|
|
25
|
+
from .security import get_security
|
|
26
|
+
from .serializers import (
|
|
27
|
+
get_pydantic_model,
|
|
28
|
+
marshal_json,
|
|
29
|
+
unmarshal,
|
|
30
|
+
unmarshal_json,
|
|
31
|
+
serialize_decimal,
|
|
32
|
+
serialize_float,
|
|
33
|
+
serialize_int,
|
|
34
|
+
stream_to_text,
|
|
35
|
+
stream_to_text_async,
|
|
36
|
+
stream_to_bytes,
|
|
37
|
+
stream_to_bytes_async,
|
|
38
|
+
validate_const,
|
|
39
|
+
validate_decimal,
|
|
40
|
+
validate_float,
|
|
41
|
+
validate_int,
|
|
42
|
+
validate_open_enum,
|
|
43
|
+
)
|
|
44
|
+
from .url import generate_url, template_url, remove_suffix
|
|
45
|
+
from .values import (
|
|
46
|
+
get_global_from_env,
|
|
47
|
+
match_content_type,
|
|
48
|
+
match_status_codes,
|
|
49
|
+
match_response,
|
|
50
|
+
cast_partial,
|
|
51
|
+
)
|
|
52
|
+
from .logger import Logger, get_body_content, get_default_logger
|
|
49
53
|
|
|
50
54
|
__all__ = [
|
|
51
55
|
"BackoffStrategy",
|
|
@@ -56,6 +60,7 @@ __all__ = [
|
|
|
56
60
|
"get_body_content",
|
|
57
61
|
"get_default_logger",
|
|
58
62
|
"get_discriminator",
|
|
63
|
+
"parse_datetime",
|
|
59
64
|
"get_global_from_env",
|
|
60
65
|
"get_headers",
|
|
61
66
|
"get_pydantic_model",
|
|
@@ -98,3 +103,82 @@ __all__ = [
|
|
|
98
103
|
"validate_open_enum",
|
|
99
104
|
"cast_partial",
|
|
100
105
|
]
|
|
106
|
+
|
|
107
|
+
_dynamic_imports: dict[str, str] = {
|
|
108
|
+
"BackoffStrategy": ".retries",
|
|
109
|
+
"FieldMetadata": ".metadata",
|
|
110
|
+
"find_metadata": ".metadata",
|
|
111
|
+
"FormMetadata": ".metadata",
|
|
112
|
+
"generate_url": ".url",
|
|
113
|
+
"get_body_content": ".logger",
|
|
114
|
+
"get_default_logger": ".logger",
|
|
115
|
+
"get_discriminator": ".annotations",
|
|
116
|
+
"parse_datetime": ".datetimes",
|
|
117
|
+
"get_global_from_env": ".values",
|
|
118
|
+
"get_headers": ".headers",
|
|
119
|
+
"get_pydantic_model": ".serializers",
|
|
120
|
+
"get_query_params": ".queryparams",
|
|
121
|
+
"get_response_headers": ".headers",
|
|
122
|
+
"get_security": ".security",
|
|
123
|
+
"HeaderMetadata": ".metadata",
|
|
124
|
+
"Logger": ".logger",
|
|
125
|
+
"marshal_json": ".serializers",
|
|
126
|
+
"match_content_type": ".values",
|
|
127
|
+
"match_status_codes": ".values",
|
|
128
|
+
"match_response": ".values",
|
|
129
|
+
"MultipartFormMetadata": ".metadata",
|
|
130
|
+
"OpenEnumMeta": ".enums",
|
|
131
|
+
"PathParamMetadata": ".metadata",
|
|
132
|
+
"QueryParamMetadata": ".metadata",
|
|
133
|
+
"remove_suffix": ".url",
|
|
134
|
+
"Retries": ".retries",
|
|
135
|
+
"retry": ".retries",
|
|
136
|
+
"retry_async": ".retries",
|
|
137
|
+
"RetryConfig": ".retries",
|
|
138
|
+
"RequestMetadata": ".metadata",
|
|
139
|
+
"SecurityMetadata": ".metadata",
|
|
140
|
+
"serialize_decimal": ".serializers",
|
|
141
|
+
"serialize_float": ".serializers",
|
|
142
|
+
"serialize_int": ".serializers",
|
|
143
|
+
"serialize_request_body": ".requestbodies",
|
|
144
|
+
"SerializedRequestBody": ".requestbodies",
|
|
145
|
+
"stream_to_text": ".serializers",
|
|
146
|
+
"stream_to_text_async": ".serializers",
|
|
147
|
+
"stream_to_bytes": ".serializers",
|
|
148
|
+
"stream_to_bytes_async": ".serializers",
|
|
149
|
+
"template_url": ".url",
|
|
150
|
+
"unmarshal": ".serializers",
|
|
151
|
+
"unmarshal_json": ".serializers",
|
|
152
|
+
"validate_decimal": ".serializers",
|
|
153
|
+
"validate_const": ".serializers",
|
|
154
|
+
"validate_float": ".serializers",
|
|
155
|
+
"validate_int": ".serializers",
|
|
156
|
+
"validate_open_enum": ".serializers",
|
|
157
|
+
"cast_partial": ".values",
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def __getattr__(attr_name: str) -> object:
|
|
162
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
163
|
+
if module_name is None:
|
|
164
|
+
raise AttributeError(
|
|
165
|
+
f"no {attr_name} found in _dynamic_imports, module name -> {__name__} "
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
module = import_module(module_name, __package__)
|
|
170
|
+
result = getattr(module, attr_name)
|
|
171
|
+
return result
|
|
172
|
+
except ImportError as e:
|
|
173
|
+
raise ImportError(
|
|
174
|
+
f"Failed to import {attr_name} from {module_name}: {e}"
|
|
175
|
+
) from e
|
|
176
|
+
except AttributeError as e:
|
|
177
|
+
raise AttributeError(
|
|
178
|
+
f"Failed to get {attr_name} from {module_name}: {e}"
|
|
179
|
+
) from e
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def __dir__():
|
|
183
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
184
|
+
return sorted(lazy_attrs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dub
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.25.0
|
|
4
4
|
Summary: Python Client SDK Generated by Speakeasy
|
|
5
5
|
Author: Speakeasy
|
|
6
6
|
Requires-Python: >=3.9.2
|
|
@@ -276,6 +276,11 @@ asyncio.run(main())
|
|
|
276
276
|
|
|
277
277
|
* [retrieve](https://github.com/dubinc/dub-python/blob/master/docs/sdks/analytics/README.md#retrieve) - Retrieve analytics for a link, a domain, or the authenticated workspace.
|
|
278
278
|
|
|
279
|
+
### [commissions](https://github.com/dubinc/dub-python/blob/master/docs/sdks/commissions/README.md)
|
|
280
|
+
|
|
281
|
+
* [list](https://github.com/dubinc/dub-python/blob/master/docs/sdks/commissions/README.md#list) - Get commissions for a program.
|
|
282
|
+
* [update](https://github.com/dubinc/dub-python/blob/master/docs/sdks/commissions/README.md#update) - Update a commission.
|
|
283
|
+
|
|
279
284
|
### [customers](https://github.com/dubinc/dub-python/blob/master/docs/sdks/customers/README.md)
|
|
280
285
|
|
|
281
286
|
* [list](https://github.com/dubinc/dub-python/blob/master/docs/sdks/customers/README.md#list) - Retrieve a list of customers
|
|
@@ -327,7 +332,6 @@ asyncio.run(main())
|
|
|
327
332
|
* [retrieve_links](https://github.com/dubinc/dub-python/blob/master/docs/sdks/partners/README.md#retrieve_links) - Retrieve a partner's links.
|
|
328
333
|
* [upsert_link](https://github.com/dubinc/dub-python/blob/master/docs/sdks/partners/README.md#upsert_link) - Upsert a link for a partner
|
|
329
334
|
* [analytics](https://github.com/dubinc/dub-python/blob/master/docs/sdks/partners/README.md#analytics) - Retrieve analytics for a partner
|
|
330
|
-
* [update_sale](https://github.com/dubinc/dub-python/blob/master/docs/sdks/partners/README.md#update_sale) - Update a sale for a partner.
|
|
331
335
|
|
|
332
336
|
### [qr_codes](https://github.com/dubinc/dub-python/blob/master/docs/sdks/qrcodes/README.md)
|
|
333
337
|
|