-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathresponses.py
81 lines (64 loc) · 2.74 KB
/
responses.py
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
from __future__ import annotations
from typing import Any, Dict, List, Optional, Union
from aleph_message.models import (
AlephMessage,
Chain,
ItemHash,
ItemType,
MessageConfirmation,
)
from pydantic import BaseModel, ConfigDict, Field
class Post(BaseModel):
"""
A post is a type of message that can be updated. Over the get_posts API
we get the latest version of a post.
"""
chain: Chain = Field(description="Blockchain this post is associated with")
item_hash: ItemHash = Field(description="Unique hash for this post")
sender: str = Field(description="Address of the sender")
type: str = Field(description="Type of the POST message")
channel: Optional[str] = Field(description="Channel this post is associated with")
confirmed: bool = Field(description="Whether the post is confirmed or not")
content: Dict[str, Any] = Field(description="The content of the POST message")
item_content: Optional[str] = Field(
description="The POSTs content field as serialized JSON, if of type inline"
)
item_type: ItemType = Field(
description="Type of the item content, usually 'inline' or 'storage' for POSTs"
)
signature: Optional[str] = Field(
description="Cryptographic signature of the message by the sender"
)
size: int = Field(description="Size of the post")
time: float = Field(description="Timestamp of the post")
confirmations: List[MessageConfirmation] = Field(
description="Number of confirmations"
)
original_item_hash: ItemHash = Field(description="Hash of the original content")
original_signature: Optional[str] = Field(
description="Cryptographic signature of the original message"
)
original_type: str = Field(description="The original type of the message")
hash: ItemHash = Field(description="Hash of the original item")
ref: Optional[Union[str, Any]] = Field(
description="Other message referenced by this one"
)
address: Optional[str] = Field(description="Address of the sender")
model_config = ConfigDict(extra="forbid")
class PaginationResponse(BaseModel):
pagination_page: int
pagination_total: int
pagination_per_page: int
pagination_item: str
class PostsResponse(PaginationResponse):
"""Response from an aleph.im node API on the path /api/v0/posts.json"""
posts: List[Post]
pagination_item: str = "posts"
class MessagesResponse(PaginationResponse):
"""Response from an aleph.im node API on the path /api/v0/messages.json"""
messages: List[AlephMessage]
pagination_item: str = "messages"
class PriceResponse(BaseModel):
"""Response from an aleph.im node API on the path /api/v0/price/{item_hash}"""
required_tokens: float
payment_type: str