use chrono::{DateTime, Utc};
use client::{Client, Method};
mod types;
pub use self::types::{
Condition, InventorySupply, InventorySupplyDetail, SupplyType, Timepoint, TimepointType,
};
use result::MwsResult;
static PATH: &'static str = "/FulfillmentInventory/2010-10-01";
static VERSION: &'static str = "2010-10-01";
#[derive(Debug, Serialize, SerializeMwsParams)]
pub enum ResponseGroup {
Basic,
Detailed,
}
#[allow(non_snake_case)]
#[derive(Debug, Default, Serialize, SerializeMwsParams)]
pub struct ListInventorySupplyParameters {
pub SellerSkus: Option<Vec<String>>,
pub QueryStartDateTime: Option<DateTime<Utc>>,
pub ResponseGroup: Option<ResponseGroup>,
pub MarketplaceId: Option<String>,
}
#[allow(non_snake_case)]
#[derive(Debug, Default, Serialize, FromXmlStream)]
pub struct ListInventorySupplyResponse {
pub MarketplaceId: String,
pub InventorySupplyList: Vec<InventorySupply>,
pub NextToken: Option<String>,
}
response_envelope_type!(
ListInventorySupplyResponseEnvelope<ListInventorySupplyResponse>,
"ListInventorySupplyResponse",
"ListInventorySupplyResult"
);
response_envelope_type!(
ListInventorySupplyByNextTokenResponseEnvelope<ListInventorySupplyResponse>,
"ListInventorySupplyByNextTokenResponse",
"ListInventorySupplyByNextTokenResult"
);
#[allow(non_snake_case)]
pub fn ListInventorySupply(
client: &Client,
parameters: ListInventorySupplyParameters,
) -> MwsResult<ListInventorySupplyResponse> {
client
.request_xml(
Method::Post,
PATH,
VERSION,
"ListInventorySupply",
parameters,
).map(|e: ListInventorySupplyResponseEnvelope| e.into_inner())
.map_err(|err| err.into())
}
#[allow(non_snake_case)]
pub fn ListInventorySupplyByNextToken(
client: &Client,
next_token: String,
) -> MwsResult<ListInventorySupplyResponse> {
let params = vec![("NextToken".to_string(), next_token)];
client
.request_xml(
Method::Post,
PATH,
VERSION,
"ListInventorySupplyByNextToken",
params,
).map(|e: ListInventorySupplyByNextTokenResponseEnvelope| e.into_inner())
.map_err(|err| err.into())
}