|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + HelloAsso API |
| 5 | +
|
| 6 | + HelloAsso auto-generated SDK |
| 7 | +
|
| 8 | + The version of the OpenAPI document: public |
| 9 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 10 | +
|
| 11 | + Do not edit the class manually. |
| 12 | +""" # noqa: E501 |
| 13 | + |
| 14 | + |
| 15 | +from __future__ import annotations |
| 16 | +import pprint |
| 17 | +import re # noqa: F401 |
| 18 | +import json |
| 19 | + |
| 20 | +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr |
| 21 | +from typing import Any, ClassVar, Dict, List, Optional, Union |
| 22 | +from helloasso_python.models.hello_asso_api_v5_models_forms_custom_field_public_model import HelloAssoApiV5ModelsFormsCustomFieldPublicModel |
| 23 | +from typing import Optional, Set |
| 24 | +from typing_extensions import Self |
| 25 | + |
| 26 | +class HelloAssoApiV5ModelsFormsExtraOptionPublicModel(BaseModel): |
| 27 | + """ |
| 28 | + ExtraOptionFullModel |
| 29 | + """ # noqa: E501 |
| 30 | + custom_fields: Optional[List[HelloAssoApiV5ModelsFormsCustomFieldPublicModel]] = Field(default=None, description="List of custom fields to be filled by the user", alias="customFields") |
| 31 | + id: Optional[StrictInt] = Field(default=None, description="Id") |
| 32 | + price: Optional[StrictInt] = Field(default=None, description="Price of the extraOption, can be free") |
| 33 | + vat_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Vat rate if applicable Amount have to be 0.10 for 10%", alias="vatRate") |
| 34 | + label: Optional[StrictStr] = Field(default=None, description="The name of the option") |
| 35 | + description: Optional[StrictStr] = Field(default=None, description="The description of the option") |
| 36 | + is_required: Optional[StrictBool] = Field(default=None, description="Additional option is required/mandatory", alias="isRequired") |
| 37 | + __properties: ClassVar[List[str]] = ["customFields", "id", "price", "vatRate", "label", "description", "isRequired"] |
| 38 | + |
| 39 | + model_config = ConfigDict( |
| 40 | + populate_by_name=True, |
| 41 | + validate_assignment=True, |
| 42 | + protected_namespaces=(), |
| 43 | + ) |
| 44 | + |
| 45 | + |
| 46 | + def to_str(self) -> str: |
| 47 | + """Returns the string representation of the model using alias""" |
| 48 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 49 | + |
| 50 | + def to_json(self) -> str: |
| 51 | + """Returns the JSON representation of the model using alias""" |
| 52 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 53 | + return json.dumps(self.to_dict()) |
| 54 | + |
| 55 | + @classmethod |
| 56 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 57 | + """Create an instance of HelloAssoApiV5ModelsFormsExtraOptionPublicModel from a JSON string""" |
| 58 | + return cls.from_dict(json.loads(json_str)) |
| 59 | + |
| 60 | + def to_dict(self) -> Dict[str, Any]: |
| 61 | + """Return the dictionary representation of the model using alias. |
| 62 | +
|
| 63 | + This has the following differences from calling pydantic's |
| 64 | + `self.model_dump(by_alias=True)`: |
| 65 | +
|
| 66 | + * `None` is only added to the output dict for nullable fields that |
| 67 | + were set at model initialization. Other fields with value `None` |
| 68 | + are ignored. |
| 69 | + * OpenAPI `readOnly` fields are excluded. |
| 70 | + """ |
| 71 | + excluded_fields: Set[str] = set([ |
| 72 | + "is_required", |
| 73 | + ]) |
| 74 | + |
| 75 | + _dict = self.model_dump( |
| 76 | + by_alias=True, |
| 77 | + exclude=excluded_fields, |
| 78 | + exclude_none=True, |
| 79 | + ) |
| 80 | + # override the default output from pydantic by calling `to_dict()` of each item in custom_fields (list) |
| 81 | + _items = [] |
| 82 | + if self.custom_fields: |
| 83 | + for _item_custom_fields in self.custom_fields: |
| 84 | + if _item_custom_fields: |
| 85 | + _items.append(_item_custom_fields.to_dict()) |
| 86 | + _dict['customFields'] = _items |
| 87 | + # set to None if custom_fields (nullable) is None |
| 88 | + # and model_fields_set contains the field |
| 89 | + if self.custom_fields is None and "custom_fields" in self.model_fields_set: |
| 90 | + _dict['customFields'] = None |
| 91 | + |
| 92 | + # set to None if label (nullable) is None |
| 93 | + # and model_fields_set contains the field |
| 94 | + if self.label is None and "label" in self.model_fields_set: |
| 95 | + _dict['label'] = None |
| 96 | + |
| 97 | + # set to None if description (nullable) is None |
| 98 | + # and model_fields_set contains the field |
| 99 | + if self.description is None and "description" in self.model_fields_set: |
| 100 | + _dict['description'] = None |
| 101 | + |
| 102 | + return _dict |
| 103 | + |
| 104 | + @classmethod |
| 105 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 106 | + """Create an instance of HelloAssoApiV5ModelsFormsExtraOptionPublicModel from a dict""" |
| 107 | + if obj is None: |
| 108 | + return None |
| 109 | + |
| 110 | + if not isinstance(obj, dict): |
| 111 | + return cls.model_validate(obj) |
| 112 | + |
| 113 | + _obj = cls.model_validate({ |
| 114 | + "customFields": [HelloAssoApiV5ModelsFormsCustomFieldPublicModel.from_dict(_item) for _item in obj["customFields"]] if obj.get("customFields") is not None else None, |
| 115 | + "id": obj.get("id"), |
| 116 | + "price": obj.get("price"), |
| 117 | + "vatRate": obj.get("vatRate"), |
| 118 | + "label": obj.get("label"), |
| 119 | + "description": obj.get("description"), |
| 120 | + "isRequired": obj.get("isRequired") |
| 121 | + }) |
| 122 | + return _obj |
| 123 | + |
| 124 | + |
0 commit comments