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/update_price.rs (line 11)
10async fn main() -> Result<()> {
11 let config = SpapiConfig::from_env()?;
12 let client = SpapiClient::new(config.clone())?;
13
14 let seller_id = "YOUR_SELLER_ID";
15 let sku = "YOUR_SKU";
16 let marketplace_ids = vec!["ATVPDKIKX0DER".to_string()]; // Amazon US Marketplace ID
17 let new_price = 42.0; // New price to set
18
19 log::info!(
20 "Updating price for SKU: {} in marketplace: {:?}",
21 sku,
22 marketplace_ids
23 );
24 match update_listing_price(&client, seller_id, sku, &marketplace_ids, new_price).await {
25 Ok(response) => {
26 println!(
27 "Price update request submitted successfully! {:#?}",
28 response
29 );
30 println!("Submission ID: {}", response.submission_id);
31 if let Some(issues) = response.issues {
32 if !issues.is_empty() {
33 println!("Issues found:");
34 for issue in issues {
35 println!(" - {}: {}", issue.code, issue.message);
36 }
37 }
38 }
39 }
40 Err(e) => {
41 eprintln!("Failed to update price: {}", e);
42 }
43 }
44
45 let item = get_current_listing(&client, seller_id, sku, &marketplace_ids).await?;
46 println!("Current listing information: {:#?}", item);
47
48 Ok(())
49}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