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
//! # GLEIF API Client Library ([`gleif_rs`](crate))
//!
//! This Rust library provides a type-safe, ergonomic client for interacting with the [Global Legal Entity Identifier Foundation (GLEIF) API](https://www.gleif.org/en/lei-data/gleif-api).
//! Whether you're retrieving LEI records, filtering data, or managing API responses, this library ensures seamless integration with strong typing and clear error handling.
//!
//! ## Features
//!
//! - **Simple API Requests:** Easily fetch and filter LEI records via the fluent interface ([`crate::client::GleifClient::lei_records`]).
//! - **Type-Safe Fields & Values:** Use enums like [`crate::field::Field`] and [`crate::value::EntityCategory`] to avoid typos and invalid values.
//! - **Comprehensive Error Handling:** Centralized error management via [`crate::error::GleifError`].
//! - **Customizable Requests:** Build and refine API queries with [`crate::request_builder::GleifRequestBuilder`].
//! - **Extensible HTTP Client:** Bring your own [`reqwest::Client`] or use middleware for retries, logging, and more.
//!
//! ## Getting Started
//!
//! Run the following Cargo command in your project directory:
//!
//! ```shell
//! cargo add gleif-rs
//! ```
//!
//! ### Basic Example: Fetching an LEI Record
//!
//! The following example demonstrates how to fetch a specific LEI record using its ID.
//!
//! ```rust
//! use gleif_rs::{
//! client::GleifClient,
//! error::GleifError,
//! model::LeiRecord,
//! };
//!
//! #[tokio::main]
//! async fn main() -> Result<(), GleifError> {
//! // Initialize the GLEIF client
//! let client = GleifClient::new();
//! // Fetch a specific LEI record by its ID
//! let lei_record: LeiRecord = client.lei_record_by_id("5493001KJTIIGC8Y1R12").await?;
//!
//! println!("LEI Record: {lei_record:#?}");
//! Ok(())
//! }
//! ```
//!
//! ### Filtering LEI Records
//!
//! You can refine your API queries using filters:
//!
//! ```rust
//! use gleif_rs::{
//! client::GleifClient,
//! error::GleifError,
//! field::Field,
//! model::LeiRecordList,
//! value::{EntityCategory, RegistrationStatus},
//! };
//!
//! #[tokio::main]
//! async fn main() -> Result<(), GleifError> {
//! // Initialize the GLEIF client
//! let client = GleifClient::new();
//! // Fetch LEI records with specific filters
//! let lei_records: LeiRecordList = client
//! .lei_records()
//! .filter_eq(Field::EntityCategory, EntityCategory::Fund)
//! .filter_eq(Field::RegistrationStatus, RegistrationStatus::Issued)
//! .sort(Field::EntityLegalName)
//! .page_size(10)
//! .send()
//! .await?;
//!
//! println!("Found {} matching records.", lei_records.data.len());
//! Ok(())
//! }
//! ```
//!
//! ### Advanced Configuration: Custom HTTP Client
//!
//! For greater control over API requests, such as retry policies and timeouts,
//! you can customize the underlying HTTP client:
//!
//! ```rust
//! use gleif_rs::client::GleifClient;
//! use reqwest::Client as ReqwestClient;
//! use reqwest_middleware::ClientBuilder;
//! use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff};
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() {
//! let reqwest_client = ReqwestClient::builder()
//! .timeout(Duration::from_secs(30))
//! .connect_timeout(Duration::from_secs(5))
//! .build()
//! .expect("Failed to create reqwest client");
//! let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3);
//! let middleware = ClientBuilder::new(reqwest_client)
//! .with(RetryTransientMiddleware::new_with_policy(retry_policy))
//! .build();
//! let client = GleifClient::from_middleware_client(middleware);
//! println!("GLEIF client initialized with custom middleware: {}", client.base_url());
//! }
//! ```
//!
//! ## Error Handling
//!
//! All API methods return [`crate::error::Result`]. See the [`crate::error`] module for details.
//!
//! ## License
//!
//! This project is licensed under the MIT License. See [LICENSE](https://github.com/gleif-rs/gleif-rs/blob/main/LICENSE) for details.
//!
//! ---
//!
//! Feel free to explore and extend its capabilities based on your needs!
/// Library version
pub const VERSION: &str = env!;
/// The default base URL for the GLEIF API v1.
pub const DEFAULT_BASE_URL: &str = "https://api.gleif.org/api/v1/";