intelligence-cloud 0.1.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.
- intelligence_cloud/__init__.py +62 -0
- intelligence_cloud/_base.py +75 -0
- intelligence_cloud/_generated.py +533 -0
- intelligence_cloud/_spec.py +334 -0
- intelligence_cloud/_version.py +1 -0
- intelligence_cloud/auth.py +142 -0
- intelligence_cloud/client.py +433 -0
- intelligence_cloud/data/spec.json +6391 -0
- intelligence_cloud/errors.py +179 -0
- intelligence_cloud/intelligence.py +292 -0
- intelligence_cloud/py.typed +0 -0
- intelligence_cloud/receiver.py +197 -0
- intelligence_cloud/resources.py +358 -0
- intelligence_cloud/workflows.py +791 -0
- intelligence_cloud-0.1.0.dist-info/METADATA +410 -0
- intelligence_cloud-0.1.0.dist-info/RECORD +18 -0
- intelligence_cloud-0.1.0.dist-info/WHEEL +4 -0
- intelligence_cloud-0.1.0.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Intelligence Cloud partner API client.
|
|
2
|
+
|
|
3
|
+
Customer lifecycle with admin credentials (``client.companies``, ``client.users``, ...,
|
|
4
|
+
``client.workflows``) and conversation intelligence with frontline credentials
|
|
5
|
+
(``client.intelligence``).
|
|
6
|
+
"""
|
|
7
|
+
from ._base import Page, unwrap
|
|
8
|
+
from ._version import __version__
|
|
9
|
+
from .auth import FileTokenStore, MemoryTokenStore, Tokens, TokenStore
|
|
10
|
+
from .client import DEFAULT_BASE_URL, Client
|
|
11
|
+
from .errors import (
|
|
12
|
+
ApiError,
|
|
13
|
+
AuthError,
|
|
14
|
+
ConflictError,
|
|
15
|
+
ConnectorError,
|
|
16
|
+
ConnectorTimeoutError,
|
|
17
|
+
ExtensionMappingError,
|
|
18
|
+
FrontlineRequiredError,
|
|
19
|
+
IntelligenceCloudError,
|
|
20
|
+
InvalidRequestError,
|
|
21
|
+
MfaRequiredError,
|
|
22
|
+
NotFoundError,
|
|
23
|
+
PasswordExpiredError,
|
|
24
|
+
PayloadTooLargeError,
|
|
25
|
+
RateLimitError,
|
|
26
|
+
ValidationError,
|
|
27
|
+
WebhookPayloadError,
|
|
28
|
+
)
|
|
29
|
+
from .intelligence import RecordingLink, WebhookTestResult
|
|
30
|
+
from .receiver import (
|
|
31
|
+
AfterCallCall,
|
|
32
|
+
AfterCallEvent,
|
|
33
|
+
AfterCallLocation,
|
|
34
|
+
AfterCallSummary,
|
|
35
|
+
Deduplicator,
|
|
36
|
+
DedupStore,
|
|
37
|
+
MAX_EVENT_BYTES,
|
|
38
|
+
MemoryDedupStore,
|
|
39
|
+
UnknownEvent,
|
|
40
|
+
parse_after_call_event,
|
|
41
|
+
)
|
|
42
|
+
from .workflows import (
|
|
43
|
+
ConnectorSpec,
|
|
44
|
+
LocationSpec,
|
|
45
|
+
SeatCustomer,
|
|
46
|
+
SeatCustomerSpec,
|
|
47
|
+
SeatUser,
|
|
48
|
+
UserSpec,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"Client", "DEFAULT_BASE_URL", "Page", "unwrap", "__version__",
|
|
53
|
+
"Tokens", "TokenStore", "MemoryTokenStore", "FileTokenStore",
|
|
54
|
+
"IntelligenceCloudError", "InvalidRequestError", "ApiError", "AuthError", "PasswordExpiredError",
|
|
55
|
+
"NotFoundError", "ConflictError", "ValidationError", "RateLimitError", "MfaRequiredError",
|
|
56
|
+
"FrontlineRequiredError", "ConnectorError", "ConnectorTimeoutError", "ExtensionMappingError",
|
|
57
|
+
"WebhookPayloadError", "PayloadTooLargeError", "WebhookTestResult", "RecordingLink",
|
|
58
|
+
"AfterCallEvent", "AfterCallCall", "AfterCallSummary", "AfterCallLocation", "UnknownEvent",
|
|
59
|
+
"parse_after_call_event", "MAX_EVENT_BYTES",
|
|
60
|
+
"Deduplicator", "DedupStore", "MemoryDedupStore",
|
|
61
|
+
"SeatCustomerSpec", "LocationSpec", "ConnectorSpec", "UserSpec", "SeatCustomer", "SeatUser",
|
|
62
|
+
]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
7
|
+
from .client import Client
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Namespace:
|
|
11
|
+
"""A group of operations sharing the client's session."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, client: "Client"):
|
|
14
|
+
self._c = client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def unwrap(body: Any) -> Any:
|
|
18
|
+
"""Return the record inside a response: ``data.attributes`` when present, else ``data``."""
|
|
19
|
+
if isinstance(body, dict) and "data" in body:
|
|
20
|
+
data = body["data"]
|
|
21
|
+
if isinstance(data, dict) and "attributes" in data and isinstance(data["attributes"], dict):
|
|
22
|
+
return data["attributes"]
|
|
23
|
+
return data
|
|
24
|
+
return body
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _flatten(item: Any) -> Any:
|
|
28
|
+
if isinstance(item, dict) and "attributes" in item and isinstance(item["attributes"], dict):
|
|
29
|
+
return item["attributes"]
|
|
30
|
+
return item
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class Page:
|
|
35
|
+
"""One page of a list.
|
|
36
|
+
|
|
37
|
+
``items`` are the records (resource ``attributes`` already unwrapped). ``raw`` is the whole response,
|
|
38
|
+
including summaries such as ``data.summary`` on calls and alerts.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
items: List[Any]
|
|
42
|
+
next_cursor: Optional[str]
|
|
43
|
+
has_more: bool
|
|
44
|
+
total: Optional[int] = None
|
|
45
|
+
raw: Dict[str, Any] = field(default_factory=dict, repr=False)
|
|
46
|
+
|
|
47
|
+
def __iter__(self):
|
|
48
|
+
return iter(self.items)
|
|
49
|
+
|
|
50
|
+
def __len__(self) -> int:
|
|
51
|
+
return len(self.items)
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def from_body(cls, body: Any) -> "Page":
|
|
55
|
+
body = body if isinstance(body, dict) else {}
|
|
56
|
+
data = body.get("data")
|
|
57
|
+
items: List[Any] = []
|
|
58
|
+
total = None
|
|
59
|
+
if isinstance(data, list):
|
|
60
|
+
items = [_flatten(i) for i in data]
|
|
61
|
+
elif isinstance(data, dict):
|
|
62
|
+
for key in ("calls", "alerts"):
|
|
63
|
+
if isinstance(data.get(key), list):
|
|
64
|
+
items = [_flatten(i) for i in data[key]]
|
|
65
|
+
break
|
|
66
|
+
summary = data.get("summary") or {}
|
|
67
|
+
total = summary.get("total", summary.get("total_calls"))
|
|
68
|
+
paging = body.get("pagination") or body.get("meta") or body
|
|
69
|
+
cursor = paging.get("next_cursor") if isinstance(paging, dict) else None
|
|
70
|
+
has_more = bool(paging.get("has_more")) if isinstance(paging, dict) else False
|
|
71
|
+
if isinstance(paging, dict):
|
|
72
|
+
total = paging.get("total_count", paging.get("total", total))
|
|
73
|
+
if not has_more:
|
|
74
|
+
cursor = None
|
|
75
|
+
return cls(items=items, next_cursor=cursor or None, has_more=has_more and bool(cursor), total=total, raw=body)
|