Skip to content

Commit

Permalink
created alternate methods for generating the sku spec associations
Browse files Browse the repository at this point in the history
  • Loading branch information
mvonbodun committed May 16, 2022
1 parent 161631d commit fcfc6d7
Show file tree
Hide file tree
Showing 8 changed files with 819 additions and 235 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions impex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ arg_enum! {
import,
genproductspecsfile,
genskuspecsfile,
genskuspecsfilealternate
}
}

Expand Down Expand Up @@ -131,6 +132,7 @@ arg_enum! {
enum SkuSpecAssocActions {
import,
genskuspecassocfile,
genskuspecassignfilealternate,
genskuspecassocfilealternate
}
}
Expand Down Expand Up @@ -807,7 +809,7 @@ impl Command {
command.product_file = m.value_of("PRODUCT_FILE").unwrap_or("").to_string();
command.sku_file = m.value_of("SKU_FILE").unwrap_or("").to_string();
command.concurrency = m.value_of("CONCURRENCY").unwrap_or("1").parse::<usize>().expect("CONCURRENCY must be a positive integer between 1 and 24. Default is 1 - Recommended");
command.rate_limit = m.value_of("RATE_LIMIT").unwrap_or("40").parse::<NonZeroU32>().expect("RATE_LIMIT must be a positive integer between 1 and 200. Default is 40 - Recommended");
command.rate_limit = m.value_of("RATE_LIMIT").unwrap_or("30").parse::<NonZeroU32>().expect("RATE_LIMIT must be a positive integer between 1 and 200. Default is 30 - Recommended");
}
("skufile", Some(m)) => {
command.object = "skufile".to_string();
Expand Down Expand Up @@ -894,7 +896,7 @@ pub async fn run() -> Result<(), Box<dyn Error>> {
header::HeaderValue::from_str(&vtex_api_apptoken)?,
);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(3))
.timeout(Duration::from_secs(12))
.default_headers(headers)
.build()?;

Expand Down Expand Up @@ -981,6 +983,16 @@ pub async fn run() -> Result<(), Box<dyn Error>> {
cmd.product_file,
)
.await?;
} else if cmd.action.eq("genskuspecsfilealternate") {
specifications::gen_sku_specifications_file_alternate(
cmd.input_file.to_string(),
&client,
account_name,
environment,
cmd.sku_spec_allowed_values_file,
cmd.product_file,
)
.await?;
}
} else if cmd.object.eq("specificationvalue") {
if cmd.action.eq("import") {
Expand Down Expand Up @@ -1107,7 +1119,7 @@ pub async fn run() -> Result<(), Box<dyn Error>> {
cmd.sku_file,
)
.await?;
} else if cmd.action.eq("genskuspecassocfilealternate") {
} else if cmd.action.eq("genskuspecassignfilealternate") {
skuspecassociation::gen_sku_spec_assign_file_alternate(
cmd.input_file,
&client,
Expand All @@ -1118,6 +1130,17 @@ pub async fn run() -> Result<(), Box<dyn Error>> {
cmd.sku_file,
)
.await?
} else if cmd.action.eq("genskuspecassocfilealternate") {
skuspecassociation::gen_sku_spec_association_file_alternate(
cmd.input_file,
&client,
account_name,
environment,
cmd.sku_spec_assign_file,
cmd.product_file,
cmd.sku_file,
)
.await?
}
} else if cmd.object.eq("skufile") {
// Load sku files
Expand Down
3 changes: 2 additions & 1 deletion impex/src/productspecassociation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ pub async fn gen_product_spec_association_file(
debug!("field_id_lookup: {:?}", field_id_lookup.len());

// Get a lookup HashMap for the parent category of a product
let product_parent_category_lookup = utils::create_product_parent_category_lookup(product_file);
let product_parent_category_lookup =
utils::create_product_parent_category_lookup(&product_file);
debug!(
"product_parent_category_lookkup: {:?}",
product_parent_category_lookup.len()
Expand Down
Loading

0 comments on commit fcfc6d7

Please sign in to comment.