|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Bandwidth |
| 5 | +
|
| 6 | + Bandwidth's Communication APIs |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 1.0.0 |
| 9 | + Contact: letstalk@bandwidth.com |
| 10 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 11 | +
|
| 12 | + Do not edit the class manually. |
| 13 | +""" # noqa: E501 |
| 14 | + |
| 15 | + |
| 16 | +from __future__ import annotations |
| 17 | +import pprint |
| 18 | +import re # noqa: F401 |
| 19 | +import json |
| 20 | + |
| 21 | +from datetime import datetime |
| 22 | +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr |
| 23 | +from typing import Any, ClassVar, Dict, List, Optional |
| 24 | +from bandwidth.models.call_direction_enum import CallDirectionEnum |
| 25 | +from typing import Optional, Set |
| 26 | +from typing_extensions import Self |
| 27 | + |
| 28 | +class ReferCompleteCallback(BaseModel): |
| 29 | + """ |
| 30 | + The Refer Complete event is fired when the <Refer> verb finishes executing. This is sent to the referCompleteUrl specified on the <Refer> verb, and the BXML returned in it is executed on the call only on failure — the call is torn down on success. |
| 31 | + """ # noqa: E501 |
| 32 | + event_type: Optional[StrictStr] = Field(default=None, description="The event type, value is referComplete.", alias="eventType") |
| 33 | + event_time: Optional[datetime] = Field(default=None, description="The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.", alias="eventTime") |
| 34 | + account_id: Optional[StrictStr] = Field(default=None, description="The user account associated with the call.", alias="accountId") |
| 35 | + application_id: Optional[StrictStr] = Field(default=None, description="The id of the application associated with the call.", alias="applicationId") |
| 36 | + var_from: Optional[StrictStr] = Field(default=None, description="The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).", alias="from") |
| 37 | + to: Optional[StrictStr] = Field(default=None, description="The phone number that received the call, in E.164 format (e.g. +15555555555).") |
| 38 | + direction: Optional[CallDirectionEnum] = None |
| 39 | + call_id: Optional[StrictStr] = Field(default=None, description="The call id associated with the event.", alias="callId") |
| 40 | + call_url: Optional[StrictStr] = Field(default=None, description="The URL of the call associated with the event.", alias="callUrl") |
| 41 | + start_time: Optional[datetime] = Field(default=None, description="Time the call was started, in ISO 8601 format.", alias="startTime") |
| 42 | + answer_time: Optional[datetime] = Field(default=None, description="Time the call was answered, in ISO 8601 format.", alias="answerTime") |
| 43 | + tag: Optional[StrictStr] = Field(default=None, description="(optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.") |
| 44 | + refer_call_status: Optional[StrictStr] = Field(default=None, description="The outcome of the REFER operation. Either 'success' or 'failure'.", alias="referCallStatus") |
| 45 | + refer_sip_response_code: Optional[StrictInt] = Field(default=None, description="The SIP response code returned for the REFER request itself (e.g. 202, 405, 603). Present when a SIP response was received for the REFER.", alias="referSipResponseCode") |
| 46 | + notify_sip_response_code: Optional[StrictInt] = Field(default=None, description="The final SIP response code reported via NOTIFY. Present only when the caller's endpoint sent a final NOTIFY (e.g. 200, 404, 486). Not present on NOTIFY timeout or when REFER was rejected before a subscription was established.", alias="notifySipResponseCode") |
| 47 | + additional_properties: Dict[str, Any] = {} |
| 48 | + __properties: ClassVar[List[str]] = ["eventType", "eventTime", "accountId", "applicationId", "from", "to", "direction", "callId", "callUrl", "startTime", "answerTime", "tag", "referCallStatus", "referSipResponseCode", "notifySipResponseCode"] |
| 49 | + |
| 50 | + model_config = ConfigDict( |
| 51 | + populate_by_name=True, |
| 52 | + validate_assignment=True, |
| 53 | + protected_namespaces=(), |
| 54 | + ) |
| 55 | + |
| 56 | + |
| 57 | + def to_str(self) -> str: |
| 58 | + """Returns the string representation of the model using alias""" |
| 59 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 60 | + |
| 61 | + def to_json(self) -> str: |
| 62 | + """Returns the JSON representation of the model using alias""" |
| 63 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 64 | + return json.dumps(self.to_dict()) |
| 65 | + |
| 66 | + @classmethod |
| 67 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 68 | + """Create an instance of ReferCompleteCallback from a JSON string""" |
| 69 | + return cls.from_dict(json.loads(json_str)) |
| 70 | + |
| 71 | + def to_dict(self) -> Dict[str, Any]: |
| 72 | + """Return the dictionary representation of the model using alias. |
| 73 | +
|
| 74 | + This has the following differences from calling pydantic's |
| 75 | + `self.model_dump(by_alias=True)`: |
| 76 | +
|
| 77 | + * `None` is only added to the output dict for nullable fields that |
| 78 | + were set at model initialization. Other fields with value `None` |
| 79 | + are ignored. |
| 80 | + * Fields in `self.additional_properties` are added to the output dict. |
| 81 | + """ |
| 82 | + excluded_fields: Set[str] = set([ |
| 83 | + "additional_properties", |
| 84 | + ]) |
| 85 | + |
| 86 | + _dict = self.model_dump( |
| 87 | + by_alias=True, |
| 88 | + exclude=excluded_fields, |
| 89 | + exclude_none=True, |
| 90 | + ) |
| 91 | + # puts key-value pairs in additional_properties in the top level |
| 92 | + if self.additional_properties is not None: |
| 93 | + for _key, _value in self.additional_properties.items(): |
| 94 | + _dict[_key] = _value |
| 95 | + |
| 96 | + # set to None if answer_time (nullable) is None |
| 97 | + # and model_fields_set contains the field |
| 98 | + if self.answer_time is None and "answer_time" in self.model_fields_set: |
| 99 | + _dict['answerTime'] = None |
| 100 | + |
| 101 | + # set to None if tag (nullable) is None |
| 102 | + # and model_fields_set contains the field |
| 103 | + if self.tag is None and "tag" in self.model_fields_set: |
| 104 | + _dict['tag'] = None |
| 105 | + |
| 106 | + # set to None if refer_sip_response_code (nullable) is None |
| 107 | + # and model_fields_set contains the field |
| 108 | + if self.refer_sip_response_code is None and "refer_sip_response_code" in self.model_fields_set: |
| 109 | + _dict['referSipResponseCode'] = None |
| 110 | + |
| 111 | + # set to None if notify_sip_response_code (nullable) is None |
| 112 | + # and model_fields_set contains the field |
| 113 | + if self.notify_sip_response_code is None and "notify_sip_response_code" in self.model_fields_set: |
| 114 | + _dict['notifySipResponseCode'] = None |
| 115 | + |
| 116 | + return _dict |
| 117 | + |
| 118 | + @classmethod |
| 119 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 120 | + """Create an instance of ReferCompleteCallback from a dict""" |
| 121 | + if obj is None: |
| 122 | + return None |
| 123 | + |
| 124 | + if not isinstance(obj, dict): |
| 125 | + return cls.model_validate(obj) |
| 126 | + |
| 127 | + _obj = cls.model_validate({ |
| 128 | + "eventType": obj.get("eventType"), |
| 129 | + "eventTime": obj.get("eventTime"), |
| 130 | + "accountId": obj.get("accountId"), |
| 131 | + "applicationId": obj.get("applicationId"), |
| 132 | + "from": obj.get("from"), |
| 133 | + "to": obj.get("to"), |
| 134 | + "direction": obj.get("direction"), |
| 135 | + "callId": obj.get("callId"), |
| 136 | + "callUrl": obj.get("callUrl"), |
| 137 | + "startTime": obj.get("startTime"), |
| 138 | + "answerTime": obj.get("answerTime"), |
| 139 | + "tag": obj.get("tag"), |
| 140 | + "referCallStatus": obj.get("referCallStatus"), |
| 141 | + "referSipResponseCode": obj.get("referSipResponseCode"), |
| 142 | + "notifySipResponseCode": obj.get("notifySipResponseCode") |
| 143 | + }) |
| 144 | + # store additional fields in additional_properties |
| 145 | + for _key in obj.keys(): |
| 146 | + if _key not in cls.__properties: |
| 147 | + _obj.additional_properties[_key] = obj.get(_key) |
| 148 | + |
| 149 | + return _obj |
0 commit comments