diff --git a/src/trello/attachment.rs b/src/trello/attachment.rs index bc09c69..3ca845b 100644 --- a/src/trello/attachment.rs +++ b/src/trello/attachment.rs @@ -6,7 +6,7 @@ use color_eyre::Result; use crate::{execute::Execute, p, FullCtx}; -use super::model::{TrelloAttachmentId, TrelloCardId}; +use super::model::{attachment::TrelloAttachmentId, card::TrelloCardId}; #[derive(Parser, Debug)] pub enum TrelloAttachmentCommand { diff --git a/src/trello/board.rs b/src/trello/board.rs index 22af4de..60a98a2 100644 --- a/src/trello/board.rs +++ b/src/trello/board.rs @@ -4,7 +4,7 @@ use clap::Parser; use crate::execute::Execute; use crate::{p, FullCtx}; -use super::model::TrelloBoardId; +use super::model::board::TrelloBoardId; #[derive(Parser, Debug)] pub enum TrelloBoardCommand { diff --git a/src/trello/card.rs b/src/trello/card.rs index bb8fd86..acefaae 100644 --- a/src/trello/card.rs +++ b/src/trello/card.rs @@ -4,7 +4,7 @@ use color_eyre::Result; use crate::{execute::Execute, p, FullCtx}; -use super::model::TrelloCardId; +use super::model::card::TrelloCardId; #[derive(Parser, Debug)] pub enum TrelloCardCommand { diff --git a/src/trello/client.rs b/src/trello/client.rs index 54ea871..2f215a2 100644 --- a/src/trello/client.rs +++ b/src/trello/client.rs @@ -5,14 +5,15 @@ use std::path::PathBuf; use color_eyre::eyre::Context; use kxio::net::{Net, ReqBuilder}; -use crate::trello::model::{TrelloAttachment, TrelloAttachmentId}; use crate::{ api_result::APIResult, f, s, trello::model::{ - board::TrelloBoard, + attachment::{TrelloAttachment, TrelloAttachmentId}, + board::{TrelloBoard, TrelloBoardId}, + card::TrelloCardId, card::{TrelloLongCard, TrelloShortCard}, - TrelloBoardId, TrelloCardId, TrelloListId, + list::TrelloListId, }, FullCtx, }; diff --git a/src/trello/model/attachment.rs b/src/trello/model/attachment.rs new file mode 100644 index 0000000..6ca15e8 --- /dev/null +++ b/src/trello/model/attachment.rs @@ -0,0 +1,25 @@ +// +use derive_more::derive::Display; +use serde::Deserialize; + +use crate::newtype; + +newtype!(TrelloAttachmentId, String, Display, "Card Attachment ID"); + +#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +pub(crate) struct TrelloAttachment { + pub(crate) id: String, // "5abbe4b7ddc1b351ef961414", + pub(crate) bytes: i64, + pub(crate) date: String, //"2018-10-17T19:10:14.808Z", + #[serde(rename = "idMember")] + pub(crate) id_member: String, //"5abbe4b7ddc1b351ef961414", + #[serde(rename = "isUpload")] + pub(crate) is_upload: bool, //false, + #[serde(rename = "mimeType")] + pub(crate) mime_type: Option, //"", + pub(crate) name: String, //"Deprecation Extension Notice", + pub(crate) url: String, //"https://admin.typeform.com/form/RzExEM/share#/link", + pub(crate) pos: i64, //1638 + #[serde(rename = "fileName")] + pub(crate) file_name: String, +} diff --git a/src/trello/model/board.rs b/src/trello/model/board.rs index cd44b0f..28dd09b 100644 --- a/src/trello/model/board.rs +++ b/src/trello/model/board.rs @@ -1,7 +1,10 @@ // -use crate::trello::model::list::TrelloList; +use derive_more::derive::Display; -use super::{TrelloBoardId, TrelloBoardName}; +use crate::{newtype, trello::model::list::TrelloList}; + +newtype!(TrelloBoardId, String, Display, "Board ID"); +newtype!(TrelloBoardName, String, Display, "Board Name"); #[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)] pub(crate) struct TrelloBoard { diff --git a/src/trello/model/card.rs b/src/trello/model/card.rs index be0fe69..e0fad1d 100644 --- a/src/trello/model/card.rs +++ b/src/trello/model/card.rs @@ -1,10 +1,18 @@ // -use super::{ - TrelloAttachment, TrelloAttachmentId, TrelloCardDescription, TrelloCardDue, TrelloCardId, - TrelloCardName, TrelloCardPosition, TrelloLabelId, TrelloListId, -}; +use derive_more::derive::Display; +use serde::Deserialize; -#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)] +use crate::newtype; + +use super::{attachment::{TrelloAttachment, TrelloAttachmentId}, label::TrelloLabelId, list::TrelloListId}; + +newtype!(TrelloCardId, String, Display, "Card ID"); +newtype!(TrelloCardName, String, Display, "Card Name"); +newtype!(TrelloCardDescription, String, Display, "Card Description"); +newtype!(TrelloCardDue, String, Display, "Card Due"); +newtype!(TrelloCardPosition, i64, Display, "Card Position"); + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize)] pub(crate) struct TrelloCard { pub(crate) id: TrelloCardId, pub(crate) name: TrelloCardName, @@ -12,7 +20,7 @@ pub(crate) struct TrelloCard { pub(crate) id_list: TrelloListId, } -#[derive(Debug, PartialEq, Eq, serde::Deserialize)] +#[derive(Debug, PartialEq, Eq, Deserialize)] pub(crate) struct TrelloShortCard { pub(crate) id: TrelloCardId, pub(crate) name: TrelloCardName, @@ -24,7 +32,7 @@ pub(crate) struct TrelloShortCard { pub(crate) pos: TrelloCardPosition, } -#[derive(Debug, PartialEq, Eq, serde::Deserialize)] +#[derive(Debug, PartialEq, Eq, Deserialize)] pub(crate) struct TrelloLongCard { pub(crate) id: TrelloCardId, pub(crate) name: TrelloCardName, diff --git a/src/trello/model/label.rs b/src/trello/model/label.rs new file mode 100644 index 0000000..b589223 --- /dev/null +++ b/src/trello/model/label.rs @@ -0,0 +1,6 @@ +// +use derive_more::derive::Display; + +use crate::newtype; + +newtype!(TrelloLabelId, String, Display, "Label ID"); diff --git a/src/trello/model/list.rs b/src/trello/model/list.rs index 5b6c0d3..0946fc4 100644 --- a/src/trello/model/list.rs +++ b/src/trello/model/list.rs @@ -1,7 +1,20 @@ // -use super::{TrelloListId, TrelloListName}; +use derive_more::derive::Display; +use serde::Deserialize; -#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)] +use crate::newtype; + +newtype!(TrelloListId, String, Display, "List ID"); +newtype!( + TrelloListName, + String, + Display, + PartialOrd, + Ord, + "List Name" +); + +#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] pub(crate) struct TrelloList { pub(crate) id: TrelloListId, pub(crate) name: TrelloListName, diff --git a/src/trello/model/mod.rs b/src/trello/model/mod.rs index 3433240..6bf7f6a 100644 --- a/src/trello/model/mod.rs +++ b/src/trello/model/mod.rs @@ -1,46 +1,7 @@ +// +pub(crate) mod attachment; pub(crate) mod auth; pub(crate) mod board; pub(crate) mod card; -pub(crate) mod list; - -use derive_more::derive::Display; -use serde::{Deserialize, Serialize}; - -use crate::newtype; - -newtype!(TrelloBoardId, String, Display, "Board ID"); -newtype!(TrelloBoardName, String, Display, "Board Name"); -newtype!(TrelloListId, String, Display, "List ID"); -newtype!( - TrelloListName, - String, - Display, - PartialOrd, - Ord, - "List Name" -); -newtype!(TrelloCardId, String, Display, "Card ID"); -newtype!(TrelloCardName, String, Display, "Card Name"); -newtype!(TrelloCardDescription, String, Display, "Card Description"); -newtype!(TrelloCardDue, String, Display, "Card Due"); -newtype!(TrelloCardPosition, i64, Display, "Card Position"); -newtype!(TrelloAttachmentId, String, Display, "Card Attachment ID"); -newtype!(TrelloLabelId, String, Display, "Label ID"); - -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] -pub(crate) struct TrelloAttachment { - pub(crate) id: String, // "5abbe4b7ddc1b351ef961414", - pub(crate) bytes: i64, - pub(crate) date: String, //"2018-10-17T19:10:14.808Z", - #[serde(rename = "idMember")] - pub(crate) id_member: String, //"5abbe4b7ddc1b351ef961414", - #[serde(rename = "isUpload")] - pub(crate) is_upload: bool, //false, - #[serde(rename = "mimeType")] - pub(crate) mime_type: Option, //"", - pub(crate) name: String, //"Deprecation Extension Notice", - pub(crate) url: String, //"https://admin.typeform.com/form/RzExEM/share#/link", - pub(crate) pos: i64, //1638 - #[serde(rename = "fileName")] - pub(crate) file_name: String, -} +pub(crate) mod label; +pub(crate) mod list; \ No newline at end of file diff --git a/src/trello/stack.rs b/src/trello/stack.rs index 650bf3b..ea3de7b 100644 --- a/src/trello/stack.rs +++ b/src/trello/stack.rs @@ -4,7 +4,7 @@ use color_eyre::Result; use crate::{execute::Execute, p, FullCtx}; -use super::model::TrelloListId; +use super::model::list::TrelloListId; #[derive(Parser, Debug)] pub enum TrelloStackCommand { diff --git a/src/trello/tests/attachment/get.rs b/src/trello/tests/attachment/get.rs index a5f8c94..5e5af88 100644 --- a/src/trello/tests/attachment/get.rs +++ b/src/trello/tests/attachment/get.rs @@ -1,6 +1,8 @@ // -use crate::trello::attachment::TrelloAttachmentCommand; -use crate::trello::model::TrelloAttachmentId; +use crate::trello::{ + attachment::TrelloAttachmentCommand, + model::{attachment::TrelloAttachmentId, card::TrelloCardId}, +}; use super::*; diff --git a/src/trello/tests/attachment/save.rs b/src/trello/tests/attachment/save.rs index 3195d33..919b9c9 100644 --- a/src/trello/tests/attachment/save.rs +++ b/src/trello/tests/attachment/save.rs @@ -1,11 +1,18 @@ -use crate::trello::attachment::TrelloAttachmentCommand; -use crate::trello::model::{TrelloAttachmentId, TrelloCardId}; -use crate::Command; +// +use std::path::PathBuf; + use assert2::let_assert; use http::Response; use kxio::fs::{FileSystem, TempFileSystem}; -use std::path::PathBuf; -// + +use crate::{ + trello::{ + attachment::TrelloAttachmentCommand, + model::{attachment::TrelloAttachmentId, card::TrelloCardId}, + }, + Command, +}; + use super::*; #[rstest::fixture] diff --git a/src/trello/tests/mod.rs b/src/trello/tests/mod.rs index 2b2aa09..fa91636 100644 --- a/src/trello/tests/mod.rs +++ b/src/trello/tests/mod.rs @@ -19,8 +19,8 @@ use crate::{ card::TrelloCardCommand, member::TrelloMemberCommand, model::{ - board::{TrelloBoard, TrelloBoards}, - TrelloBoardId, TrelloBoardName, TrelloCardId, + board::{TrelloBoard, TrelloBoardId, TrelloBoardName, TrelloBoards}, + card::TrelloCardId, }, stack::TrelloStackCommand, TrelloCommand, TrelloConfig, diff --git a/src/trello/tests/stack/get.rs b/src/trello/tests/stack/get.rs index 6962d2b..31bcbba 100644 --- a/src/trello/tests/stack/get.rs +++ b/src/trello/tests/stack/get.rs @@ -1,5 +1,6 @@ -use crate::trello::model::TrelloListId; // +use crate::trello::model::list::TrelloListId; + use super::*; #[rstest::fixture]