handset 0.1.1__tar.gz

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.
Files changed (135) hide show
  1. handset-0.1.1/PKG-INFO +144 -0
  2. handset-0.1.1/README.md +124 -0
  3. handset-0.1.1/handset/__init__.py +8 -0
  4. handset-0.1.1/handset/api/__init__.py +1 -0
  5. handset-0.1.1/handset/api/compliance/__init__.py +1 -0
  6. handset-0.1.1/handset/api/compliance/create_brand.py +210 -0
  7. handset-0.1.1/handset/api/compliance/create_campaign.py +214 -0
  8. handset-0.1.1/handset/api/compliance/create_e911_address.py +210 -0
  9. handset-0.1.1/handset/api/compliance/get_brand.py +174 -0
  10. handset-0.1.1/handset/api/compliance/get_campaign.py +174 -0
  11. handset-0.1.1/handset/api/compliance/list_brands.py +198 -0
  12. handset-0.1.1/handset/api/compliance/list_campaigns.py +233 -0
  13. handset-0.1.1/handset/api/compliance/list_e911_addresses.py +213 -0
  14. handset-0.1.1/handset/api/messaging/__init__.py +1 -0
  15. handset-0.1.1/handset/api/messaging/get_conversation.py +174 -0
  16. handset-0.1.1/handset/api/messaging/get_message.py +174 -0
  17. handset-0.1.1/handset/api/messaging/list_conversations.py +240 -0
  18. handset-0.1.1/handset/api/messaging/list_messages.py +248 -0
  19. handset-0.1.1/handset/api/messaging/list_opt_outs.py +225 -0
  20. handset-0.1.1/handset/api/messaging/send_message.py +210 -0
  21. handset-0.1.1/handset/api/phone_numbers/__init__.py +1 -0
  22. handset-0.1.1/handset/api/phone_numbers/get_number.py +174 -0
  23. handset-0.1.1/handset/api/phone_numbers/list_numbers.py +213 -0
  24. handset-0.1.1/handset/api/phone_numbers/purchase_number.py +198 -0
  25. handset-0.1.1/handset/api/phone_numbers/release_number.py +178 -0
  26. handset-0.1.1/handset/api/phone_numbers/search_available_numbers.py +228 -0
  27. handset-0.1.1/handset/api/phone_numbers/update_number.py +194 -0
  28. handset-0.1.1/handset/api/tenants/__init__.py +1 -0
  29. handset-0.1.1/handset/api/tenants/create_tenant.py +198 -0
  30. handset-0.1.1/handset/api/tenants/delete_tenant.py +182 -0
  31. handset-0.1.1/handset/api/tenants/get_tenant.py +174 -0
  32. handset-0.1.1/handset/api/tenants/list_tenants.py +213 -0
  33. handset-0.1.1/handset/api/tenants/update_tenant.py +194 -0
  34. handset-0.1.1/handset/api/usage/__init__.py +1 -0
  35. handset-0.1.1/handset/api/usage/get_usage.py +225 -0
  36. handset-0.1.1/handset/api/voice/__init__.py +1 -0
  37. handset-0.1.1/handset/api/voice/create_routing_config.py +198 -0
  38. handset-0.1.1/handset/api/voice/delete_routing_config.py +178 -0
  39. handset-0.1.1/handset/api/voice/get_call.py +174 -0
  40. handset-0.1.1/handset/api/voice/get_recording.py +174 -0
  41. handset-0.1.1/handset/api/voice/get_routing_config.py +174 -0
  42. handset-0.1.1/handset/api/voice/get_voicemail.py +174 -0
  43. handset-0.1.1/handset/api/voice/list_calls.py +228 -0
  44. handset-0.1.1/handset/api/voice/list_routing_configs.py +213 -0
  45. handset-0.1.1/handset/api/voice/list_voicemails.py +213 -0
  46. handset-0.1.1/handset/api/voice/update_routing_config.py +202 -0
  47. handset-0.1.1/handset/api/webhooks/__init__.py +1 -0
  48. handset-0.1.1/handset/api/webhooks/create_webhook_endpoint.py +198 -0
  49. handset-0.1.1/handset/api/webhooks/delete_webhook_endpoint.py +170 -0
  50. handset-0.1.1/handset/api/webhooks/list_webhook_endpoints.py +198 -0
  51. handset-0.1.1/handset/api/webhooks/test_webhook_endpoint.py +197 -0
  52. handset-0.1.1/handset/api/webhooks/update_webhook_endpoint.py +194 -0
  53. handset-0.1.1/handset/client.py +271 -0
  54. handset-0.1.1/handset/errors.py +14 -0
  55. handset-0.1.1/handset/models/__init__.py +159 -0
  56. handset-0.1.1/handset/models/available_number.py +156 -0
  57. handset-0.1.1/handset/models/available_number_capabilities_item.py +9 -0
  58. handset-0.1.1/handset/models/brand.py +223 -0
  59. handset-0.1.1/handset/models/brand_create.py +170 -0
  60. handset-0.1.1/handset/models/brand_create_entity_type.py +10 -0
  61. handset-0.1.1/handset/models/brand_status.py +9 -0
  62. handset-0.1.1/handset/models/call.py +294 -0
  63. handset-0.1.1/handset/models/call_direction.py +7 -0
  64. handset-0.1.1/handset/models/call_events_item.py +127 -0
  65. handset-0.1.1/handset/models/call_events_item_detail_type_0.py +65 -0
  66. handset-0.1.1/handset/models/call_status.py +12 -0
  67. handset-0.1.1/handset/models/campaign.py +202 -0
  68. handset-0.1.1/handset/models/campaign_create.py +126 -0
  69. handset-0.1.1/handset/models/campaign_create_use_case.py +11 -0
  70. handset-0.1.1/handset/models/campaign_status.py +11 -0
  71. handset-0.1.1/handset/models/campaign_throughput.py +101 -0
  72. handset-0.1.1/handset/models/conversation.py +144 -0
  73. handset-0.1.1/handset/models/e911_address.py +163 -0
  74. handset-0.1.1/handset/models/e911_address_create.py +131 -0
  75. handset-0.1.1/handset/models/e911_address_status.py +8 -0
  76. handset-0.1.1/handset/models/error_body.py +84 -0
  77. handset-0.1.1/handset/models/error_body_error.py +116 -0
  78. handset-0.1.1/handset/models/event_envelope.py +132 -0
  79. handset-0.1.1/handset/models/event_envelope_data.py +66 -0
  80. handset-0.1.1/handset/models/get_usage_response_200.py +141 -0
  81. handset-0.1.1/handset/models/get_usage_response_200_data_item.py +88 -0
  82. handset-0.1.1/handset/models/get_usage_response_200_data_item_kind.py +11 -0
  83. handset-0.1.1/handset/models/get_usage_response_200_mode.py +8 -0
  84. handset-0.1.1/handset/models/get_usage_response_200_object.py +7 -0
  85. handset-0.1.1/handset/models/list_brands_response_200.py +124 -0
  86. handset-0.1.1/handset/models/list_calls_response_200.py +124 -0
  87. handset-0.1.1/handset/models/list_campaigns_response_200.py +124 -0
  88. handset-0.1.1/handset/models/list_conversations_response_200.py +124 -0
  89. handset-0.1.1/handset/models/list_e911_addresses_response_200.py +124 -0
  90. handset-0.1.1/handset/models/list_messages_direction.py +8 -0
  91. handset-0.1.1/handset/models/list_messages_response_200.py +124 -0
  92. handset-0.1.1/handset/models/list_numbers_response_200.py +124 -0
  93. handset-0.1.1/handset/models/list_opt_outs_response_200.py +124 -0
  94. handset-0.1.1/handset/models/list_routing_configs_response_200.py +124 -0
  95. handset-0.1.1/handset/models/list_tenants_response_200.py +124 -0
  96. handset-0.1.1/handset/models/list_voicemails_response_200.py +124 -0
  97. handset-0.1.1/handset/models/list_webhook_endpoints_response_200.py +124 -0
  98. handset-0.1.1/handset/models/message.py +263 -0
  99. handset-0.1.1/handset/models/message_direction.py +8 -0
  100. handset-0.1.1/handset/models/message_status.py +12 -0
  101. handset-0.1.1/handset/models/message_status_history_item.py +93 -0
  102. handset-0.1.1/handset/models/metadata.py +66 -0
  103. handset-0.1.1/handset/models/opt_out.py +119 -0
  104. handset-0.1.1/handset/models/opt_out_source.py +9 -0
  105. handset-0.1.1/handset/models/page.py +120 -0
  106. handset-0.1.1/handset/models/phone_number.py +217 -0
  107. handset-0.1.1/handset/models/phone_number_capabilities_item.py +9 -0
  108. handset-0.1.1/handset/models/phone_number_status.py +10 -0
  109. handset-0.1.1/handset/models/purchase_number_body.py +129 -0
  110. handset-0.1.1/handset/models/recording.py +132 -0
  111. handset-0.1.1/handset/models/ring_behavior.py +145 -0
  112. handset-0.1.1/handset/models/ring_behavior_strategy.py +8 -0
  113. handset-0.1.1/handset/models/routing_config.py +222 -0
  114. handset-0.1.1/handset/models/routing_config_create.py +202 -0
  115. handset-0.1.1/handset/models/routing_config_create_business_hours_type_0.py +101 -0
  116. handset-0.1.1/handset/models/routing_config_create_business_hours_type_0_schedule_item.py +107 -0
  117. handset-0.1.1/handset/models/routing_config_create_business_hours_type_0_schedule_item_days_item.py +13 -0
  118. handset-0.1.1/handset/models/routing_config_create_recording.py +89 -0
  119. handset-0.1.1/handset/models/search_available_numbers_response_200.py +94 -0
  120. handset-0.1.1/handset/models/send_message_body.py +132 -0
  121. handset-0.1.1/handset/models/tenant.py +151 -0
  122. handset-0.1.1/handset/models/tenant_create.py +131 -0
  123. handset-0.1.1/handset/models/tenant_update.py +132 -0
  124. handset-0.1.1/handset/models/test_webhook_endpoint_body.py +78 -0
  125. handset-0.1.1/handset/models/test_webhook_endpoint_response_200.py +121 -0
  126. handset-0.1.1/handset/models/update_number_body.py +133 -0
  127. handset-0.1.1/handset/models/voicemail.py +153 -0
  128. handset-0.1.1/handset/models/voicemail_behavior.py +132 -0
  129. handset-0.1.1/handset/models/webhook_endpoint.py +145 -0
  130. handset-0.1.1/handset/models/webhook_endpoint_create.py +113 -0
  131. handset-0.1.1/handset/models/webhook_endpoint_status.py +8 -0
  132. handset-0.1.1/handset/models/webhook_endpoint_with_secret.py +154 -0
  133. handset-0.1.1/handset/py.typed +1 -0
  134. handset-0.1.1/handset/types.py +53 -0
  135. handset-0.1.1/pyproject.toml +29 -0
handset-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: handset
3
+ Version: 0.1.1
4
+ Summary: A client library for accessing Handset API
5
+ License: MIT
6
+ Keywords: sms,voice,telephony,10dlc,phone-numbers,voicemail
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: attrs (>=22.2.0)
15
+ Requires-Dist: httpx (>=0.23.1,<0.29.0)
16
+ Project-URL: Documentation, https://docs.handset.dev
17
+ Project-URL: Homepage, https://handset.dev
18
+ Description-Content-Type: text/markdown
19
+
20
+ # handset
21
+ A client library for accessing Handset API
22
+
23
+ ## Usage
24
+ First, create a client:
25
+
26
+ ```python
27
+ from handset import Client
28
+
29
+ client = Client(base_url="https://api.example.com")
30
+ ```
31
+
32
+ If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
33
+
34
+ ```python
35
+ from handset import AuthenticatedClient
36
+
37
+ client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
38
+ ```
39
+
40
+ Now call your endpoint and use your models:
41
+
42
+ ```python
43
+ from handset.models import MyDataModel
44
+ from handset.api.my_tag import get_my_data_model
45
+ from handset.types import Response
46
+
47
+ with client as client:
48
+ my_data: MyDataModel = get_my_data_model.sync(client=client)
49
+ # or if you need more info (e.g. status_code)
50
+ response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
51
+ ```
52
+
53
+ Or do the same thing with an async version:
54
+
55
+ ```python
56
+ from handset.models import MyDataModel
57
+ from handset.api.my_tag import get_my_data_model
58
+ from handset.types import Response
59
+
60
+ async with client as client:
61
+ my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
62
+ response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
63
+ ```
64
+
65
+ By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
66
+
67
+ ```python
68
+ client = AuthenticatedClient(
69
+ base_url="https://internal_api.example.com",
70
+ token="SuperSecretToken",
71
+ verify_ssl="/path/to/certificate_bundle.pem",
72
+ )
73
+ ```
74
+
75
+ You can also disable certificate validation altogether, but beware that **this is a security risk**.
76
+
77
+ ```python
78
+ client = AuthenticatedClient(
79
+ base_url="https://internal_api.example.com",
80
+ token="SuperSecretToken",
81
+ verify_ssl=False
82
+ )
83
+ ```
84
+
85
+ Things to know:
86
+ 1. Every path/method combo becomes a Python module with four functions:
87
+ 1. `sync`: Blocking request that returns parsed data (if successful) or `None`
88
+ 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
89
+ 1. `asyncio`: Like `sync` but async instead of blocking
90
+ 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
91
+
92
+ 1. All path/query params, and bodies become method arguments.
93
+ 1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
94
+ 1. Any endpoint which did not have a tag will be in `handset.api.default`
95
+
96
+ ## Advanced customizations
97
+
98
+ There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
99
+
100
+ ```python
101
+ from handset import Client
102
+
103
+ def log_request(request):
104
+ print(f"Request event hook: {request.method} {request.url} - Waiting for response")
105
+
106
+ def log_response(response):
107
+ request = response.request
108
+ print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
109
+
110
+ client = Client(
111
+ base_url="https://api.example.com",
112
+ httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
113
+ )
114
+
115
+ # Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
116
+ ```
117
+
118
+ You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
119
+
120
+ ```python
121
+ import httpx
122
+ from handset import Client
123
+
124
+ client = Client(
125
+ base_url="https://api.example.com",
126
+ )
127
+ # Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
128
+ client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
129
+ ```
130
+
131
+ ## Building / publishing this package
132
+ This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
133
+ 1. Update the metadata in pyproject.toml (e.g. authors, version)
134
+ 1. If you're using a private repository, configure it with Poetry
135
+ 1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
136
+ 1. `poetry config http-basic.<your-repository-name> <username> <password>`
137
+ 1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
138
+
139
+ If you want to install this client into another project without publishing it (e.g. for development) then:
140
+ 1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
141
+ 1. If that project is not using Poetry:
142
+ 1. Build a wheel with `poetry build -f wheel`
143
+ 1. Install that wheel from the other project `pip install <path-to-wheel>`
144
+
@@ -0,0 +1,124 @@
1
+ # handset
2
+ A client library for accessing Handset API
3
+
4
+ ## Usage
5
+ First, create a client:
6
+
7
+ ```python
8
+ from handset import Client
9
+
10
+ client = Client(base_url="https://api.example.com")
11
+ ```
12
+
13
+ If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
14
+
15
+ ```python
16
+ from handset import AuthenticatedClient
17
+
18
+ client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
19
+ ```
20
+
21
+ Now call your endpoint and use your models:
22
+
23
+ ```python
24
+ from handset.models import MyDataModel
25
+ from handset.api.my_tag import get_my_data_model
26
+ from handset.types import Response
27
+
28
+ with client as client:
29
+ my_data: MyDataModel = get_my_data_model.sync(client=client)
30
+ # or if you need more info (e.g. status_code)
31
+ response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
32
+ ```
33
+
34
+ Or do the same thing with an async version:
35
+
36
+ ```python
37
+ from handset.models import MyDataModel
38
+ from handset.api.my_tag import get_my_data_model
39
+ from handset.types import Response
40
+
41
+ async with client as client:
42
+ my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
43
+ response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
44
+ ```
45
+
46
+ By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
47
+
48
+ ```python
49
+ client = AuthenticatedClient(
50
+ base_url="https://internal_api.example.com",
51
+ token="SuperSecretToken",
52
+ verify_ssl="/path/to/certificate_bundle.pem",
53
+ )
54
+ ```
55
+
56
+ You can also disable certificate validation altogether, but beware that **this is a security risk**.
57
+
58
+ ```python
59
+ client = AuthenticatedClient(
60
+ base_url="https://internal_api.example.com",
61
+ token="SuperSecretToken",
62
+ verify_ssl=False
63
+ )
64
+ ```
65
+
66
+ Things to know:
67
+ 1. Every path/method combo becomes a Python module with four functions:
68
+ 1. `sync`: Blocking request that returns parsed data (if successful) or `None`
69
+ 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
70
+ 1. `asyncio`: Like `sync` but async instead of blocking
71
+ 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
72
+
73
+ 1. All path/query params, and bodies become method arguments.
74
+ 1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
75
+ 1. Any endpoint which did not have a tag will be in `handset.api.default`
76
+
77
+ ## Advanced customizations
78
+
79
+ There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
80
+
81
+ ```python
82
+ from handset import Client
83
+
84
+ def log_request(request):
85
+ print(f"Request event hook: {request.method} {request.url} - Waiting for response")
86
+
87
+ def log_response(response):
88
+ request = response.request
89
+ print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
90
+
91
+ client = Client(
92
+ base_url="https://api.example.com",
93
+ httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
94
+ )
95
+
96
+ # Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
97
+ ```
98
+
99
+ You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
100
+
101
+ ```python
102
+ import httpx
103
+ from handset import Client
104
+
105
+ client = Client(
106
+ base_url="https://api.example.com",
107
+ )
108
+ # Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
109
+ client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
110
+ ```
111
+
112
+ ## Building / publishing this package
113
+ This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
114
+ 1. Update the metadata in pyproject.toml (e.g. authors, version)
115
+ 1. If you're using a private repository, configure it with Poetry
116
+ 1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
117
+ 1. `poetry config http-basic.<your-repository-name> <username> <password>`
118
+ 1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
119
+
120
+ If you want to install this client into another project without publishing it (e.g. for development) then:
121
+ 1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
122
+ 1. If that project is not using Poetry:
123
+ 1. Build a wheel with `poetry build -f wheel`
124
+ 1. Install that wheel from the other project `pip install <path-to-wheel>`
@@ -0,0 +1,8 @@
1
+
2
+ """ A client library for accessing Handset API """
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """ Contains methods for accessing the API """
@@ -0,0 +1 @@
1
+ """ Contains endpoint functions for accessing the API """
@@ -0,0 +1,210 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.brand import Brand
12
+ from ...models.brand_create import BrandCreate
13
+ from ...models.error_body import ErrorBody
14
+ from ...types import UNSET, Unset
15
+ from typing import cast
16
+
17
+
18
+
19
+ def _get_kwargs(
20
+ *,
21
+ body: BrandCreate,
22
+ idempotency_key: str | Unset = UNSET,
23
+
24
+ ) -> dict[str, Any]:
25
+ headers: dict[str, Any] = {}
26
+ if not isinstance(idempotency_key, Unset):
27
+ headers["Idempotency-Key"] = idempotency_key
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ _kwargs: dict[str, Any] = {
36
+ "method": "post",
37
+ "url": "/brands",
38
+ }
39
+
40
+ _kwargs["json"] = body.to_dict()
41
+
42
+ headers["Content-Type"] = "application/json"
43
+
44
+ _kwargs["headers"] = headers
45
+ return _kwargs
46
+
47
+
48
+
49
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Brand | ErrorBody:
50
+ if response.status_code == 201:
51
+ response_201 = Brand.from_dict(response.json())
52
+
53
+
54
+
55
+ return response_201
56
+
57
+ response_default = ErrorBody.from_dict(response.json())
58
+
59
+
60
+
61
+ return response_default
62
+
63
+
64
+
65
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Brand | ErrorBody]:
66
+ return Response(
67
+ status_code=HTTPStatus(response.status_code),
68
+ content=response.content,
69
+ headers=response.headers,
70
+ parsed=_parse_response(client=client, response=response),
71
+ )
72
+
73
+
74
+ def sync_detailed(
75
+ *,
76
+ client: AuthenticatedClient | Client,
77
+ body: BrandCreate,
78
+ idempotency_key: str | Unset = UNSET,
79
+
80
+ ) -> Response[Brand | ErrorBody]:
81
+ """ Register a 10DLC brand
82
+
83
+ Registers your platform (or a tenant, for tenants with their own EIN) with The Campaign Registry.
84
+ Vetting typically takes minutes to days; track via `brand.status_changed`.
85
+
86
+ Args:
87
+ idempotency_key (str | Unset):
88
+ body (BrandCreate):
89
+
90
+ Raises:
91
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
92
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
93
+
94
+ Returns:
95
+ Response[Brand | ErrorBody]
96
+ """
97
+
98
+
99
+ kwargs = _get_kwargs(
100
+ body=body,
101
+ idempotency_key=idempotency_key,
102
+
103
+ )
104
+
105
+ response = client.get_httpx_client().request(
106
+ **kwargs,
107
+ )
108
+
109
+ return _build_response(client=client, response=response)
110
+
111
+ def sync(
112
+ *,
113
+ client: AuthenticatedClient | Client,
114
+ body: BrandCreate,
115
+ idempotency_key: str | Unset = UNSET,
116
+
117
+ ) -> Brand | ErrorBody | None:
118
+ """ Register a 10DLC brand
119
+
120
+ Registers your platform (or a tenant, for tenants with their own EIN) with The Campaign Registry.
121
+ Vetting typically takes minutes to days; track via `brand.status_changed`.
122
+
123
+ Args:
124
+ idempotency_key (str | Unset):
125
+ body (BrandCreate):
126
+
127
+ Raises:
128
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
129
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
130
+
131
+ Returns:
132
+ Brand | ErrorBody
133
+ """
134
+
135
+
136
+ return sync_detailed(
137
+ client=client,
138
+ body=body,
139
+ idempotency_key=idempotency_key,
140
+
141
+ ).parsed
142
+
143
+ async def asyncio_detailed(
144
+ *,
145
+ client: AuthenticatedClient | Client,
146
+ body: BrandCreate,
147
+ idempotency_key: str | Unset = UNSET,
148
+
149
+ ) -> Response[Brand | ErrorBody]:
150
+ """ Register a 10DLC brand
151
+
152
+ Registers your platform (or a tenant, for tenants with their own EIN) with The Campaign Registry.
153
+ Vetting typically takes minutes to days; track via `brand.status_changed`.
154
+
155
+ Args:
156
+ idempotency_key (str | Unset):
157
+ body (BrandCreate):
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Response[Brand | ErrorBody]
165
+ """
166
+
167
+
168
+ kwargs = _get_kwargs(
169
+ body=body,
170
+ idempotency_key=idempotency_key,
171
+
172
+ )
173
+
174
+ response = await client.get_async_httpx_client().request(
175
+ **kwargs
176
+ )
177
+
178
+ return _build_response(client=client, response=response)
179
+
180
+ async def asyncio(
181
+ *,
182
+ client: AuthenticatedClient | Client,
183
+ body: BrandCreate,
184
+ idempotency_key: str | Unset = UNSET,
185
+
186
+ ) -> Brand | ErrorBody | None:
187
+ """ Register a 10DLC brand
188
+
189
+ Registers your platform (or a tenant, for tenants with their own EIN) with The Campaign Registry.
190
+ Vetting typically takes minutes to days; track via `brand.status_changed`.
191
+
192
+ Args:
193
+ idempotency_key (str | Unset):
194
+ body (BrandCreate):
195
+
196
+ Raises:
197
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
198
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
199
+
200
+ Returns:
201
+ Brand | ErrorBody
202
+ """
203
+
204
+
205
+ return (await asyncio_detailed(
206
+ client=client,
207
+ body=body,
208
+ idempotency_key=idempotency_key,
209
+
210
+ )).parsed
@@ -0,0 +1,214 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.campaign import Campaign
12
+ from ...models.campaign_create import CampaignCreate
13
+ from ...models.error_body import ErrorBody
14
+ from ...types import UNSET, Unset
15
+ from typing import cast
16
+
17
+
18
+
19
+ def _get_kwargs(
20
+ *,
21
+ body: CampaignCreate,
22
+ idempotency_key: str | Unset = UNSET,
23
+
24
+ ) -> dict[str, Any]:
25
+ headers: dict[str, Any] = {}
26
+ if not isinstance(idempotency_key, Unset):
27
+ headers["Idempotency-Key"] = idempotency_key
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ _kwargs: dict[str, Any] = {
36
+ "method": "post",
37
+ "url": "/campaigns",
38
+ }
39
+
40
+ _kwargs["json"] = body.to_dict()
41
+
42
+ headers["Content-Type"] = "application/json"
43
+
44
+ _kwargs["headers"] = headers
45
+ return _kwargs
46
+
47
+
48
+
49
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Campaign | ErrorBody:
50
+ if response.status_code == 201:
51
+ response_201 = Campaign.from_dict(response.json())
52
+
53
+
54
+
55
+ return response_201
56
+
57
+ response_default = ErrorBody.from_dict(response.json())
58
+
59
+
60
+
61
+ return response_default
62
+
63
+
64
+
65
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Campaign | ErrorBody]:
66
+ return Response(
67
+ status_code=HTTPStatus(response.status_code),
68
+ content=response.content,
69
+ headers=response.headers,
70
+ parsed=_parse_response(client=client, response=response),
71
+ )
72
+
73
+
74
+ def sync_detailed(
75
+ *,
76
+ client: AuthenticatedClient | Client,
77
+ body: CampaignCreate,
78
+ idempotency_key: str | Unset = UNSET,
79
+
80
+ ) -> Response[Campaign | ErrorBody]:
81
+ """ Register a 10DLC campaign
82
+
83
+ Registers a messaging use case under an approved brand for a tenant. Carrier review typically takes
84
+ 1–3 business days; sending is blocked until status is `approved`. Track via
85
+ `campaign.status_changed`.
86
+
87
+ Args:
88
+ idempotency_key (str | Unset):
89
+ body (CampaignCreate):
90
+
91
+ Raises:
92
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
93
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
94
+
95
+ Returns:
96
+ Response[Campaign | ErrorBody]
97
+ """
98
+
99
+
100
+ kwargs = _get_kwargs(
101
+ body=body,
102
+ idempotency_key=idempotency_key,
103
+
104
+ )
105
+
106
+ response = client.get_httpx_client().request(
107
+ **kwargs,
108
+ )
109
+
110
+ return _build_response(client=client, response=response)
111
+
112
+ def sync(
113
+ *,
114
+ client: AuthenticatedClient | Client,
115
+ body: CampaignCreate,
116
+ idempotency_key: str | Unset = UNSET,
117
+
118
+ ) -> Campaign | ErrorBody | None:
119
+ """ Register a 10DLC campaign
120
+
121
+ Registers a messaging use case under an approved brand for a tenant. Carrier review typically takes
122
+ 1–3 business days; sending is blocked until status is `approved`. Track via
123
+ `campaign.status_changed`.
124
+
125
+ Args:
126
+ idempotency_key (str | Unset):
127
+ body (CampaignCreate):
128
+
129
+ Raises:
130
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
132
+
133
+ Returns:
134
+ Campaign | ErrorBody
135
+ """
136
+
137
+
138
+ return sync_detailed(
139
+ client=client,
140
+ body=body,
141
+ idempotency_key=idempotency_key,
142
+
143
+ ).parsed
144
+
145
+ async def asyncio_detailed(
146
+ *,
147
+ client: AuthenticatedClient | Client,
148
+ body: CampaignCreate,
149
+ idempotency_key: str | Unset = UNSET,
150
+
151
+ ) -> Response[Campaign | ErrorBody]:
152
+ """ Register a 10DLC campaign
153
+
154
+ Registers a messaging use case under an approved brand for a tenant. Carrier review typically takes
155
+ 1–3 business days; sending is blocked until status is `approved`. Track via
156
+ `campaign.status_changed`.
157
+
158
+ Args:
159
+ idempotency_key (str | Unset):
160
+ body (CampaignCreate):
161
+
162
+ Raises:
163
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
164
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
165
+
166
+ Returns:
167
+ Response[Campaign | ErrorBody]
168
+ """
169
+
170
+
171
+ kwargs = _get_kwargs(
172
+ body=body,
173
+ idempotency_key=idempotency_key,
174
+
175
+ )
176
+
177
+ response = await client.get_async_httpx_client().request(
178
+ **kwargs
179
+ )
180
+
181
+ return _build_response(client=client, response=response)
182
+
183
+ async def asyncio(
184
+ *,
185
+ client: AuthenticatedClient | Client,
186
+ body: CampaignCreate,
187
+ idempotency_key: str | Unset = UNSET,
188
+
189
+ ) -> Campaign | ErrorBody | None:
190
+ """ Register a 10DLC campaign
191
+
192
+ Registers a messaging use case under an approved brand for a tenant. Carrier review typically takes
193
+ 1–3 business days; sending is blocked until status is `approved`. Track via
194
+ `campaign.status_changed`.
195
+
196
+ Args:
197
+ idempotency_key (str | Unset):
198
+ body (CampaignCreate):
199
+
200
+ Raises:
201
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
202
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
203
+
204
+ Returns:
205
+ Campaign | ErrorBody
206
+ """
207
+
208
+
209
+ return (await asyncio_detailed(
210
+ client=client,
211
+ body=body,
212
+ idempotency_key=idempotency_key,
213
+
214
+ )).parsed