|
| 1 | +use crate::{ |
| 2 | + UserId, WpApiParamOrder, |
| 3 | + date::WpGmtDateTime, |
| 4 | + impl_as_query_value_from_to_string, |
| 5 | + navigations::NavigationId, |
| 6 | + url_query::{ |
| 7 | + AppendUrlQueryPairs, FromUrlQueryPairs, QueryPairs, QueryPairsExtension, UrlQueryPairsMap, |
| 8 | + }, |
| 9 | + wp_content_i64_id, |
| 10 | +}; |
| 11 | +use serde::{Deserialize, Serialize}; |
| 12 | +use wp_contextual::WpContextual; |
| 13 | +use wp_derive::WpDeriveParamsField; |
| 14 | + |
| 15 | +wp_content_i64_id!(NavigationRevisionId); |
| 16 | + |
| 17 | +#[derive( |
| 18 | + Debug, |
| 19 | + Default, |
| 20 | + Clone, |
| 21 | + Copy, |
| 22 | + PartialEq, |
| 23 | + Eq, |
| 24 | + uniffi::Enum, |
| 25 | + strum_macros::EnumString, |
| 26 | + strum_macros::Display, |
| 27 | +)] |
| 28 | +#[strum(serialize_all = "snake_case")] |
| 29 | +pub enum WpApiParamNavigationRevisionsOrderBy { |
| 30 | + #[default] |
| 31 | + Date, |
| 32 | + Id, |
| 33 | + Include, |
| 34 | + IncludeSlugs, |
| 35 | + Relevance, |
| 36 | + Slug, |
| 37 | + Title, |
| 38 | +} |
| 39 | + |
| 40 | +impl_as_query_value_from_to_string!(WpApiParamNavigationRevisionsOrderBy); |
| 41 | + |
| 42 | +#[derive(Debug, Default, PartialEq, Eq, uniffi::Record, WpDeriveParamsField)] |
| 43 | +#[supports_pagination(true)] |
| 44 | +pub struct NavigationRevisionListParams { |
| 45 | + /// Current page of the collection. |
| 46 | + /// Default: `1` |
| 47 | + #[uniffi(default = None)] |
| 48 | + pub page: Option<u32>, |
| 49 | + /// Maximum number of items to be returned in result set. |
| 50 | + #[uniffi(default = None)] |
| 51 | + pub per_page: Option<u32>, |
| 52 | + /// Limit results to those matching a string. |
| 53 | + #[uniffi(default = None)] |
| 54 | + pub search: Option<String>, |
| 55 | + /// Ensure result set excludes specific IDs. |
| 56 | + #[uniffi(default = [])] |
| 57 | + pub exclude: Vec<NavigationRevisionId>, |
| 58 | + /// Limit result set to specific IDs. |
| 59 | + #[uniffi(default = [])] |
| 60 | + pub include: Vec<NavigationRevisionId>, |
| 61 | + /// Offset the result set by a specific number of items. |
| 62 | + #[uniffi(default = None)] |
| 63 | + pub offset: Option<u32>, |
| 64 | + /// Order sort attribute ascending or descending. |
| 65 | + /// Default: desc |
| 66 | + /// One of: asc, desc |
| 67 | + #[uniffi(default = None)] |
| 68 | + pub order: Option<WpApiParamOrder>, |
| 69 | + /// Sort collection by object attribute. |
| 70 | + /// Default: date |
| 71 | + /// One of: date, id, include, relevance, slug, include_slugs, title |
| 72 | + #[uniffi(default = None)] |
| 73 | + #[field_name("orderby")] |
| 74 | + pub orderby: Option<WpApiParamNavigationRevisionsOrderBy>, |
| 75 | +} |
| 76 | + |
| 77 | +#[derive(Debug, Serialize, Deserialize, uniffi::Record, WpContextual)] |
| 78 | +pub struct SparseNavigationRevision { |
| 79 | + #[WpContext(edit, embed, view)] |
| 80 | + pub id: Option<NavigationRevisionId>, |
| 81 | + #[WpContext(edit, embed, view)] |
| 82 | + pub author: Option<UserId>, |
| 83 | + #[WpContext(edit, embed, view)] |
| 84 | + pub date: Option<String>, |
| 85 | + #[WpContext(edit, view)] |
| 86 | + pub date_gmt: Option<WpGmtDateTime>, |
| 87 | + #[WpContext(edit, view)] |
| 88 | + pub modified: Option<String>, |
| 89 | + #[WpContext(edit, view)] |
| 90 | + pub modified_gmt: Option<WpGmtDateTime>, |
| 91 | + #[WpContext(edit, embed, view)] |
| 92 | + pub parent: Option<NavigationId>, |
| 93 | + #[WpContext(edit, embed, view)] |
| 94 | + pub slug: Option<String>, |
| 95 | + #[WpContext(edit, view)] |
| 96 | + #[WpContextualField] |
| 97 | + pub guid: Option<crate::navigations::SparseNavigationGuid>, |
| 98 | + #[WpContext(edit, embed, view)] |
| 99 | + #[WpContextualField] |
| 100 | + pub title: Option<crate::navigations::SparseNavigationTitle>, |
| 101 | + #[WpContext(edit, view)] |
| 102 | + #[WpContextualField] |
| 103 | + pub content: Option<crate::navigations::SparseNavigationContent>, |
| 104 | + // meta field omitted for now |
| 105 | +} |
| 106 | + |
| 107 | +#[derive(Debug, Serialize, Deserialize, uniffi::Record)] |
| 108 | +pub struct NavigationRevisionDeleteResponse { |
| 109 | + pub deleted: bool, |
| 110 | + pub previous: NavigationRevisionWithEditContext, |
| 111 | +} |
0 commit comments