forked from OfficeDev/Excel-Custom-Functions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
companies-house.js
110 lines (94 loc) · 2.91 KB
/
companies-house.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const endPoint = 'https://excel-ch-api.herokuapp.com';
function httpRequest(url, callback) {
var xhr = new XMLHttpRequest();
// The last parameter must be set to true to make an asynchronous request
xhr.open('GET', url, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.setRequestHeader('Accept', 'application/json');
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
callback(xhr.response);
} else {
callback(xhr.status + ' error');
}
};
xhr.send();
}
function NAME(company_number) {
// waits 1 second before returning the result
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/company-name/' + company_number, function(response){
resolve(response);
});
});
}
function REGADDRESS(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/company-address/' + company_number, function(response){
resolve(response);
});
});
}
function LIQUIDATED(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/has-been-liquidated/' + company_number, function(response){
resolve(response);
});
});
}
function SICCODES(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/sic-code/' + company_number, function(response){
resolve(response);
});
});
}
function ACCOUNTINGDATE(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/accounting-reference-date/' + company_number, function(response){
resolve(response);
});
});
}
function OVERDUESTATUS(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/overdue-accounts/' + company_number, function(response){
resolve(response);
});
});
}
function INCORPORATIONDATE(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/incorporation-date/' + company_number, function(response){
resolve(response);
});
});
}
function COMPANYSTATUS(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/company-status/' + company_number, function(response){
resolve(response);
});
});
}
function DIRECTORS(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/company-active-directors/' + company_number, function(response){
resolve(response);
});
});
}
function SIGCONTROL(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/company-significant-control/' + company_number, function(response){
resolve(response);
});
});
}
function LASTMEMBERSLIST(company_number) {
return new OfficeExtension.Promise(function(resolve) {
httpRequest(endPoint + '/last-full-members-list/' + company_number, function(response){
resolve(response);
});
});
}