Skip to content

Commit

Permalink
Merge pull request #45 from kstep/issue-15-video
Browse files Browse the repository at this point in the history
Implement video API (closes #15)
  • Loading branch information
kstep committed Feb 7, 2016
2 parents 67d2319 + dbd2bd0 commit 7099b9d
Show file tree
Hide file tree
Showing 4 changed files with 568 additions and 13 deletions.
43 changes: 43 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,17 @@ pub enum ErrorCode {
GoodsNotFound, // 20
GoodsUnvailable, // 21
UserNotFound, // 22
RequiredParameterMissing, // 100
UserMenuAccessDenied, // 148
AccessDenied, // 204
PostAddAccessDenied, // 214
AdsPostWasRecentlyAdded, // 219,
TooManyRecipients, // 220,
HyperlinksForbidden, // 222
UserDisabledTrackBroadcast, // 221
AlbumsNumberLimitReached, // 302
VideoAlreadyAdded, // 800
VideoCommentsClosed, // 801
App(u32), // 100-999
Unknown(u32), // other
}
Expand All @@ -240,13 +244,17 @@ impl From<u32> for ErrorCode {
20 => GoodsNotFound,
21 => GoodsUnvailable,
22 => UserNotFound,
100 => RequiredParameterMissing,
148 => UserMenuAccessDenied,
204 => AccessDenied,
214 => PostAddAccessDenied,
219 => AdsPostWasRecentlyAdded,
220 => TooManyRecipients,
222 => HyperlinksForbidden,
221 => UserDisabledTrackBroadcast,
302 => AlbumsNumberLimitReached,
800 => VideoAlreadyAdded,
801 => VideoCommentsClosed,
v @ 100...999 => App(v),
v @ _ => Unknown(v),
}
Expand All @@ -268,13 +276,17 @@ impl Into<u32> for ErrorCode {
GoodsNotFound => 20,
GoodsUnvailable => 21,
UserNotFound => 22,
RequiredParameterMissing => 100,
UserMenuAccessDenied => 148,
AccessDenied => 204,
PostAddAccessDenied => 214,
AdsPostWasRecentlyAdded => 219,
TooManyRecipients => 220,
HyperlinksForbidden => 222,
UserDisabledTrackBroadcast => 221,
AlbumsNumberLimitReached => 302,
VideoAlreadyAdded => 800,
VideoCommentsClosed => 801,
App(v) => v,
Unknown(v) => v,
}
Expand All @@ -297,13 +309,17 @@ impl fmt::Display for ErrorCode {
GoodsNotFound => f.write_str("goods not found"),
GoodsUnvailable => f.write_str("goods unavailable"),
UserNotFound => f.write_str("user not found"),
RequiredParameterMissing => f.write_str("one of required parameters is missing"),
UserMenuAccessDenied => f.write_str("access to the menu of the user denied"),
AccessDenied => f.write_str("access denied"),
PostAddAccessDenied => f.write_str("access to adding post denied"),
AdsPostWasRecentlyAdded => f.write_str("ads post was recently added"),
TooManyRecipients => f.write_str("too many recipients"),
HyperlinksForbidden => f.write_str("hyperlinks are forbidden"),
UserDisabledTrackBroadcast => f.write_str("user disabled track name broadcast"),
AlbumsNumberLimitReached => f.write_str("albums number limit is reached"),
VideoAlreadyAdded => f.write_str("video is already added"),
VideoCommentsClosed => f.write_str("comments for this video are closed"),
App(v) => write!(f, "application error #{}", v),
Unknown(v) => write!(f, "unknown error #{}", v),
}
Expand Down Expand Up @@ -359,3 +375,30 @@ impl AsRef<str> for Sort {
}
}
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[repr(u8)]
pub enum ReportReason {
Spam = 0,
ChildPorn = 1,
Extremism = 2,
Violence = 3,
Drugs = 4,
AdultOnly = 5,
Offence = 6,
}

impl AsRef<str> for ReportReason {
fn as_ref(&self) -> &str {
use self::ReportReason::*;
match *self {
Spam => "0",
ChildPorn => "1",
Extremism => "2",
Violence => "3",
Drugs => "4",
AdultOnly => "5",
Offence => "6",
}
}
}
10 changes: 0 additions & 10 deletions src/photos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,3 @@ impl AsRef<str> for Sort {
}
}
}

pub enum ReportReason {
Spam = 0,
ChildPorn = 1,
Extremism = 2,
Violence = 3,
Drugs = 4,
AdultOnly = 5,
Offence = 6,
}
Loading

0 comments on commit 7099b9d

Please sign in to comment.