forked from fuzzysteve/eve-googledocs-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blueprints.gs
45 lines (40 loc) · 2.31 KB
/
blueprints.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Call this function like:
=loadBlueprints("corp",4324234,"7okqZ1gOyG43243243242342qb2wkyd21C",90926985)
and get all your blueprints loaded into the sheet. I'd suggest doing it on a blank sheet,
rather than in a sheet you have useful information on.
It's 'blueprint ID','location ID','Typeid of blueprint','name of blueprint','which hangar it's in',
'quantity. -2 for a BPC, -1 for a BPO, a number for stacked BPOs',TE,ME,'runs, -1 for a BPO'
*/
/**
* Creates a table of information on blueprints retrieved from the EVE API.
* @param {string} type This should be set to "char" or "corp" depending on the type of API key in use.
* @param {number} keyID This should be set to the keyID given by your API key.
* @param {string} vCode This should be set to the verification code given by your API key.
* @param {number} characterID This should be set to the specific character for which you would like to retrieve the blueprint data.
* @returns A table with information in the following order: 'blueprint ID','location ID','Typeid of blueprint','name of blueprint','which hangar it's in', 'quantity. -2 for a BPC, -1 for a BPO, a number for stacked BPOs',TE,ME,'runs, -1 for a BPO'
* @customfunction
*/
function loadBlueprints(type, keyID, vCode, characterID){
var blueprints= new Array();
var url = "https://api.eveonline.com/"+type+"/Blueprints.xml.aspx?keyID="+keyID+"&vCode="+vCode+"&characterID="+characterID;
var parameters = {method : "get", payload : ""};
var xmlFeed = UrlFetchApp.fetch(url, parameters).getContentText();
var xml = XmlService.parse(xmlFeed);
if(xml) {
var rows=xml.getRootElement().getChild("result").getChild("rowset").getChildren("row");
for(var i = 0; i < rows.length; i++) {
blueprint=[rows[i].getAttribute("itemID").getValue(),
rows[i].getAttribute("locationID").getValue(),
rows[i].getAttribute("typeID").getValue(),
rows[i].getAttribute("typeName").getValue(),
rows[i].getAttribute("flagID").getValue(),
rows[i].getAttribute("quantity").getValue(),
rows[i].getAttribute("timeEfficiency").getValue(),
rows[i].getAttribute("materialEfficiency").getValue(),
rows[i].getAttribute("runs").getValue()]
blueprints.push(blueprint);
}
}
return blueprints;
}