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
//! Gateway API types and functionality for Deezer's web services.
//!
//! This module provides type-safe interfaces to Deezer's gateway API endpoints,
//! handling:
//! * Authentication tokens ([`arl`])
//! * User data and settings ([`user_data`])
//! * Content listings ([`list_data`])
//! * Radio stations ([`user_radio`])
//!
//! # Number Handling
//!
//! All numeric values are stored as 64-bit integers because the JSON protocol
//! doesn't distinguish between number sizes. This ensures safe handling of all
//! possible values from the API.
//!
//! # Response Types
//!
//! The API returns two types of responses:
//! * Paginated lists ([`Response::Paginated`])
//! * Simple results ([`Response::Unpaginated`])
//!
//! # Example
//!
//! ```rust
//! use deezer::gateway::{Response, UserData};
//!
//! // Parse a user data response
//! let response: Response<UserData> = serde_json::from_str(json)?;
//!
//! // Access the first result
//! if let Some(user) = response.first() {
//! println!("User: {}", user.name);
//! }
//! ```
pub use Arl;
pub use ;
pub use ;
pub use UserRadio;
use ;
use Deserialize;
use serde_as;
/// Defines a gateway API method identifier.
///
/// Each type implementing this trait represents a specific Deezer gateway API
/// endpoint, identified by a method name string.
///
/// # Examples
///
/// ```rust
/// use deezer::gateway::{Method, Arl};
///
/// // ARL endpoint
/// assert_eq!(Arl::METHOD, "user.getArl");
///
/// // Generic function using method name
/// fn call_api<T: Method>(params: &str) {
/// println!("Calling {}: {}", T::METHOD, params);
/// }
/// ```
/// Response from a Deezer gateway API endpoint.
///
/// Responses can be either paginated (with total counts and filtered results)
/// or unpaginated (direct result lists). Both formats include an error map
/// for API status information.
///
/// # Response Formats
///
/// Paginated format:
/// ```json
/// {
/// "error": {},
/// "results": {
/// "data": [...],
/// "count": 10,
/// "total": 100,
/// "filtered_count": 10
/// }
/// }
/// ```
///
/// Unpaginated format:
/// ```json
/// {
/// "error": {},
/// "results": [...] // Direct array or single item
/// }
/// ```
///
/// # Examples
///
/// ```rust
/// use deezer::gateway::Response;
///
/// // Working with paginated data
/// let response: Response<Track> = serde_json::from_str(json)?;
/// if let Some(first_track) = response.first() {
/// println!("First track: {}", first_track.title);
/// }
///
/// // Getting all results regardless of pagination
/// for item in response.all() {
/// println!("Item: {:?}", item);
/// }
/// ```
/// Paginated result set from the Deezer gateway API.
///
/// Contains both the actual data items and metadata about the total
/// number of available items and filtering.
///
/// # Example Response
///
/// ```json
/// {
/// "data": [...], // Actual items
/// "count": 10, // Items in this page
/// "total": 100, // Total available items
/// "filtered_count": 10 // Items matching filters
/// }
/// ```
/// String value that defaults to "UNKNOWN" when parsing fails.
///
/// Used for API fields that might return unexpected or invalid values,
/// ensuring robust handling of responses while maintaining type safety.
///
/// # Examples
///
/// ```rust
/// use deezer::gateway::StringOrUnknown;
///
/// // Normal string
/// let value: StringOrUnknown = "value".parse()?;
/// assert_eq!(&*value, "value");
///
/// // Default value
/// let unknown = StringOrUnknown::default();
/// assert_eq!(&*unknown, "UNKNOWN");
/// ```
///
/// # Deref Behavior
///
/// Derefs to `String` for convenient access to string methods:
/// ```rust
/// use deezer::gateway::StringOrUnknown;
///
/// let value = StringOrUnknown::default();
/// assert_eq!(value.to_uppercase(), "UNKNOWN");
/// ```
;