-
Obsolete and apparently broken
12/02/2020 at 07:53 • 0 commentsI went to use this yesterday and it came up blank. No time to dig into it I went to the website to dowload the whole list the edit out the shipped stuff. To my pleasant surprise Tindie have added a selection dialog to the download function including the ability to download just unshipped stuff.
So this project has served its purpose and is now dead.
-
Error handling is wrong
02/19/2019 at 21:01 • 0 commentsNo orders comes out with headers but no orders.
If there is an error it says "No orders". I need to update it to display the actual error.
-
initial code
02/16/2019 at 05:56 • 0 comments/* Pull unshipped orders from Tindie API Because the website doesn't offer it, and Endicia will make duplicates Copyright 2019 Alastair Young Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function onOpen(e) { var sheet = SpreadsheetApp.getActiveSpreadsheet(); sheet.getSheetByName("Data").clear(); var url = 'https://www.tindie.com/api/v1/order/?format=json&shipped=false'; var username = sheet.getRange("Settings!B1").getValue() var apikey = sheet.getRange("Settings!B2").getValue() var options = { 'muteHttpExceptions': true, 'headers' : { "Authorization":"ApiKey " + username + ":" + apikey } }; var response = UrlFetchApp.fetch(url, options); var json = response.getContentText(); try { var data = JSON.parse(json); } catch(err) { sheet.getRange("A1").setValue("No unshipped orders"); return; } var values = [ [ "number", "date", "email", "shipping_name", "company_title", "phone", "shipping_street", "shipping_street_2", "shipping_street_3", "shipping_city", "shipping_state", "shipping_postcode", "shipping_country", "shipping_service" ] ]; for(var row in data.orders) { var newRow = []; for (var key in values[0]) { if (values[0][key] == "shipping_street"){ var address = data.orders[row][values[0][key]].split("\n"); for (var i=0; i<=2; i++) { if (address[i]) { newRow.push(address[i]); } else { newRow.push(''); } } } else if (values[0][key].indexOf("shipping_street")>-1){ continue; } else { newRow.push(data.orders[row][values[0][key]]); } } values.push(newRow); } var result = sheet.getRange("A1:N" + values.length).setValues(values); }