1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const fs = require('fs');
|
17 |
|
18 | const BaseService = require('./BaseService');
|
19 | const { HTTPMethod } = require('./Constants');
|
20 | const { Endpoints, isNullOrUndefined } = require('./Utils');
|
21 |
|
22 | class PushService extends BaseService {
|
23 | getPushSettings(envId, done) {
|
24 | const endpoint = Endpoints.push(this.cliManager.config.defaultSchemaVersion, envId);
|
25 | this.cliManager.sendRequest({ endpoint, method: HTTPMethod.GET }, done);
|
26 | }
|
27 |
|
28 | configureAndroidSettings(envId, data, done) {
|
29 | const endpoint = Endpoints.push(this.cliManager.config.defaultSchemaVersion, envId);
|
30 | this.cliManager.sendRequest({ endpoint, data, method: HTTPMethod.PUT }, done);
|
31 | }
|
32 |
|
33 | configureIosSettings(envId, data, done) {
|
34 | const formData = {
|
35 | production: JSON.stringify(data.production),
|
36 | upload: fs.createReadStream(data.certificateFilePath)
|
37 | };
|
38 |
|
39 | if (!isNullOrUndefined(data.password)) {
|
40 | formData.password = JSON.stringify(data.password);
|
41 | }
|
42 |
|
43 | const endpoint = Endpoints.push(this.cliManager.config.defaultSchemaVersion, envId);
|
44 | this.cliManager.sendRequest({
|
45 | endpoint,
|
46 | formData,
|
47 | method: HTTPMethod.POST
|
48 | }, done);
|
49 | }
|
50 | }
|
51 |
|
52 | module.exports = PushService;
|