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
//! # 🚀 Getting started
//!
//! ### Search Releases
//!
//! ```
//! use kodik_api::Client;
//! use kodik_api::search::SearchQuery;
//!
//! #[tokio::main]
//! async fn main() {
//!     let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
//!
//!     let client = Client::new(api_key);
//!
//!     let search_response = SearchQuery::new()
//!         .with_title("Cyberpunk: Edgerunners")
//!         .with_limit(1)
//!         .execute(&client)
//!         .await
//!         .unwrap();
//!
//!     println!("search response = {search_response:#?}");
//! }
//! ```
//!
//! ### List Releases
//!
//! ```
//! use futures_util::{pin_mut, StreamExt};
//!
//! use kodik_api::Client;
//! use kodik_api::list::ListQuery;
//! use kodik_api::types::ReleaseType;
//!
//! #[tokio::main]
//! async fn main() {
//!     let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
//!
//!     let client = Client::new(api_key);
//!
//!     let stream = ListQuery::new()
//!         .with_limit(100)
//!         .with_types(&[ReleaseType::Anime, ReleaseType::AnimeSerial])
//!         .stream(&client);
//!
//!     pin_mut!(stream);
//!
//!     while let Some(response) = stream.next().await {
//!         match response {
//!             Ok(response) => {
//!                 dbg!(response.total);
//!                 dbg!(response.results);
//!             }
//!             Err(err) => {
//!                 match err {
//!                     // Kodik error
//!                     kodik_api::error::Error::KodikError(message) => {
//!                         panic!("kodik error = {}", message);
//!                     }
//!                     // Reqwest error
//!                     kodik_api::error::Error::HttpError(_err) => {
//!                         // Another try
//!                         continue;
//!                     }
//!                     _ => {
//!                         panic!("Unknown error")
//!                     }
//!                 }
//!             }
//!         }
//!     }
//! }
//! ```
//!
//! ### List Translations
//!
//! ```
//! use kodik_api::Client;
//! use kodik_api::translations::TranslationQuery;
//!
//! #[tokio::main]
//! async fn main() {
//!     let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
//!
//!     let client = Client::new(api_key);
//!
//!     let translations_response = TranslationQuery::new()
//!         .execute(&client)
//!         .await
//!         .unwrap();
//!
//!     println!("translations response = {translations_response:#?}");
//! }
//! ```
//!
//! ### List Genres
//!
//! ```
//! use kodik_api::Client;
//! use kodik_api::genres::GenreQuery;
//!
//! #[tokio::main]
//! async fn main() {
//!     let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
//!
//!     let client = Client::new(api_key);
//!
//!     let genres_response = GenreQuery::new()
//!         .execute(&client)
//!         .await
//!         .unwrap();
//!
//!     println!("genres response = {genres_response:#?}");
//! }
//! ```
//!
//! ### List Countries
//!
//! ```
//! use kodik_api::Client;
//! use kodik_api::countries::CountryQuery;
//!
//! #[tokio::main]
//! async fn main() {
//!     let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
//!
//!     let client = Client::new(api_key);
//!
//!     let countries_response = CountryQuery::new()
//!         .execute(&client)
//!         .await
//!         .unwrap();
//!
//!     println!("countries response = {countries_response:#?}");
//! }
//! ```
//!
//! ### List Years
//!
//! ```
//! use kodik_api::Client;
//! use kodik_api::years::YearQuery;
//!
//! #[tokio::main]
//! async fn main() {
//!     let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
//!
//!     let client = Client::new(api_key);
//!
//!     let years_response = YearQuery::new()
//!         .execute(&client)
//!         .await
//!         .unwrap();
//!
//!     println!("years response = {years_response:#?}");
//! }
//! ```
//!
//! ### List Qualities
//!
//! ```
//! use kodik_api::Client;
//! use kodik_api::qualities::QualityQuery;
//!
//! #[tokio::main]
//! async fn main() {
//!     let api_key = std::env::var("KODIK_API_KEY").expect("KODIK_API_KEY is not set");
//!
//!     let client = Client::new(api_key);
//!
//!     let qualities_response = QualityQuery::new()
//!         .execute(&client)
//!         .await
//!         .unwrap();
//!
//!     println!("qualities response = {qualities_response:#?}");
//! }
//! ```

/// Module containing the [`client::Client`] struct.
pub mod client;

/// Module containing the [`errors::Error`] struct.
pub mod error;

/// Module representing the [search releases] structures.
pub mod search;

/// Module representing the [list releases] structures.
pub mod list;

/// Module representing the [list translations] structures.
pub mod translations;

/// Module representing the [list years] structures.
pub mod years;

/// Module representing the [list countries] structures.
pub mod countries;

/// Module representing the [list genres] structures.
pub mod genres;

/// Module representing the [list qualities] structures.
pub mod qualities;

/// Module representing the [types] structures.
pub mod types;

/// The module contains structures for unifying the API seasons response.
pub mod unify_seasons;

pub use client::*;

mod util;