|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Messente API |
| 5 | +
|
| 6 | + [Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 2.0.0 |
| 9 | + Contact: messente@messente.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 pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr |
| 22 | +from typing import Any, ClassVar, Dict, List |
| 23 | +from messente_api.models.whats_app_parameter import WhatsAppParameter |
| 24 | +from typing import Optional, Set |
| 25 | +from typing_extensions import Self |
| 26 | + |
| 27 | +class ViberVideo(BaseModel): |
| 28 | + """ |
| 29 | + Viber video object |
| 30 | + """ # noqa: E501 |
| 31 | + url: StrictStr = Field(description="URL pointing to the video resource.") |
| 32 | + thumbnail: StrictStr = Field(description="URL pointing to the video thumbnail resource.") |
| 33 | + file_size: StrictInt = Field(description="Size of the video file in bytes. Cannot be larger than 200MB.") |
| 34 | + duration: List[WhatsAppParameter] = Field(description="Duration of the video in seconds. Cannot be longer than 600 seconds.") |
| 35 | + additional_properties: Dict[str, Any] = {} |
| 36 | + __properties: ClassVar[List[str]] = ["url", "thumbnail", "file_size", "duration"] |
| 37 | + |
| 38 | + model_config = ConfigDict( |
| 39 | + populate_by_name=True, |
| 40 | + validate_assignment=True, |
| 41 | + protected_namespaces=(), |
| 42 | + ) |
| 43 | + |
| 44 | + |
| 45 | + def to_str(self) -> str: |
| 46 | + """Returns the string representation of the model using alias""" |
| 47 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 48 | + |
| 49 | + def to_json(self) -> str: |
| 50 | + """Returns the JSON representation of the model using alias""" |
| 51 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 52 | + return json.dumps(self.to_dict()) |
| 53 | + |
| 54 | + @classmethod |
| 55 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 56 | + """Create an instance of ViberVideo from a JSON string""" |
| 57 | + return cls.from_dict(json.loads(json_str)) |
| 58 | + |
| 59 | + def to_dict(self) -> Dict[str, Any]: |
| 60 | + """Return the dictionary representation of the model using alias. |
| 61 | +
|
| 62 | + This has the following differences from calling pydantic's |
| 63 | + `self.model_dump(by_alias=True)`: |
| 64 | +
|
| 65 | + * `None` is only added to the output dict for nullable fields that |
| 66 | + were set at model initialization. Other fields with value `None` |
| 67 | + are ignored. |
| 68 | + * Fields in `self.additional_properties` are added to the output dict. |
| 69 | + """ |
| 70 | + excluded_fields: Set[str] = set([ |
| 71 | + "additional_properties", |
| 72 | + ]) |
| 73 | + |
| 74 | + _dict = self.model_dump( |
| 75 | + by_alias=True, |
| 76 | + exclude=excluded_fields, |
| 77 | + exclude_none=True, |
| 78 | + ) |
| 79 | + # override the default output from pydantic by calling `to_dict()` of each item in duration (list) |
| 80 | + _items = [] |
| 81 | + if self.duration: |
| 82 | + for _item in self.duration: |
| 83 | + if _item: |
| 84 | + _items.append(_item.to_dict()) |
| 85 | + _dict['duration'] = _items |
| 86 | + # puts key-value pairs in additional_properties in the top level |
| 87 | + if self.additional_properties is not None: |
| 88 | + for _key, _value in self.additional_properties.items(): |
| 89 | + _dict[_key] = _value |
| 90 | + |
| 91 | + return _dict |
| 92 | + |
| 93 | + @classmethod |
| 94 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 95 | + """Create an instance of ViberVideo from a dict""" |
| 96 | + if obj is None: |
| 97 | + return None |
| 98 | + |
| 99 | + if not isinstance(obj, dict): |
| 100 | + return cls.model_validate(obj) |
| 101 | + |
| 102 | + _obj = cls.model_validate({ |
| 103 | + "url": obj.get("url"), |
| 104 | + "thumbnail": obj.get("thumbnail"), |
| 105 | + "file_size": obj.get("file_size"), |
| 106 | + "duration": [WhatsAppParameter.from_dict(_item) for _item in obj["duration"]] if obj.get("duration") is not None else None |
| 107 | + }) |
| 108 | + # store additional fields in additional_properties |
| 109 | + for _key in obj.keys(): |
| 110 | + if _key not in cls.__properties: |
| 111 | + _obj.additional_properties[_key] = obj.get(_key) |
| 112 | + |
| 113 | + return _obj |
| 114 | + |
| 115 | + |
0 commit comments