pub struct SpapiConfig {
pub client_id: String,
pub client_secret: String,
pub refresh_token: String,
pub marketplace_id: String,
pub region: String,
pub sandbox: bool,
pub user_agent: Option<String>,
pub timeout_sec: Option<u64>,
}Fields§
§client_id: String§client_secret: String§refresh_token: String§marketplace_id: String§region: String§sandbox: bool§user_agent: Option<String>§timeout_sec: Option<u64>Implementations§
Source§impl SpapiConfig
impl SpapiConfig
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Examples found in repository?
More examples
examples/sellers_v1_use_raw_api.rs (line 7)
6async fn main() -> Result<()> {
7 let spapi_config = SpapiConfig::from_env()?;
8 let client = SpapiClient::new(spapi_config.clone())?;
9 let configuration = client.create_configuration().await?;
10 client
11 .limiter()
12 .wait_for_token("get_marketplace_participations", 0.016, 15)
13 .await?;
14 let res = get_marketplace_participations(&configuration).await;
15 client.limiter()
16 .record_response("get_marketplace_participations")
17 .await?;
18 println!("Marketplace Participations: {:#?}", res);
19 Ok(())
20}examples/pricing_v0.rs (line 6)
5async fn main() -> Result<()> {
6 let client = SpapiClient::new(SpapiConfig::from_env()?)?;
7
8 // let res = client
9 // .get_item_offers(client.get_marketplace_id(), "B0DGJC52FP", "New", None)
10 // .await?;
11 // println!("Item offers: {:?}", res);
12
13 let res = client
14 .get_item_offers_batch_by_asins(vec!["B0DGJC52FP", "B0BN72FYFG"])
15 .await?;
16 println!("Batch item offers: {:?}", res);
17
18 // let res = client
19 // .get_listing_offers_batch_by_skus(vec!["YOU_SKU1", "YOU_SKU2"])
20 // .await?;
21 // println!("Batch listing offers: {:?}", res);
22
23
24 Ok(())
25}examples/reports.rs (line 182)
179async fn main() -> Result<()> {
180 env_logger::init();
181
182 let spapi_config = SpapiConfig::from_env()?;
183 let client = SpapiClient::new(spapi_config.clone())?;
184 let marketplace_ids = vec!["ATVPDKIKX0DER".to_string()]; // Amazon US Marketplace ID
185
186 // create report specification
187 let report_type = "GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT";
188 let report_content = client
189 .fetch_report(
190 report_type,
191 marketplace_ids.clone(),
192 None,
193 Some(|attempt, status| {
194 println!("Attempt get report {}: {:?}", attempt, status);
195 }),
196 )
197 .await?;
198
199 // save report content to a file
200 let report_file_path = "/tmp/restock_inventory_report.txt";
201 std::fs::write(report_file_path, &report_content)
202 .expect("Unable to write report content to file");
203
204 // // load report content from the file
205 // let report_file_path = "/tmp/restock_inventory_report.txt";
206 // let report_content =
207 // std::fs::read_to_string(report_file_path).expect("Unable to read report content from file");
208
209 let restocks = parse_restock_report(&report_content);
210
211 println!("Restock inventory report generated successfully.");
212 println!("{:#?}", restocks);
213
214 Ok(())
215}Additional examples can be found in:
Trait Implementations§
Source§impl Clone for SpapiConfig
impl Clone for SpapiConfig
Source§fn clone(&self) -> SpapiConfig
fn clone(&self) -> SpapiConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SpapiConfig
impl Debug for SpapiConfig
Source§impl<'de> Deserialize<'de> for SpapiConfig
impl<'de> Deserialize<'de> for SpapiConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SpapiConfig
impl RefUnwindSafe for SpapiConfig
impl Send for SpapiConfig
impl Sync for SpapiConfig
impl Unpin for SpapiConfig
impl UnwindSafe for SpapiConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more