Skip to content

Commit 851d155

Browse files
committed
update models for new generic entity struct
1 parent f8e3edb commit 851d155

File tree

8 files changed

+33
-196
lines changed

8 files changed

+33
-196
lines changed

src/model/allocation.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,10 @@ pub struct Allocation {
4040
pub time_off_type: Option<TimeOffType>,
4141
}
4242

43-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
44-
#[serde(rename_all = "camelCase")]
45-
pub struct Placeholder {
46-
pub id: types::UUID,
47-
pub name: String,
48-
}
49-
50-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
51-
#[serde(rename_all = "camelCase")]
52-
pub struct Role {
53-
pub id: types::UUID,
54-
pub name: String,
55-
}
56-
57-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
58-
#[serde(rename_all = "camelCase")]
59-
pub struct Task {
60-
pub id: types::UUID,
61-
pub name: String,
62-
}
63-
64-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
65-
#[serde(rename_all = "camelCase")]
66-
pub struct TimeOffType {
67-
pub id: types::UUID,
68-
pub name: String,
69-
}
43+
pub type Placeholder = shared::Entity;
44+
pub type Role = shared::Entity;
45+
pub type Task = shared::Entity;
46+
pub type TimeOffType = shared::Entity;
7047

7148
// custom types: enum
7249
#[derive(PartialEq, Deserialize, Serialize, Debug)]

src/model/client.rs

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! `model::customer` is a model for the Ruddr Client object. This module is not publically accessible, but the structs and members are public for reading from `interface::customer` returns.
44
//! [API Documentation](https://ruddr.readme.io/reference/client-object)
5-
use crate::model::types;
5+
use crate::model::{shared, types};
66
use serde::{Deserialize, Serialize};
77

88
/// Model for Clients used with List operations.
@@ -41,40 +41,11 @@ pub struct Client {
4141
pub business_unit: Option<BusinessUnit>,
4242
}
4343

44-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
45-
#[serde(rename_all = "camelCase")]
46-
pub struct Practice {
47-
pub id: types::UUID,
48-
pub name: String,
49-
}
50-
51-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
52-
#[serde(rename_all = "camelCase")]
53-
pub struct Owner {
54-
pub id: types::UUID,
55-
pub name: String,
56-
}
57-
58-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
59-
#[serde(rename_all = "camelCase")]
60-
pub struct InvoicePaymentTerm {
61-
pub id: types::UUID,
62-
pub name: PaymentTerms,
63-
}
64-
65-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
66-
#[serde(rename_all = "camelCase")]
67-
pub struct Tag {
68-
pub id: types::UUID,
69-
pub name: String,
70-
}
71-
72-
#[derive(Debug, PartialEq, Deserialize, Serialize)]
73-
#[serde(rename_all = "camelCase")]
74-
pub struct BusinessUnit {
75-
pub id: types::UUID,
76-
pub name: String,
77-
}
44+
pub type Practice = shared::Entity;
45+
pub type Owner = shared::Entity;
46+
pub type InvoicePaymentTerm = shared::Entity;
47+
pub type Tag = shared::Entity;
48+
pub type BusinessUnit = shared::Entity;
7849

7950
// custom types: enum
8051
#[derive(PartialEq, Deserialize, Serialize, Debug)]

src/model/client/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn test_client_deserialize() {
8282
}),
8383
invoice_payment_term: InvoicePaymentTerm {
8484
id: types::UUID(String::from("83b13634-4de2-4744-ab9e-61cf13038657")),
85-
name: PaymentTerms::Net30,
85+
name: String::from("Net-30"),
8686
},
8787
owner: Owner {
8888
id: types::UUID(String::from("db010cff-a6f6-4c4e-8160-b6b7562865ff")),

src/model/member.rs

Lines changed: 12 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! `model::member` is a model for the Ruddr Member object. This module is not publically accessible, but the structs and members are public for reading from `interface::member` returns.
44
//! [API Documentation](https://ruddr.readme.io/reference/member-object)
5-
use crate::model::types;
5+
use crate::model::{shared, types};
66
use serde::{Deserialize, Serialize};
77

88
/// Model for Members used with List operations.
@@ -56,82 +56,17 @@ pub struct Member {
5656
pub forbid_timesheet_submission_when_below_capacity: bool,
5757
}
5858

59-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
60-
#[serde(rename_all = "camelCase")]
61-
pub struct SecurityRole {
62-
pub id: types::UUID,
63-
pub name: String,
64-
}
65-
66-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
67-
#[serde(rename_all = "camelCase")]
68-
pub struct JobTitle {
69-
pub id: types::UUID,
70-
pub name: String,
71-
}
72-
73-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
74-
#[serde(rename_all = "camelCase")]
75-
pub struct Discipline {
76-
pub id: types::UUID,
77-
pub name: String,
78-
}
79-
80-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
81-
#[serde(rename_all = "camelCase")]
82-
pub struct Practice {
83-
pub id: types::UUID,
84-
pub name: String,
85-
}
86-
87-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
88-
#[serde(rename_all = "camelCase")]
89-
pub struct Location {
90-
pub id: types::UUID,
91-
pub name: String,
92-
}
93-
94-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
95-
#[serde(rename_all = "camelCase")]
96-
pub struct Manager {
97-
pub id: types::UUID,
98-
pub name: String,
99-
}
100-
101-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
102-
#[serde(rename_all = "camelCase")]
103-
pub struct TimeOffApprover {
104-
pub id: types::UUID,
105-
pub name: String,
106-
}
107-
108-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
109-
#[serde(rename_all = "camelCase")]
110-
pub struct HolidaySchedule {
111-
pub id: types::UUID,
112-
pub name: String,
113-
}
114-
115-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
116-
#[serde(rename_all = "camelCase")]
117-
pub struct Tag {
118-
pub id: types::UUID,
119-
pub name: String,
120-
}
121-
122-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
123-
#[serde(rename_all = "camelCase")]
124-
pub struct Skill {
125-
pub id: types::UUID,
126-
pub name: String,
127-
}
128-
129-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
130-
#[serde(rename_all = "camelCase")]
131-
pub struct TimeOffType {
132-
pub id: types::UUID,
133-
pub name: String,
134-
}
59+
pub type SecurityRole = shared::Entity;
60+
pub type JobTitle = shared::Entity;
61+
pub type Discipline = shared::Entity;
62+
pub type Practice = shared::Entity;
63+
pub type Location = shared::Entity;
64+
pub type Manager = shared::Entity;
65+
pub type TimeOffApprover = shared::Entity;
66+
pub type HolidaySchedule = shared::Entity;
67+
pub type Tag = shared::Entity;
68+
pub type Skill = shared::Entity;
69+
pub type TimeOffType = shared::Entity;
13570

13671
#[derive(PartialEq, Deserialize, Serialize, Debug)]
13772
#[serde(rename_all = "camelCase")]

src/model/project.rs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -62,40 +62,11 @@ pub struct Project {
6262
pub monthly_budget: Option<MonthlyBudget>,
6363
}
6464

65-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
66-
#[serde(rename_all = "camelCase")]
67-
pub struct Practice {
68-
pub id: types::UUID,
69-
pub name: String,
70-
}
71-
72-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
73-
#[serde(rename_all = "camelCase")]
74-
pub struct ProjectType {
75-
pub id: types::UUID,
76-
pub name: String,
77-
}
78-
79-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
80-
#[serde(rename_all = "camelCase")]
81-
pub struct Tag {
82-
pub id: types::UUID,
83-
pub name: String,
84-
}
85-
86-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
87-
#[serde(rename_all = "camelCase")]
88-
pub struct SalesRepresentative {
89-
pub id: types::UUID,
90-
pub name: String,
91-
}
92-
93-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
94-
#[serde(rename_all = "camelCase")]
95-
pub struct BusinessUnit {
96-
pub id: types::UUID,
97-
pub name: String,
98-
}
65+
pub type Practice = shared::Entity;
66+
pub type ProjectType = shared::Entity;
67+
pub type Tag = shared::Entity;
68+
pub type SalesRepresentative = shared::Entity;
69+
pub type BusinessUnit = shared::Entity;
9970

10071
#[derive(PartialEq, Deserialize, Serialize, Debug)]
10172
#[serde(rename_all = "camelCase")]

src/model/time.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,9 @@ pub struct TimeEntry {
3939
pub invoice: Option<Invoice>,
4040
}
4141

42-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
43-
#[serde(rename_all = "camelCase")]
44-
pub struct Role {
45-
pub id: types::UUID,
46-
pub name: String,
47-
}
48-
49-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
50-
#[serde(rename_all = "camelCase")]
51-
pub struct Task {
52-
pub id: types::UUID,
53-
pub name: String,
54-
}
55-
56-
#[derive(PartialEq, Deserialize, Serialize, Debug)]
57-
#[serde(rename_all = "camelCase")]
58-
pub struct TimeOffType {
59-
pub id: types::UUID,
60-
pub name: String,
61-
}
42+
pub type Role = shared::Entity;
43+
pub type Task = shared::Entity;
44+
pub type TimeOffType = shared::Entity;
6245

6346
#[derive(PartialEq, Deserialize, Serialize, Debug)]
6447
#[serde(rename_all = "camelCase")]

src/model/utilization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Utilizations {
1919
pub struct Utilization {
2020
pub id: types::UUID,
2121
pub start: types::Date,
22-
pub target_percentage: i64,
22+
pub target_percentage: f64,
2323
pub created_at: types::Timestamp,
2424
pub is_default: bool,
2525
pub end: types::Date,

src/model/utilization/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn test_utilization_deserialize() {
1616
let utilization = Utilization {
1717
id: types::UUID(String::from("8e6d6316-5bc2-4135-b99c-f604f29051ab")),
1818
start: types::Date(String::from("2024-11-01")),
19-
target_percentage: 85,
19+
target_percentage: 85.0,
2020
created_at: types::Timestamp(String::from("2024-11-08T00:50:42.006Z")),
2121
is_default: false,
2222
end: types::Date(String::from("2025-10-31")),

0 commit comments

Comments
 (0)