Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const apiKey = "0e2d8482ae31c8eb1d4a304cf56a8699";
- const url = "https://api.novaposhta.ua/v2.0/json/";
- const sheetNP = "НП";
- function go() {
- const ss = SpreadsheetApp.getActive();
- const sh = ss.getSheetByName(sheetNP);
- const values = sh.getRange("d2:d" + sh.getLastRow()).getValues().filter(h => h[0]);
- values.forEach((h, i) => {
- const result = getEr(h);
- sh.getRange("I" + (2 + i)).setValue(result);
- SpreadsheetApp.flush();
- })
- }
- function getEr(ttn) {
- let data = {
- "modelName": "TrackingDocument",
- "calledMethod": "getStatusDocuments",
- "methodProperties": {
- "Documents": [
- {
- "DocumentNumber": ttn.toString(),
- "Phone": ""
- }
- ]
- }
- };
- let options = {
- "method": "POST",
- "headers": {
- "content-type": "application/json",
- "apiKey": apiKey
- },
- "async": true,
- "crossDomain": true,
- "processData": false,
- "payload": JSON.stringify(data)
- }
- let response = UrlFetchApp.fetch(url, options);
- let dataPars = JSON.parse(response.getContentText());
- return dataPars.data[0].Status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement