forked from sns-sdks/python-facebook
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathattachment.py
More file actions
99 lines (71 loc) · 2.71 KB
/
attachment.py
File metadata and controls
99 lines (71 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""
Models for Attachments
Refer: https://developers.facebook.com/docs/graph-api/reference/post/attachments/
"""
from dataclasses import dataclass
from typing import List, Optional
from pyfacebook.models.base import BaseModel, field
from pyfacebook.models.extensions import Paging
from pyfacebook.models.image import ImageSource
@dataclass
class EntityAtTextRange(BaseModel):
"""
A class representing the Entity At Text Range.
Refer: https://developers.facebook.com/docs/graph-api/reference/entity-at-text-range/
"""
id: Optional[str] = field(repr=True, compare=True)
length: Optional[int] = field()
name: Optional[str] = field(repr=True)
object: Optional[dict] = field() # TODO
offset: Optional[int] = field()
type: Optional[str] = field()
@dataclass
class StoryAttachmentMedia(BaseModel):
"""
A class representing the Story Attachment Media.
Refer: https://developers.facebook.com/docs/graph-api/reference/story-attachment-media/
"""
image: Optional[ImageSource] = field()
source: Optional[str] = field(repr=True)
@dataclass
class StoryAttachmentTarget(BaseModel):
"""
A class representing the Story Attachment Target.
Refer: https://developers.facebook.com/docs/graph-api/reference/story-attachment-target/
"""
id: Optional[str] = field(repr=True)
unshimmed_url: Optional[str] = field()
url: Optional[str] = field()
@dataclass
class StoryAttachmentSubattachments(BaseModel):
"""
A class representing the Story Attachment Subattachments.
Refer: https://developers.facebook.com/docs/graph-api/reference/story-attachment/subattachments/
"""
data: Optional[List["StoryAttachment"]] = field(repr=True)
paging: Optional[Paging] = field()
@dataclass
class StoryAttachment(BaseModel):
"""
A class representing the Story Attachment
Refer: https://developers.facebook.com/docs/graph-api/reference/story-attachment/
"""
description: Optional[str] = field()
description_tags: Optional[List[EntityAtTextRange]] = field()
media: Optional[StoryAttachmentMedia] = field()
media_type: Optional[str] = field(repr=True)
target: Optional[StoryAttachmentTarget] = field()
title: Optional[str] = field()
type: Optional[str] = field(repr=True)
unshimmed_url: Optional[str] = field()
url: Optional[str] = field()
# common connections
subattachments: Optional[StoryAttachmentSubattachments] = field()
@dataclass
class Attachments(BaseModel):
"""
A class representing the Attachments connection.
Refer: https://developers.facebook.com/docs/graph-api/reference/post/attachments/
"""
data: Optional[List[StoryAttachment]] = field(repr=True)
paging: Optional[Paging] = field()