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
//! Generic provider trait for multi-provider integrations
use async_trait;
use crate::;
/// Generic provider trait for integrating multiple external providers
///
/// This trait defines the interface that all provider implementations must follow,
/// enabling services to integrate with multiple external sources through a consistent API.
///
/// ## Type Parameters
///
/// - `Item`: The type of items returned by this provider (e.g., Product, Payment, Shipment)
/// - `Filter`: Domain-specific filter criteria for fetching items
/// - `Pagination`: Pagination parameters for the provider's API
///
/// ## Example
///
/// ```rust
/// use pleme_providers::{Provider, ProviderCapabilities, ProviderError, ProviderBatch};
/// use async_trait::async_trait;
///
/// #[derive(Clone)]
/// struct Product { id: String, name: String }
///
/// #[derive(Default)]
/// struct ProductFilter { category: Option<String> }
///
/// #[derive(Default)]
/// struct ProductPagination { page: i32, per_page: i32 }
///
/// struct MyProvider;
///
/// #[async_trait]
/// impl Provider for MyProvider {
/// type Item = Product;
/// type Filter = ProductFilter;
/// type Pagination = ProductPagination;
///
/// fn provider_id(&self) -> &str { "my-provider" }
/// fn provider_name(&self) -> &str { "My Provider" }
/// fn capabilities(&self) -> ProviderCapabilities { ProviderCapabilities::default() }
///
/// async fn fetch_items(
/// &self,
/// _filter: Self::Filter,
/// _pagination: Self::Pagination,
/// ) -> Result<ProviderBatch<Self::Item>, ProviderError> {
/// // Implement provider-specific logic
/// Ok(ProviderBatch {
/// items: vec![],
/// total_count: 0,
/// has_next_page: false,
/// next_page_token: None,
/// })
/// }
///
/// async fn validate_credentials(&self) -> Result<(), ProviderError> {
/// Ok(())
/// }
/// }
/// ```