swiftyper-node 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Error.js +77 -77
- package/lib/SwiftyperMethod.js +24 -21
- package/lib/SwiftyperResource.js +432 -352
- package/lib/makeRequest.js +105 -103
- package/lib/resources/Business.js +23 -23
- package/lib/resources/EmailUtil.js +13 -13
- package/lib/resources/Fbt.js +13 -13
- package/lib/resources/HelpCenter.js +18 -0
- package/lib/resources/HelpCenterArticle.js +23 -0
- package/lib/resources/HelpCenterCategory.js +18 -0
- package/lib/resources/HelpCenterChat.js +40 -0
- package/lib/resources/IpUtil.js +13 -13
- package/lib/resources/Phrase.js +23 -23
- package/lib/resources/Places.js +58 -58
- package/lib/resources/Translation.js +38 -38
- package/lib/resources/Translator.js +13 -13
- package/lib/resources/ViesUtil.js +13 -13
- package/lib/resources.js +17 -13
- package/lib/swiftyper.js +159 -159
- package/lib/utils.js +332 -272
- package/package.json +36 -36
package/lib/makeRequest.js
CHANGED
|
@@ -1,103 +1,105 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const utils = require('./utils');
|
|
4
|
-
|
|
5
|
-
function getRequestOpts(self, requestArgs, spec, overrideData) {
|
|
6
|
-
const commandPath = utils.makeURLInterpolator(spec.path || '');
|
|
7
|
-
const requestMethod = (spec.method || 'POST').toUpperCase();
|
|
8
|
-
const urlParams = spec.urlParams || [];
|
|
9
|
-
const encode = spec.encode || ((data) => data);
|
|
10
|
-
const host = spec.host;
|
|
11
|
-
const path = self.createResourcePathWithSymbols(spec.path);
|
|
12
|
-
|
|
13
|
-
const args = [].slice.call(requestArgs);
|
|
14
|
-
|
|
15
|
-
const urlData = urlParams.reduce((urlData, param) => {
|
|
16
|
-
const arg = args.shift();
|
|
17
|
-
if (typeof arg !== 'string') {
|
|
18
|
-
throw new Error(
|
|
19
|
-
`Swiftyper: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
urlData[param] = arg;
|
|
24
|
-
return urlData;
|
|
25
|
-
}, {});
|
|
26
|
-
|
|
27
|
-
const dataFromArgs = utils.getDataFromArgs(args);
|
|
28
|
-
const data = encode(Object.assign({}, dataFromArgs, overrideData));
|
|
29
|
-
const options = utils.getOptionsFromArgs(args);
|
|
30
|
-
|
|
31
|
-
if (args.filter((x) => x != null).length) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`Swiftyper: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/swiftyper-sk/swiftyper-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const requestPath = self.createFullPath(commandPath, urlData);
|
|
38
|
-
const headers = Object.assign(options.headers, spec.headers);
|
|
39
|
-
|
|
40
|
-
if (spec.validator) {
|
|
41
|
-
spec.validator(data, {headers});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const dataInQuery = spec.method === 'GET';
|
|
45
|
-
const bodyData = dataInQuery ? {} : data;
|
|
46
|
-
const queryData = dataInQuery ? data : {};
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
requestMethod,
|
|
50
|
-
requestPath,
|
|
51
|
-
bodyData,
|
|
52
|
-
queryData,
|
|
53
|
-
auth: options.auth,
|
|
54
|
-
headers,
|
|
55
|
-
host,
|
|
56
|
-
settings: options.settings,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function makeRequest(self, requestArgs, spec, overrideData) {
|
|
61
|
-
return new Promise((resolve, reject) => {
|
|
62
|
-
let opts;
|
|
63
|
-
try {
|
|
64
|
-
opts = getRequestOpts(self, requestArgs, spec, overrideData);
|
|
65
|
-
} catch (err) {
|
|
66
|
-
reject(err);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function requestCallback(err, response) {
|
|
71
|
-
if (err) {
|
|
72
|
-
reject(err);
|
|
73
|
-
} else {
|
|
74
|
-
resolve(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
opts.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const utils = require('./utils');
|
|
4
|
+
|
|
5
|
+
function getRequestOpts(self, requestArgs, spec, overrideData) {
|
|
6
|
+
const commandPath = utils.makeURLInterpolator(spec.path || '');
|
|
7
|
+
const requestMethod = (spec.method || 'POST').toUpperCase();
|
|
8
|
+
const urlParams = spec.urlParams || [];
|
|
9
|
+
const encode = spec.encode || ((data) => data);
|
|
10
|
+
const host = spec.host;
|
|
11
|
+
const path = self.createResourcePathWithSymbols(spec.path);
|
|
12
|
+
|
|
13
|
+
const args = [].slice.call(requestArgs);
|
|
14
|
+
|
|
15
|
+
const urlData = urlParams.reduce((urlData, param) => {
|
|
16
|
+
const arg = args.shift();
|
|
17
|
+
if (typeof arg !== 'string') {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`Swiftyper: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
urlData[param] = arg;
|
|
24
|
+
return urlData;
|
|
25
|
+
}, {});
|
|
26
|
+
|
|
27
|
+
const dataFromArgs = utils.getDataFromArgs(args);
|
|
28
|
+
const data = encode(Object.assign({}, dataFromArgs, overrideData));
|
|
29
|
+
const options = utils.getOptionsFromArgs(args);
|
|
30
|
+
|
|
31
|
+
if (args.filter((x) => x != null).length) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Swiftyper: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/swiftyper-sk/swiftyper-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const requestPath = self.createFullPath(commandPath, urlData);
|
|
38
|
+
const headers = Object.assign(options.headers, spec.headers);
|
|
39
|
+
|
|
40
|
+
if (spec.validator) {
|
|
41
|
+
spec.validator(data, {headers});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const dataInQuery = spec.method === 'GET';
|
|
45
|
+
const bodyData = dataInQuery ? {} : data;
|
|
46
|
+
const queryData = dataInQuery ? data : {};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
requestMethod,
|
|
50
|
+
requestPath,
|
|
51
|
+
bodyData,
|
|
52
|
+
queryData,
|
|
53
|
+
auth: options.auth,
|
|
54
|
+
headers,
|
|
55
|
+
host,
|
|
56
|
+
settings: options.settings,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function makeRequest(self, requestArgs, spec, overrideData) {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
let opts;
|
|
63
|
+
try {
|
|
64
|
+
opts = getRequestOpts(self, requestArgs, spec, overrideData);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
reject(err);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function requestCallback(err, response) {
|
|
71
|
+
if (err) {
|
|
72
|
+
reject(err);
|
|
73
|
+
} else if (spec.streaming) {
|
|
74
|
+
resolve(utils.parseSSEStream(response));
|
|
75
|
+
} else {
|
|
76
|
+
resolve(
|
|
77
|
+
spec.transformResponseData
|
|
78
|
+
? spec.transformResponseData(response)
|
|
79
|
+
: response
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const emptyQuery = Object.keys(opts.queryData).length === 0;
|
|
85
|
+
const path = [
|
|
86
|
+
opts.requestPath,
|
|
87
|
+
emptyQuery ? '' : '?',
|
|
88
|
+
utils.stringifyRequestData(opts.queryData),
|
|
89
|
+
].join('');
|
|
90
|
+
|
|
91
|
+
const {headers, settings} = opts;
|
|
92
|
+
|
|
93
|
+
self._request(
|
|
94
|
+
opts.requestMethod,
|
|
95
|
+
opts.host,
|
|
96
|
+
path,
|
|
97
|
+
opts.bodyData,
|
|
98
|
+
opts.auth,
|
|
99
|
+
{headers, settings, rawStream: !!spec.streaming},
|
|
100
|
+
requestCallback
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = makeRequest;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
-
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
-
|
|
6
|
-
module.exports = SwiftyperResource.extend({
|
|
7
|
-
path: 'business',
|
|
8
|
-
|
|
9
|
-
query: swiftyperMethod({
|
|
10
|
-
method: 'POST',
|
|
11
|
-
path: '/query',
|
|
12
|
-
}),
|
|
13
|
-
|
|
14
|
-
identifier: swiftyperMethod({
|
|
15
|
-
method: 'POST',
|
|
16
|
-
path: '/identifier',
|
|
17
|
-
}),
|
|
18
|
-
|
|
19
|
-
detail: swiftyperMethod({
|
|
20
|
-
method: 'POST',
|
|
21
|
-
path: '/{business_id}',
|
|
22
|
-
}),
|
|
23
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'business',
|
|
8
|
+
|
|
9
|
+
query: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/query',
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
identifier: swiftyperMethod({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
path: '/identifier',
|
|
17
|
+
}),
|
|
18
|
+
|
|
19
|
+
detail: swiftyperMethod({
|
|
20
|
+
method: 'POST',
|
|
21
|
+
path: '/{business_id}',
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
-
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
-
|
|
6
|
-
module.exports = SwiftyperResource.extend({
|
|
7
|
-
path: 'utils/email',
|
|
8
|
-
|
|
9
|
-
validate: swiftyperMethod({
|
|
10
|
-
method: 'POST',
|
|
11
|
-
path: '/validate',
|
|
12
|
-
}),
|
|
13
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'utils/email',
|
|
8
|
+
|
|
9
|
+
validate: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/validate',
|
|
12
|
+
}),
|
|
13
|
+
});
|
package/lib/resources/Fbt.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
-
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
-
|
|
6
|
-
module.exports = SwiftyperResource.extend({
|
|
7
|
-
path: 'intl/fbt',
|
|
8
|
-
|
|
9
|
-
init: swiftyperMethod({
|
|
10
|
-
method: 'POST',
|
|
11
|
-
path: '/initialize',
|
|
12
|
-
}),
|
|
13
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'intl/fbt',
|
|
8
|
+
|
|
9
|
+
init: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/initialize',
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'help-center',
|
|
8
|
+
|
|
9
|
+
configuration: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/configuration',
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
contact: swiftyperMethod({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
path: '/contact',
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'help-center/articles',
|
|
8
|
+
|
|
9
|
+
query: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/query',
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
popular: swiftyperMethod({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
path: '/popular',
|
|
17
|
+
}),
|
|
18
|
+
|
|
19
|
+
detail: swiftyperMethod({
|
|
20
|
+
method: 'POST',
|
|
21
|
+
path: '/{article_id}',
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'help-center/categories',
|
|
8
|
+
|
|
9
|
+
query: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/query',
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
detail: swiftyperMethod({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
path: '/{category_id}',
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'help-center/chat',
|
|
8
|
+
|
|
9
|
+
stream: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
headers: {Accept: 'text/event-stream'},
|
|
12
|
+
path: '/stream',
|
|
13
|
+
streaming: true,
|
|
14
|
+
}),
|
|
15
|
+
|
|
16
|
+
handoff: swiftyperMethod({
|
|
17
|
+
method: 'POST',
|
|
18
|
+
path: '/handoff',
|
|
19
|
+
}),
|
|
20
|
+
|
|
21
|
+
contact: swiftyperMethod({
|
|
22
|
+
method: 'POST',
|
|
23
|
+
path: '/handoffs/{request_id}/contact',
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
skip: swiftyperMethod({
|
|
27
|
+
method: 'POST',
|
|
28
|
+
path: '/handoffs/{request_id}/skip',
|
|
29
|
+
}),
|
|
30
|
+
|
|
31
|
+
feedback: swiftyperMethod({
|
|
32
|
+
method: 'POST',
|
|
33
|
+
path: '/{session_id}/feedback',
|
|
34
|
+
}),
|
|
35
|
+
|
|
36
|
+
end: swiftyperMethod({
|
|
37
|
+
method: 'POST',
|
|
38
|
+
path: '/{session_id}/end',
|
|
39
|
+
}),
|
|
40
|
+
});
|
package/lib/resources/IpUtil.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
-
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
-
|
|
6
|
-
module.exports = SwiftyperResource.extend({
|
|
7
|
-
path: 'utils/ip',
|
|
8
|
-
|
|
9
|
-
info: swiftyperMethod({
|
|
10
|
-
method: 'GET',
|
|
11
|
-
path: '/{ip_address}',
|
|
12
|
-
}),
|
|
13
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'utils/ip',
|
|
8
|
+
|
|
9
|
+
info: swiftyperMethod({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/{ip_address}',
|
|
12
|
+
}),
|
|
13
|
+
});
|
package/lib/resources/Phrase.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
-
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
-
|
|
6
|
-
module.exports = SwiftyperResource.extend({
|
|
7
|
-
path: 'intl/phrases',
|
|
8
|
-
|
|
9
|
-
query: swiftyperMethod({
|
|
10
|
-
method: 'POST',
|
|
11
|
-
path: '/query',
|
|
12
|
-
}),
|
|
13
|
-
|
|
14
|
-
upload: swiftyperMethod({
|
|
15
|
-
method: 'POST',
|
|
16
|
-
path: '/upload',
|
|
17
|
-
}),
|
|
18
|
-
|
|
19
|
-
raw: swiftyperMethod({
|
|
20
|
-
method: 'GET',
|
|
21
|
-
path: '/raw',
|
|
22
|
-
}),
|
|
23
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'intl/phrases',
|
|
8
|
+
|
|
9
|
+
query: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/query',
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
upload: swiftyperMethod({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
path: '/upload',
|
|
17
|
+
}),
|
|
18
|
+
|
|
19
|
+
raw: swiftyperMethod({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
path: '/raw',
|
|
22
|
+
}),
|
|
23
|
+
});
|
package/lib/resources/Places.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
-
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
-
|
|
6
|
-
module.exports = SwiftyperResource.extend({
|
|
7
|
-
path: 'places',
|
|
8
|
-
|
|
9
|
-
query: swiftyperMethod({
|
|
10
|
-
method: 'POST',
|
|
11
|
-
path: '/query',
|
|
12
|
-
}),
|
|
13
|
-
|
|
14
|
-
validate: swiftyperMethod({
|
|
15
|
-
method: 'POST',
|
|
16
|
-
path: '/validate',
|
|
17
|
-
}),
|
|
18
|
-
|
|
19
|
-
street: swiftyperMethod({
|
|
20
|
-
method: 'POST',
|
|
21
|
-
path: '/street',
|
|
22
|
-
}),
|
|
23
|
-
|
|
24
|
-
municipality: swiftyperMethod({
|
|
25
|
-
method: 'POST',
|
|
26
|
-
path: '/municipality',
|
|
27
|
-
}),
|
|
28
|
-
|
|
29
|
-
postal: swiftyperMethod({
|
|
30
|
-
method: 'POST',
|
|
31
|
-
path: '/postal',
|
|
32
|
-
}),
|
|
33
|
-
|
|
34
|
-
reverse: swiftyperMethod({
|
|
35
|
-
method: 'POST',
|
|
36
|
-
path: '/reverse',
|
|
37
|
-
}),
|
|
38
|
-
|
|
39
|
-
regions: swiftyperMethod({
|
|
40
|
-
method: 'POST',
|
|
41
|
-
path: '/regions',
|
|
42
|
-
}),
|
|
43
|
-
|
|
44
|
-
counties: swiftyperMethod({
|
|
45
|
-
method: 'POST',
|
|
46
|
-
path: '/counties',
|
|
47
|
-
}),
|
|
48
|
-
|
|
49
|
-
municipalities: swiftyperMethod({
|
|
50
|
-
method: 'POST',
|
|
51
|
-
path: '/municipalities',
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
detail: swiftyperMethod({
|
|
55
|
-
method: 'POST',
|
|
56
|
-
path: '/{place_id}',
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SwiftyperResource = require('../SwiftyperResource');
|
|
4
|
+
const swiftyperMethod = SwiftyperResource.method;
|
|
5
|
+
|
|
6
|
+
module.exports = SwiftyperResource.extend({
|
|
7
|
+
path: 'places',
|
|
8
|
+
|
|
9
|
+
query: swiftyperMethod({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/query',
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
validate: swiftyperMethod({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
path: '/validate',
|
|
17
|
+
}),
|
|
18
|
+
|
|
19
|
+
street: swiftyperMethod({
|
|
20
|
+
method: 'POST',
|
|
21
|
+
path: '/street',
|
|
22
|
+
}),
|
|
23
|
+
|
|
24
|
+
municipality: swiftyperMethod({
|
|
25
|
+
method: 'POST',
|
|
26
|
+
path: '/municipality',
|
|
27
|
+
}),
|
|
28
|
+
|
|
29
|
+
postal: swiftyperMethod({
|
|
30
|
+
method: 'POST',
|
|
31
|
+
path: '/postal',
|
|
32
|
+
}),
|
|
33
|
+
|
|
34
|
+
reverse: swiftyperMethod({
|
|
35
|
+
method: 'POST',
|
|
36
|
+
path: '/reverse',
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
regions: swiftyperMethod({
|
|
40
|
+
method: 'POST',
|
|
41
|
+
path: '/regions',
|
|
42
|
+
}),
|
|
43
|
+
|
|
44
|
+
counties: swiftyperMethod({
|
|
45
|
+
method: 'POST',
|
|
46
|
+
path: '/counties',
|
|
47
|
+
}),
|
|
48
|
+
|
|
49
|
+
municipalities: swiftyperMethod({
|
|
50
|
+
method: 'POST',
|
|
51
|
+
path: '/municipalities',
|
|
52
|
+
}),
|
|
53
|
+
|
|
54
|
+
detail: swiftyperMethod({
|
|
55
|
+
method: 'POST',
|
|
56
|
+
path: '/{place_id}',
|
|
57
|
+
}),
|
|
58
|
+
});
|