Created
May 13, 2021 11:44
-
-
Save gordonturner/89ad05a8eb48c94fa75d0e66efe1a47a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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