lib.rs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. pub mod errors;
  2. pub mod parser;
  3. pub use parser::*;
  4. use serde::{Deserialize, Serialize};
  5. #[derive(Default, Serialize, Deserialize, Debug)]
  6. pub struct SignInParams {
  7. pub email: String,
  8. pub password: String,
  9. pub name: String,
  10. }
  11. #[derive(Debug, Default, Serialize, Deserialize, Clone)]
  12. pub struct SignInResponse {
  13. pub user_id: String,
  14. pub name: String,
  15. pub email: String,
  16. pub token: String,
  17. }
  18. #[derive(Serialize, Deserialize, Default, Debug)]
  19. pub struct SignUpParams {
  20. pub email: String,
  21. pub name: String,
  22. pub password: String,
  23. }
  24. #[derive(Serialize, Deserialize, Debug, Default, Clone)]
  25. pub struct SignUpResponse {
  26. pub user_id: String,
  27. pub name: String,
  28. pub email: String,
  29. pub token: String,
  30. }
  31. #[derive(Serialize, Deserialize, Default, Debug, Clone)]
  32. pub struct UserProfile {
  33. pub id: String,
  34. pub email: String,
  35. pub name: String,
  36. pub token: String,
  37. pub icon_url: String,
  38. }
  39. #[derive(Serialize, Deserialize, Default, Clone, Debug)]
  40. pub struct UpdateUserProfileParams {
  41. pub id: String,
  42. pub name: Option<String>,
  43. pub email: Option<String>,
  44. pub password: Option<String>,
  45. pub icon_url: Option<String>,
  46. }
  47. impl UpdateUserProfileParams {
  48. pub fn new(user_id: &str) -> Self {
  49. Self {
  50. id: user_id.to_owned(),
  51. name: None,
  52. email: None,
  53. password: None,
  54. icon_url: None,
  55. }
  56. }
  57. pub fn name(mut self, name: &str) -> Self {
  58. self.name = Some(name.to_owned());
  59. self
  60. }
  61. pub fn email(mut self, email: &str) -> Self {
  62. self.email = Some(email.to_owned());
  63. self
  64. }
  65. pub fn password(mut self, password: &str) -> Self {
  66. self.password = Some(password.to_owned());
  67. self
  68. }
  69. pub fn icon_url(mut self, icon_url: &str) -> Self {
  70. self.icon_url = Some(icon_url.to_owned());
  71. self
  72. }
  73. }