1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
//! # Kintone Data Models
//!
//! This module provides data structures for representing Kintone records, fields, and other entities.
//! These models handle serialization/deserialization between Rust types and Kintone's JSON API format.
//!
//! ## Usage Examples
//!
//! ### Creating a Record
//! ```rust
//! use kintone::model::record::{Record, FieldValue};
//!
//! let mut record = Record::new();
//! record.put_field("name", FieldValue::SingleLineText("John Doe".to_owned()));
//! record.put_field("age", FieldValue::Number(Some(30.into())));
//! println!("record = {record:?}");
//! ```
//!
//! ### Reading Field Values
//! ```rust
//! # use kintone::model::record::{Record, FieldValue};
//! # let record = Record::new();
//! if let Some(FieldValue::SingleLineText(name)) = record.get("name") {
//! println!("Name: {}", name);
//! }
//! if let Some(FieldValue::Number(age)) = record.get("age") {
//! println!("Age: {:?}", age);
//! }
//! ```
use crateoption_stringified;
use ;
/// Represents the type of entity in Kintone's user management system.
///
/// Kintone supports three types of entities for access control and assignment:
/// users, groups, and organizations. This enum is used throughout the API
/// to specify which type of entity is being referenced.
///
/// # Examples
///
/// ```rust
/// use kintone::model::EntityType;
///
/// let user_type = EntityType::USER;
/// let group_type = EntityType::GROUP;
/// let org_type = EntityType::ORGANIZATION;
/// ```
/// Represents a generic entity in Kintone's user management system.
///
/// An entity can be a user, group, or organization, identified by its type and code.
/// This structure is commonly used in permission settings, assignee specifications,
/// and other contexts where you need to reference a Kintone entity.
///
/// # Fields
///
/// * `entity_type` - The type of entity (USER, GROUP, or ORGANIZATION)
/// * `code` - The unique identifier code for the entity
///
/// # Examples
///
/// ```rust
/// use kintone::model::{Entity, EntityType};
///
/// // Create a user entity
/// let user_entity = Entity {
/// entity_type: EntityType::USER,
/// code: "john.doe".to_owned(),
/// };
///
/// // Create a group entity
/// let group_entity = Entity {
/// entity_type: EntityType::GROUP,
/// code: "development-team".to_owned(),
/// };
/// ```
/// Represents a user in the Kintone system.
///
/// This structure contains basic information about a Kintone user, including
/// their display name and unique code. Users can be assigned to records,
/// added to groups, and given various permissions within Kintone apps.
///
/// # Fields
///
/// * `name` - The display name of the user
/// * `code` - The unique identifier code for the user (typically their login name)
///
/// # Examples
///
/// ```rust
/// use kintone::model::User;
///
/// let user = User {
/// name: "John Doe".to_owned(),
/// code: "john.doe".to_owned(),
/// };
///
/// println!("User: {} ({})", user.name, user.code);
/// ```
/// Represents a group in the Kintone system.
///
/// Groups are collections of users that can be managed together for permissions,
/// assignments, and notifications. Groups help organize users and simplify
/// access control management in Kintone applications.
///
/// # Fields
///
/// * `name` - The display name of the group
/// * `code` - The unique identifier code for the group
///
/// # Examples
///
/// ```rust
/// use kintone::model::Group;
///
/// let group = Group {
/// name: "Development Team".to_owned(),
/// code: "dev-team".to_owned(),
/// };
///
/// println!("Group: {} ({})", group.name, group.code);
/// ```
/// Represents an organizational unit in the Kintone system.
///
/// Organizations represent hierarchical structures within your company or entity.
/// They can be used for access control, workflow routing, and organizational
/// reporting within Kintone applications.
///
/// # Fields
///
/// * `name` - The display name of the organization
/// * `code` - The unique identifier code for the organization
///
/// # Examples
///
/// ```rust
/// use kintone::model::Organization;
///
/// let org = Organization {
/// name: "Engineering Division".to_owned(),
/// code: "eng-div".to_owned(),
/// };
///
/// println!("Organization: {} ({})", org.name, org.code);
/// ```
/// Represents metadata for a file stored in Kintone.
///
/// This structure contains information about files that have been uploaded to Kintone,
/// including their content type, unique file key, original filename, and size.
/// File bodies are typically used in attachment fields and file upload operations.
///
/// # Fields
///
/// * `file_key` - The unique identifier for the file in Kintone's storage system.
/// When you writing a record, only this field is required.
/// * `content_type` - The MIME type of the file (e.g., "image/jpeg", "application/pdf")
/// * `name` - The original filename when the file was uploaded
/// * `size` - The file size in bytes
///
/// # Examples
///
/// Using the builder pattern (recommended):
/// ```rust
/// use kintone::model::file_body;
///
/// let file_key = "abc123def456";
/// let file = file_body(file_key).build();
/// ```
///
/// Using direct struct initialization:
/// ```rust
/// use kintone::model::FileBody;
///
/// let file = FileBody {
/// file_key: "abc123def456".to_owned(),
/// content_type: Some("image/jpeg".to_owned()),
/// name: Some("photo.jpg".to_owned()),
/// size: Some(1024),
/// };
/// ```
/// Creates a new file body builder.
///
/// # Arguments
/// * `file_key` - The unique identifier for the file in Kintone's storage system
///
/// # Examples
/// ```rust
/// use kintone::model::file_body;
///
/// let file = file_body("abc123def456")
/// .content_type("image/jpeg")
/// .name("photo.jpg")
/// .size(1024)
/// .build();
/// ```
/// Builder for creating [`FileBody`].
/// Represents the sort order for query results.
///
/// This enum is used to specify whether records should be sorted in ascending
/// or descending order when querying Kintone records. It's commonly used in
/// record retrieval operations and other sorted data requests.
///
/// # Variants
///
/// * `Asc` - Ascending order (A-Z, 0-9, oldest to newest)
/// * `Desc` - Descending order (Z-A, 9-0, newest to oldest)
///
/// # Examples
///
/// ```rust
/// use kintone::model::Order;
///
/// let ascending = Order::Asc;
/// let descending = Order::Desc;
///
/// // The Display trait converts to lowercase string representation
/// assert_eq!(ascending.to_string(), "asc");
/// assert_eq!(descending.to_string(), "desc");
/// ```