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
100
101
102
use users::UserOptionField;
use api::{Bool, Collection, Id, LikesCount, OwnerId, Timestamp};

#[derive(Debug, PartialEq, Eq, Deserialize, Clone)]
pub struct WallPost {
    id: Id,
    owner_id: OwnerId,
    from_id: OwnerId,
    date: Timestamp,
    text: String,
    reply_owner_id: OwnerId,
    reply_post_id: Id,
    friends_only: Bool,
    comments: CommentsCount,
    likes: LikesCount,
    reposts: RepostsCount,
    post_type: PostType,
    post_source: PostSource, // TODO
    attachments: Vec<Attachment>, // TODO
    geo: GeoLocation, // TODO
    signer_id: Id,
    copy_history: Option<Vec<RepostInfo>>, // TODO
    can_pin: Bool,
    is_pinned: Bool,
}

#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub struct CommentsCount {
    count: u32,
    can_post: Bool,
}

#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub struct RepostsCount {
    count: u32,
    user_reposted: Bool,
}

#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub enum PostType {
    Post,
    Copy,
    Reply,
    Postpone,
    Suggest
}

#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub struct PostSource;
#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub struct Attachment;
#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub struct GeoLocation;
#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub struct RepostInfo;

#[derive(Debug, PartialEq, Eq, Deserialize, Clone, Copy)]
pub struct PostId {
    post_id: Id,
}

request_ref! {
    struct Get for ["wall.get"](v => 5.44, extended => 0) -> Collection<WallPost> {
        sized {
            owner_id: OwnerId = () => {},
            filter: Filter = (Filter::All) => {AsRef},
            offset: usize = (0) => {},
            count: usize = (100) => {},
        }
        unsized {
            domain: str = ("") => {=},
            fields: [UserOptionField] = (&[][..]) => {AsRef<Vec>},
        }
    }
}

request_ref! {
    struct Post for ["wall.post"](v => 5.44) -> PostId [Wall] {
        sized {
            owner_id: OwnerId = () => {},
            friend_only: bool = (true) => {bool},
            from_group: bool = (false) => {bool},
            signed: bool = (false) => {bool},
            publish_date: Timestamp = (0) => {},
            lat: f32 = () => {},
            long: f32 = () => {},
            place_id: Id = () => {},
            post_id: Id = () => {},
        }
        unsized {
            message: str = ("") => {=},
            services: str = ("") => {=},
        }
    }
}

enum_str! { Filter {
    Owner = "owner",
    Others = "others",
    All = "all",
    Suggests = "suggests",
}}