|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Webhook Type Definition |
| 5 | +
|
| 6 | + Webhook event definition of the LINE Messaging API # noqa: E501 |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 1.0.0 |
| 9 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 10 | +
|
| 11 | + Do not edit the class manually. |
| 12 | +""" |
| 13 | + |
| 14 | + |
| 15 | +from __future__ import annotations |
| 16 | +import pprint |
| 17 | +import re # noqa: F401 |
| 18 | +import json |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +from pydantic.v1 import Field |
| 23 | +from linebot.v3.webhooks.models.delivery_context import DeliveryContext |
| 24 | +from linebot.v3.webhooks.models.event import Event |
| 25 | +from linebot.v3.webhooks.models.event_mode import EventMode |
| 26 | +from linebot.v3.webhooks.models.pnp_delivery import PnpDelivery |
| 27 | +from linebot.v3.webhooks.models.source import Source |
| 28 | + |
| 29 | +class PnpDeliveryCompletionEvent(Event): |
| 30 | + """ |
| 31 | + When a request is made to the LINE notification messages API and delivery of the LINE notification message to the user is completed, a dedicated webhook event (delivery completion event) is sent from the LINE Platform to the webhook URL of the bot server. |
| 32 | + """ |
| 33 | + delivery: PnpDelivery = Field(...) |
| 34 | + type: str = "delivery" |
| 35 | + |
| 36 | + __properties = ["type", "source", "timestamp", "mode", "webhookEventId", "deliveryContext", "delivery"] |
| 37 | + |
| 38 | + class Config: |
| 39 | + """Pydantic configuration""" |
| 40 | + allow_population_by_field_name = True |
| 41 | + validate_assignment = True |
| 42 | + |
| 43 | + def to_str(self) -> str: |
| 44 | + """Returns the string representation of the model using alias""" |
| 45 | + return pprint.pformat(self.dict(by_alias=True)) |
| 46 | + |
| 47 | + def to_json(self) -> str: |
| 48 | + """Returns the JSON representation of the model using alias""" |
| 49 | + return json.dumps(self.to_dict()) |
| 50 | + |
| 51 | + @classmethod |
| 52 | + def from_json(cls, json_str: str) -> PnpDeliveryCompletionEvent: |
| 53 | + """Create an instance of PnpDeliveryCompletionEvent from a JSON string""" |
| 54 | + return cls.from_dict(json.loads(json_str)) |
| 55 | + |
| 56 | + def to_dict(self): |
| 57 | + """Returns the dictionary representation of the model using alias""" |
| 58 | + _dict = self.dict(by_alias=True, |
| 59 | + exclude={ |
| 60 | + }, |
| 61 | + exclude_none=True) |
| 62 | + # override the default output from pydantic.v1 by calling `to_dict()` of source |
| 63 | + if self.source: |
| 64 | + _dict['source'] = self.source.to_dict() |
| 65 | + # override the default output from pydantic.v1 by calling `to_dict()` of delivery_context |
| 66 | + if self.delivery_context: |
| 67 | + _dict['deliveryContext'] = self.delivery_context.to_dict() |
| 68 | + # override the default output from pydantic.v1 by calling `to_dict()` of delivery |
| 69 | + if self.delivery: |
| 70 | + _dict['delivery'] = self.delivery.to_dict() |
| 71 | + return _dict |
| 72 | + |
| 73 | + @classmethod |
| 74 | + def from_dict(cls, obj: dict) -> PnpDeliveryCompletionEvent: |
| 75 | + """Create an instance of PnpDeliveryCompletionEvent from a dict""" |
| 76 | + if obj is None: |
| 77 | + return None |
| 78 | + |
| 79 | + if not isinstance(obj, dict): |
| 80 | + return PnpDeliveryCompletionEvent.parse_obj(obj) |
| 81 | + |
| 82 | + _obj = PnpDeliveryCompletionEvent.parse_obj({ |
| 83 | + "type": obj.get("type"), |
| 84 | + "source": Source.from_dict(obj.get("source")) if obj.get("source") is not None else None, |
| 85 | + "timestamp": obj.get("timestamp"), |
| 86 | + "mode": obj.get("mode"), |
| 87 | + "webhook_event_id": obj.get("webhookEventId"), |
| 88 | + "delivery_context": DeliveryContext.from_dict(obj.get("deliveryContext")) if obj.get("deliveryContext") is not None else None, |
| 89 | + "delivery": PnpDelivery.from_dict(obj.get("delivery")) if obj.get("delivery") is not None else None |
| 90 | + }) |
| 91 | + return _obj |
| 92 | + |
0 commit comments