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
//! Response models for the OpenFIGI search endpoint.
//!
//! This module contains the data structures used to represent responses from the
//! [OpenFIGI search endpoint](https://www.openfigi.com/api/documentation#v3-post-search).
//! The search endpoint allows finding financial instruments using text-based queries
//! and returns either successful FIGI results with optional pagination or error responses.
//!
//! # Response Structure
//!
//! The search endpoint returns a [`SearchResponse`] which wraps either:
//! - [`SearchData`] containing successful FIGI results with optional pagination support
//! - Error information when the search query fails or produces no results
//!
//! # Examples
//!
//! ```rust
//! use openfigi_rs::model::response::SearchResponse;
//! use serde_json;
//!
//! // Successful search response with results
//! let json = r#"{
//! "data": [
//! {"figi": "BBG000BLNNH6", "ticker": "AAPL", "name": "Apple Inc"},
//! {"figi": "BBG000B9XRY4", "ticker": "TSLA", "name": "Tesla Inc"}
//! ],
//! "next": "pagination_token_here"
//! }"#;
//! let response: SearchResponse = serde_json::from_str(json).unwrap();
//! assert!(response.is_success());
//! assert_eq!(response.data().unwrap().len(), 2);
//! assert!(response.next_page().is_some());
//!
//! // Error response when search fails
//! let error_json = r#"{"error": "Invalid search query"}"#;
//! let error_response: SearchResponse = serde_json::from_str(error_json).unwrap();
//! assert!(error_response.is_error());
//! ```
//!
//! Note: This module is not intended for direct use by consumers of the OpenFIGI API.
use crate;
use ;
/// Response type for the OpenFIGI search endpoint (POST /v3/search).
///
/// This type alias represents the complete response from the search endpoint, which can
/// contain either successful search results or error information. The search endpoint
/// allows finding financial instruments using free-text queries and supports pagination
/// for large result sets.
///
/// # Response Format
///
/// Results are generally sorted by relevance to the search query.
///
/// Successful responses contain:
/// - An array of FIGI results matching the search criteria
/// - Optional pagination token for retrieving additional results
///
/// Error responses contain:
/// - A descriptive error message explaining why the search request failed
///
/// # Examples
///
/// ```rust
/// use openfigi_rs::model::response::SearchResponse;
/// use serde_json;
///
/// // Successful search with multiple results
/// let success_json = r#"{
/// "data": [
/// {
/// "figi": "BBG000BLNNH6",
/// "ticker": "AAPL",
/// "name": "Apple Inc",
/// "marketSector": "Equity"
/// },
/// {
/// "figi": "BBG000BVPV84",
/// "ticker": "AAPL",
/// "name": "Apple Inc",
/// "marketSector": "Equity"
/// }
/// ],
/// "next": "eyJwYWdlIjoxfQ=="
/// }"#;
/// let response: SearchResponse = serde_json::from_str(success_json).unwrap();
/// assert!(response.is_success());
/// assert_eq!(response.data().unwrap().len(), 2);
/// assert!(response.next_page().is_some());
///
/// // Empty search results
/// let empty_json = r#"{"data": []}"#;
/// let empty_response: SearchResponse = serde_json::from_str(empty_json).unwrap();
/// assert!(empty_response.is_success());
/// assert_eq!(empty_response.data().unwrap().len(), 0);
/// assert!(empty_response.next_page().is_none());
///
/// // Search error response
/// let error_json = r#"{"error": "Query too short"}"#;
/// let error_response: SearchResponse = serde_json::from_str(error_json).unwrap();
/// assert!(error_response.is_error());
/// assert_eq!(error_response.error(), Some("Query too short"));
/// ```
pub type SearchResponse = ;
/// Successful search result containing FIGI data and optional pagination information.
///
/// This structure represents the payload returned when a search query successfully
/// finds matching financial instruments. The search endpoint can return multiple
/// FIGI results for a single query, especially when the search term matches multiple
/// instruments or variations of the same instrument across different exchanges.
///
/// # Field Descriptions
///
/// - `data`: Array of FIGI results matching the search query, ordered by relevance
/// - `next`: Optional pagination token for retrieving additional search results
///
/// # Pagination
///
/// When the result set is large, the API may return only a subset of results along
/// with a `next` token. This token can be used in subsequent requests to retrieve
/// additional pages of results.