Skip to content

Instantly share code, notes, and snippets.

@gordonturner
Created May 13, 2021 11:44
Show Gist options
  • Save gordonturner/89ad05a8eb48c94fa75d0e66efe1a47a to your computer and use it in GitHub Desktop.
Save gordonturner/89ad05a8eb48c94fa75d0e66efe1a47a to your computer and use it in GitHub Desktop.
/**
* @param model
* @return
*/
@PreAuthorize("ROLE_USER")
@RequestMapping(value = "/secure/etsy-receipts.html", method = RequestMethod.GET)
public ModelAndView handleSecureEtsyReceiptsGetRequest(ModelMap model) {
logger.debug("Called handleSecureEtsyReceiptsGetRequest");
// Get the first EtsyShop, which should be our primary shop, not supporting multiple shops RN.
EtsyShop etsyShop = etsyService.getEtsyShopReceiptsAndTransactions("XXXXXXXXX");
// Parse through to get the open orders, things that have not been shipped.
ArrayList<EtsyReceipt> notShippedEtsyReceipts = new ArrayList<>();
for ( EtsyReceipt etsyReceipt : etsyShop.getReceipts() ) {
if( etsyReceipt.getShipped() ){
logger.info("Found not shipped receipt: " + etsyReceipt.getReceiptId() + " " + etsyReceipt.getName() );
notShippedEtsyReceipts.add( etsyReceipt );
}
}
logger.info("Found " + notShippedEtsyReceipts.size() + " not shipped receipts (orders).");
// Based on the open receipts, get the associated transactions.
List<EtsyTransaction> allEtsyTransactions = etsyShop.getTransactions();
for(EtsyReceipt pendingEtsyReceipt : notShippedEtsyReceipts){
logger.info("Finding transactions for receipt id: " + pendingEtsyReceipt.getReceiptId() );
for( EtsyTransaction etsyTransaction: allEtsyTransactions) {
if( pendingEtsyReceipt.getReceiptId().equals(etsyTransaction.getReceiptId() ) ) {
logger.info("Found the transaction for not shipped receipt: " + pendingEtsyReceipt.getReceiptId() +
" quantity: " +
etsyTransaction.getQuantity() +
" title: " + etsyTransaction.getTitle());
for(EtsyPropertyValue etsyPropertyValues : etsyTransaction.getListingProduct().getPropertyValues()){
logger.info("Variation: " + etsyPropertyValues.getPropertyName() + " " + etsyPropertyValues.getValues() );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment