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
use IndexMap;
use ;
/// Supported export formats for Vtiger data.
///
/// Each format has different characteristics:
/// - JSON creates a single file with all records in an array
/// - JSON Lines creates one JSON object per line (streaming-friendly)
/// - CSV creates a traditional spreadsheet format with headers
///
/// # Examples
///
/// ```no_run
/// use vtiger_client::ExportFormat;
///
/// let formats = vec![
/// ExportFormat::Json,
/// ExportFormat::JsonLines,
/// ExportFormat::CSV,
/// ];
/// ```
/// Response wrapper for all Vtiger REST API calls.
///
/// This struct represents the standard response format returned by the Vtiger API.
/// All API responses follow this structure, containing a success flag, optional result data,
/// and optional error information.
///
/// # Fields
///
/// * `success` - Indicates whether the API call was successful
/// * `result` - Contains the response data when the call succeeds
/// * `error` - Contains error details when the call fails
///
/// # Examples
///
/// ```no_run
/// use vtiger_client::{ApiError, VtigerResponse};
/// use indexmap::IndexMap;
///
/// // Successful response
/// let success_response = VtigerResponse {
/// success: true,
/// result: Some(IndexMap::new()),
/// error: None,
/// };
///
/// // Error response
/// let error_response = VtigerResponse {
/// success: false,
/// result: None,
/// error: Some(ApiError {
/// code: "404".to_string(),
/// message: "Not Found".to_string(),
/// }),
/// };
/// ```
/// Response format for Vtiger query operations that return multiple records.
///
/// This struct is used specifically for API calls that return arrays of data,
/// such as `SELECT` queries or list operations. It follows the same success/error
/// pattern as [`VtigerResponse`] but contains a vector of records instead of a single object.
///
/// # Examples
///
/// ```no_run
/// use indexmap::IndexMap;
/// use serde_json::json;
/// use vtiger_client::VtigerQueryResponse;
///
/// // Query response with multiple records
/// let response = VtigerQueryResponse {
/// success: true,
/// result: Some(vec![
/// IndexMap::from([("id".to_string(), json!("1"))]),
/// IndexMap::from([("id".to_string(), json!("2"))]),
/// ]),
/// error: None,
/// };
/// ```
/// Error information returned by the Vtiger API.
///
/// When an API call fails, the Vtiger API returns structured error information
/// containing both a code for programmatic handling and a human-readable message.
///
/// # Examples
///
/// ```no_run
/// use vtiger_client::ApiError;
/// let error = ApiError {
/// code: "AUTHENTICATION_FAILURE".to_string(),
/// message: "Invalid username or access key".to_string(),
/// };
/// ```