|
| 1 | +from enum import Enum, auto |
| 2 | +from typing import Dict, Optional |
| 3 | + |
| 4 | +from aws_lambda_powertools.utilities.data_classes.common import DictWrapper |
| 5 | + |
| 6 | + |
| 7 | +class ConnectContactFlowChannel(Enum): |
| 8 | + VOICE = auto() |
| 9 | + CHAT = auto() |
| 10 | + |
| 11 | + |
| 12 | +class ConnectContactFlowEndpointType(Enum): |
| 13 | + TELEPHONE_NUMBER = auto() |
| 14 | + |
| 15 | + |
| 16 | +class ConnectContactFlowInitiationMethod(Enum): |
| 17 | + INBOUND = auto() |
| 18 | + OUTBOUND = auto() |
| 19 | + TRANSFER = auto() |
| 20 | + CALLBACK = auto() |
| 21 | + API = auto() |
| 22 | + |
| 23 | + |
| 24 | +class ConnectContactFlowEndpoint(DictWrapper): |
| 25 | + @property |
| 26 | + def address(self) -> str: |
| 27 | + """The phone number.""" |
| 28 | + return self["Address"] |
| 29 | + |
| 30 | + @property |
| 31 | + def endpoint_type(self) -> ConnectContactFlowEndpointType: |
| 32 | + """The enpoint type.""" |
| 33 | + return ConnectContactFlowEndpointType[self["Type"]] |
| 34 | + |
| 35 | + |
| 36 | +class ConnectContactFlowQueue(DictWrapper): |
| 37 | + @property |
| 38 | + def arn(self) -> str: |
| 39 | + """The unique queue ARN.""" |
| 40 | + return self["ARN"] |
| 41 | + |
| 42 | + @property |
| 43 | + def name(self) -> str: |
| 44 | + """The queue name.""" |
| 45 | + return self["Name"] |
| 46 | + |
| 47 | + |
| 48 | +class ConnectContactFlowMediaStreamAudio(DictWrapper): |
| 49 | + @property |
| 50 | + def start_fragment_number(self) -> Optional[str]: |
| 51 | + """The number that identifies the Kinesis Video Streams fragment, in the stream used for Live media streaming, |
| 52 | + in which the customer audio stream started. |
| 53 | + """ |
| 54 | + return self["StartFragmentNumber"] |
| 55 | + |
| 56 | + @property |
| 57 | + def start_timestamp(self) -> Optional[str]: |
| 58 | + """When the customer audio stream started.""" |
| 59 | + return self["StartTimestamp"] |
| 60 | + |
| 61 | + @property |
| 62 | + def stream_arn(self) -> Optional[str]: |
| 63 | + """The ARN of the Kinesis Video stream used for Live media streaming that includes the customer data to |
| 64 | + reference. |
| 65 | + """ |
| 66 | + return self["StreamARN"] |
| 67 | + |
| 68 | + |
| 69 | +class ConnectContactFlowMediaStreamCustomer(DictWrapper): |
| 70 | + @property |
| 71 | + def audio(self) -> ConnectContactFlowMediaStreamAudio: |
| 72 | + return ConnectContactFlowMediaStreamAudio(self["Audio"]) |
| 73 | + |
| 74 | + |
| 75 | +class ConnectContactFlowMediaStreams(DictWrapper): |
| 76 | + @property |
| 77 | + def customer(self) -> ConnectContactFlowMediaStreamCustomer: |
| 78 | + return ConnectContactFlowMediaStreamCustomer(self["Customer"]) |
| 79 | + |
| 80 | + |
| 81 | +class ConnectContactFlowData(DictWrapper): |
| 82 | + @property |
| 83 | + def attributes(self) -> Dict[str, str]: |
| 84 | + """These are attributes that have been previously associated with a contact, |
| 85 | + such as when using a Set contact attributes block in a contact flow. |
| 86 | + This map may be empty if there aren't any saved attributes. |
| 87 | + """ |
| 88 | + return self["Attributes"] |
| 89 | + |
| 90 | + @property |
| 91 | + def channel(self) -> ConnectContactFlowChannel: |
| 92 | + """The method used to contact your contact center.""" |
| 93 | + return ConnectContactFlowChannel[self["Channel"]] |
| 94 | + |
| 95 | + @property |
| 96 | + def contact_id(self) -> str: |
| 97 | + """The unique identifier of the contact.""" |
| 98 | + return self["ContactId"] |
| 99 | + |
| 100 | + @property |
| 101 | + def customer_endpoint(self) -> Optional[ConnectContactFlowEndpoint]: |
| 102 | + """Contains the customer’s address (number) and type of address.""" |
| 103 | + if self["CustomerEndpoint"] is not None: |
| 104 | + return ConnectContactFlowEndpoint(self["CustomerEndpoint"]) |
| 105 | + return None |
| 106 | + |
| 107 | + @property |
| 108 | + def initial_contact_id(self) -> str: |
| 109 | + """The unique identifier for the contact associated with the first interaction between the customer and your |
| 110 | + contact center. Use the initial contact ID to track contacts between contact flows. |
| 111 | + """ |
| 112 | + return self["InitialContactId"] |
| 113 | + |
| 114 | + @property |
| 115 | + def initiation_method(self) -> ConnectContactFlowInitiationMethod: |
| 116 | + """How the contact was initiated.""" |
| 117 | + return ConnectContactFlowInitiationMethod[self["InitiationMethod"]] |
| 118 | + |
| 119 | + @property |
| 120 | + def instance_arn(self) -> str: |
| 121 | + """The ARN for your Amazon Connect instance.""" |
| 122 | + return self["InstanceARN"] |
| 123 | + |
| 124 | + @property |
| 125 | + def previous_contact_id(self) -> str: |
| 126 | + """The unique identifier for the contact before it was transferred. |
| 127 | + Use the previous contact ID to trace contacts between contact flows. |
| 128 | + """ |
| 129 | + return self["PreviousContactId"] |
| 130 | + |
| 131 | + @property |
| 132 | + def queue(self) -> Optional[ConnectContactFlowQueue]: |
| 133 | + """The current queue.""" |
| 134 | + if self["Queue"] is not None: |
| 135 | + return ConnectContactFlowQueue(self["Queue"]) |
| 136 | + return None |
| 137 | + |
| 138 | + @property |
| 139 | + def system_endpoint(self) -> Optional[ConnectContactFlowEndpoint]: |
| 140 | + """Contains the address (number) the customer dialed to call your contact center and type of address.""" |
| 141 | + if self["SystemEndpoint"] is not None: |
| 142 | + return ConnectContactFlowEndpoint(self["SystemEndpoint"]) |
| 143 | + return None |
| 144 | + |
| 145 | + @property |
| 146 | + def media_streams(self) -> ConnectContactFlowMediaStreams: |
| 147 | + return ConnectContactFlowMediaStreams(self["MediaStreams"]) |
| 148 | + |
| 149 | + |
| 150 | +class ConnectContactFlowEvent(DictWrapper): |
| 151 | + """Amazon Connect contact flow event |
| 152 | +
|
| 153 | + Documentation: |
| 154 | + ------------- |
| 155 | + - https://docs.aws.amazon.com/connect/latest/adminguide/connect-lambda-functions.html |
| 156 | + """ |
| 157 | + |
| 158 | + @property |
| 159 | + def contact_data(self) -> ConnectContactFlowData: |
| 160 | + """This is always passed by Amazon Connect for every contact. Some parameters are optional.""" |
| 161 | + return ConnectContactFlowData(self["Details"]["ContactData"]) |
| 162 | + |
| 163 | + @property |
| 164 | + def parameters(self) -> Dict[str, str]: |
| 165 | + """These are parameters specific to this call that were defined when you created the Lambda function.""" |
| 166 | + return self["Details"]["Parameters"] |
0 commit comments