lib.rs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. pub openai_key: String,
  39. }
  40. #[derive(Serialize, Deserialize, Default, Clone, Debug)]
  41. pub struct UpdateUserProfileParams {
  42. pub id: String,
  43. pub name: Option<String>,
  44. pub email: Option<String>,
  45. pub password: Option<String>,
  46. pub icon_url: Option<String>,
  47. pub openai_key: Option<String>,
  48. }
  49. impl UpdateUserProfileParams {
  50. pub fn new(user_id: &str) -> Self {
  51. Self {
  52. id: user_id.to_owned(),
  53. name: None,
  54. email: None,
  55. password: None,
  56. icon_url: None,
  57. openai_key: None,
  58. }
  59. }
  60. pub fn name(mut self, name: &str) -> Self {
  61. self.name = Some(name.to_owned());
  62. self
  63. }
  64. pub fn email(mut self, email: &str) -> Self {
  65. self.email = Some(email.to_owned());
  66. self
  67. }
  68. pub fn password(mut self, password: &str) -> Self {
  69. self.password = Some(password.to_owned());
  70. self
  71. }
  72. pub fn icon_url(mut self, icon_url: &str) -> Self {
  73. self.icon_url = Some(icon_url.to_owned());
  74. self
  75. }
  76. pub fn openai_key(mut self, openai_key: &str) -> Self {
  77. self.openai_key = Some(openai_key.to_owned());
  78. self
  79. }
  80. }