superu 2025.10.6.2__py3-none-any.whl → 2025.11.7.1__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.
superu/core.py CHANGED
@@ -281,7 +281,74 @@ class ToolWrapper:
281
281
  if response.status_code != 200:
282
282
  raise Exception(f"Failed to get tool: {response.status_code}, {response.text}")
283
283
  return response.json()
284
-
284
+
285
+ class ContactWrapper:
286
+ def __init__(self, api_key):
287
+ self.api_key = api_key
288
+
289
+ def create_audience(self , audience_name: str , audience_description: str , contacts: list[dict]):
290
+ payload = {
291
+ "audience_name": audience_name,
292
+ "audience_description": audience_description,
293
+ "contacts": contacts
294
+ }
295
+
296
+ compulsory_fields = ['first_name', 'country_code', 'phone_number']
297
+
298
+ for contact in contacts:
299
+ for field in compulsory_fields:
300
+ if field not in contact:
301
+ raise ValueError(f"Missing compulsory field '{field}' in contact: {contact}")
302
+
303
+ if not isinstance(contact.get('phone_number'), str):
304
+ raise ValueError(f"'phone_number' must be a string in contact: {contact}")
305
+ phone_pattern = re.compile(r'^\d{10,15}$')
306
+ if not phone_pattern.match(contact['phone_number']):
307
+ raise ValueError(f"Invalid 'phone_number' format in contact: {contact}. It should contain only digits and be 10 to 15 digits long.")
308
+ country_code_pattern = re.compile(r'^\+\d{1,4}$')
309
+ if not country_code_pattern.match(contact['country_code']):
310
+ raise ValueError(f"Invalid 'country_code' format in contact: {contact}. It should start with '+' followed by 1 to 4 digits.")
311
+
312
+ response = requests.post(f'{server_url}/pypi_support/audience/create', json={**payload , 'api_key': self.api_key})
313
+ if response.status_code != 200:
314
+ raise Exception(f"Failed to create contact: {response.status_code}, {response.text}")
315
+ return response.json()
316
+
317
+ def create(self , contact: dict):
318
+ payload = {
319
+ **contact
320
+ }
321
+
322
+ compulsory_fields = ['first_name', 'last_name', 'email', 'country_code', 'phone_number']
323
+
324
+
325
+ for field in compulsory_fields:
326
+ if field not in contact:
327
+ raise ValueError(f"Missing compulsory field '{field}' in contact: {contact}")
328
+
329
+ if not isinstance(contact.get('phone_number'), str):
330
+ raise ValueError(f"'phone_number' must be a string in contact: {contact}")
331
+ phone_pattern = re.compile(r'^\d{10,15}$')
332
+ if not phone_pattern.match(contact['phone_number']):
333
+ raise ValueError(f"Invalid 'phone_number' format in contact: {contact}. It should contain only digits and be 10 to 15 digits long.")
334
+ country_code_pattern = re.compile(r'^\+\d{1,4}$')
335
+ if not country_code_pattern.match(contact['country_code']):
336
+ raise ValueError(f"Invalid 'country_code' format in contact: {contact}. It should start with '+' followed by 1 to 4 digits.")
337
+ email_pattern = re.compile(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$')
338
+ if not email_pattern.match(contact['email']):
339
+ raise ValueError(f"Invalid 'email' format in contact: {contact}. It should be a valid email address.")
340
+
341
+ response = requests.post(f'{server_url}/pypi_support/contact/create', json={**payload , 'api_key': self.api_key})
342
+ if response.status_code != 200 and response.status_code != 201:
343
+ raise Exception(f"Failed to create contact: {response.status_code}, {response.text}")
344
+ return response.json()
345
+
346
+ def list(self , page : int = 1 , page_size : int = 10):
347
+ response = requests.post(f'{server_url}/pypi_support/contact/list', json={'api_key': self.api_key, 'page': page, 'page_size': page_size})
348
+ if response.status_code != 200:
349
+ raise Exception(f"Failed to list contacts: {response.status_code}, {response.text}")
350
+ return response.json()
351
+
285
352
  class PlutoWrapper:
286
353
  def __init__(self, api_key , user_id , assistants):
287
354
  self.api_key = api_key
@@ -434,6 +501,7 @@ class SuperU:
434
501
  self.assistants = AssistantWrapper(self.api_key)
435
502
  self.tools = ToolWrapper(self.api_key)
436
503
  self.pluto = PlutoWrapper(self.api_key , self.user_id , assistants=self.assistants)
504
+ self.contacts = ContactWrapper(self.api_key)
437
505
 
438
506
  def validate_api_key(self, api_key):
439
507
  response = requests.post(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: superu
3
- Version: 2025.10.6.2
3
+ Version: 2025.11.7.1
4
4
  Summary: SuperU SDK to make AI calls - Create intelligent voice assistants for automated phone calls
5
5
  Author-email: Paras Chhugani <paras@superu.ai>
6
6
  Maintainer-email: Paras Chhugani <peoband@gmail.com>
@@ -0,0 +1,7 @@
1
+ superu/__init__.py,sha256=XNmATEfXs9i9gwdKZSJQ78Ro00wVQ1sfBRUzWmAwWF4,25
2
+ superu/core.py,sha256=wiEhvd_tpUhzDRMfGB2a8It4YqEfmO4dcuQa9iFMnIg,22350
3
+ superu/example.py,sha256=NtR9QKpDpROtMOntElsOev9CmaO-vyKNVARl7qVT3l4,45486
4
+ superu-2025.11.7.1.dist-info/METADATA,sha256=dt6JWFZag-IOPnsFIVN2bjVOXjnzkTkaGYR44AJtAe0,9370
5
+ superu-2025.11.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ superu-2025.11.7.1.dist-info/top_level.txt,sha256=5zVX3cRNVlQ4ErMzcEtWY9LraC6jWjmxpJJPVLIHVnA,7
7
+ superu-2025.11.7.1.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- superu/__init__.py,sha256=XNmATEfXs9i9gwdKZSJQ78Ro00wVQ1sfBRUzWmAwWF4,25
2
- superu/core.py,sha256=Ie1jGdUg_2uFhMZ1WJjUtXAN8ziHWutz6RW_VrpLPew,18661
3
- superu/example.py,sha256=NtR9QKpDpROtMOntElsOev9CmaO-vyKNVARl7qVT3l4,45486
4
- superu-2025.10.6.2.dist-info/METADATA,sha256=lQN3fzjrkHjfR6FBLEzW5R98jJ1jJOBng1bdo7DjHqQ,9370
5
- superu-2025.10.6.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- superu-2025.10.6.2.dist-info/top_level.txt,sha256=5zVX3cRNVlQ4ErMzcEtWY9LraC6jWjmxpJJPVLIHVnA,7
7
- superu-2025.10.6.2.dist-info/RECORD,,