|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +PostFinance Python SDK |
| 5 | +
|
| 6 | +This library allows to interact with the PostFinance payment service. |
| 7 | +
|
| 8 | +Copyright owner: Wallee AG |
| 9 | +Website: https://www.postfinance.ch/en/private.html |
| 10 | +Developer email: ecosystem-team@wallee.com |
| 11 | +
|
| 12 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 | +you may not use this file except in compliance with the License. |
| 14 | +You may obtain a copy of the License at |
| 15 | +
|
| 16 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | +
|
| 18 | +Unless required by applicable law or agreed to in writing, software |
| 19 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | +See the License for the specific language governing permissions and |
| 22 | +limitations under the License. |
| 23 | +""" |
| 24 | + |
| 25 | + |
| 26 | +from __future__ import annotations |
| 27 | +import pprint |
| 28 | +import re # noqa: F401 |
| 29 | +import json |
| 30 | + |
| 31 | +from pydantic import BaseModel, ConfigDict, Field, StrictStr |
| 32 | +from typing import Any, ClassVar, Dict, List, Optional |
| 33 | +from typing import Optional, Set |
| 34 | +from typing_extensions import Self |
| 35 | + |
| 36 | +class BogusExpressCheckoutPaymentData(BaseModel): |
| 37 | + """ |
| 38 | + BogusExpressCheckoutPaymentData |
| 39 | + """ # noqa: E501 |
| 40 | + payment_token: Optional[StrictStr] = Field(default=None, description="Wallet-generated payment token collected during approval.", alias="paymentToken") |
| 41 | + cryptogram: Optional[StrictStr] = Field(default=None, description="Wallet-generated cryptogram collected during approval.") |
| 42 | + __properties: ClassVar[List[str]] = ["paymentToken", "cryptogram"] |
| 43 | + |
| 44 | + model_config = ConfigDict( |
| 45 | + populate_by_name=True, |
| 46 | + validate_assignment=True, |
| 47 | + protected_namespaces=(), |
| 48 | + ) |
| 49 | + |
| 50 | + |
| 51 | + def to_str(self) -> str: |
| 52 | + """Returns the string representation of the model using alias""" |
| 53 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 54 | + |
| 55 | + def to_json(self) -> str: |
| 56 | + """Returns the JSON representation of the model using alias""" |
| 57 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 58 | + return json.dumps(self.to_dict()) |
| 59 | + |
| 60 | + @classmethod |
| 61 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 62 | + """Create an instance of BogusExpressCheckoutPaymentData from a JSON string""" |
| 63 | + return cls.from_dict(json.loads(json_str)) |
| 64 | + |
| 65 | + def to_dict(self) -> Dict[str, Any]: |
| 66 | + """Return the dictionary representation of the model using alias. |
| 67 | +
|
| 68 | + This has the following differences from calling pydantic's |
| 69 | + `self.model_dump(by_alias=True)`: |
| 70 | +
|
| 71 | + * `None` is only added to the output dict for nullable fields that |
| 72 | + were set at model initialization. Other fields with value `None` |
| 73 | + are ignored. |
| 74 | + * OpenAPI `readOnly` fields are excluded. |
| 75 | + * OpenAPI `readOnly` fields are excluded. |
| 76 | + """ |
| 77 | + excluded_fields: Set[str] = set([ |
| 78 | + "payment_token", |
| 79 | + "cryptogram", |
| 80 | + ]) |
| 81 | + |
| 82 | + _dict = self.model_dump( |
| 83 | + by_alias=True, |
| 84 | + exclude=excluded_fields, |
| 85 | + exclude_none=True, |
| 86 | + ) |
| 87 | + return _dict |
| 88 | + |
| 89 | + @classmethod |
| 90 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 91 | + """Create an instance of BogusExpressCheckoutPaymentData from a dict""" |
| 92 | + if obj is None: |
| 93 | + return None |
| 94 | + |
| 95 | + if not isinstance(obj, dict): |
| 96 | + return cls.model_validate(obj) |
| 97 | + |
| 98 | + _obj = cls.model_validate({ |
| 99 | + "paymentToken": obj.get("paymentToken"), |
| 100 | + "cryptogram": obj.get("cryptogram") |
| 101 | + }) |
| 102 | + return _obj |
| 103 | + |
| 104 | + |
0 commit comments