-
Notifications
You must be signed in to change notification settings - Fork 3
Add Freshly Pressed #884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Add Freshly Pressed #884
Conversation
570747d
to
a1f4140
Compare
Handles cases like: - Valid u64 - `null` - -1 (used in some cases in place of `null`) - `false` (used in some cases in place of `null`)
a1f4140
to
e5e2c0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @jkmassel! I've left a few comments.
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, uniffi::Record)] | ||
pub struct FreshlyPressedDiscussionSettings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, a discussion
field needs to be added to FreshlyPressedPost
and use this struct
. At least, the sample json used in tests seem to include it.
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, uniffi::Record)] | ||
pub struct FreshlyPressedEditorialSettings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, all endpoint
files have an _endpoint
suffix, which this file should also follow.
pub struct FreshlyPressedPost { | ||
#[serde(rename = "ID")] | ||
pub id: PostId, | ||
#[serde(alias = "site_ID")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we specifically need to alias
, we should be consistent and use rename
everywhere.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, IntoStaticStr)] | ||
enum FreshlyPressedListParamsField { | ||
#[strum(serialize = "number")] | ||
Number, | ||
#[strum(serialize = "page")] | ||
Page, | ||
} | ||
|
||
impl AppendUrlQueryPairs for FreshlyPressedListParams { | ||
fn append_query_pairs(&self, query_pairs_mut: &mut QueryPairs) { | ||
query_pairs_mut | ||
.append_option_query_value_pair( | ||
FreshlyPressedListParamsField::Number, | ||
self.number.as_ref(), | ||
) | ||
.append_option_query_value_pair( | ||
FreshlyPressedListParamsField::Page, | ||
self.page.as_ref(), | ||
); | ||
} | ||
} | ||
|
||
impl FromUrlQueryPairs for FreshlyPressedListParams { | ||
fn from_url_query_pairs(query_pairs: UrlQueryPairsMap) -> Option<Self> { | ||
Some(Self { | ||
number: query_pairs.get(FreshlyPressedListParamsField::Number), | ||
page: query_pairs.get(FreshlyPressedListParamsField::Page), | ||
}) | ||
} | ||
|
||
fn supports_pagination() -> bool { | ||
true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should no longer be necessary and should be replaced with the new macros you've reviewed yesterday.
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, uniffi::Record)] | ||
pub struct FreshlyPressedPost { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Freshly Pressed" seemingly uses the same response format as all other response streams in Reader: site, tags, feeds, discover. I suggest generalizing it from the start even if we don't end up using it everywhere originally.
Adds the WP.com Freshly Pressed endpoints for integration into Reader.