-
Notifications
You must be signed in to change notification settings - Fork 2
/
configuration-example.js
114 lines (99 loc) · 3.39 KB
/
configuration-example.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
111
112
113
114
require('dotenv').config();
var SeniorApi = require('../').SeniorApi;
var username = process.env.SENIOR_USERNAME;
var password = process.env.PASS;
var api = new SeniorApi();
const servicePropertiesPayload = {
dominio: 'domain01',
servico: 'service01'
}
const createPayload = {
propertyKey: 'MinhaPropCustomizada',
type: 'String',
propertyValue: 'Meu teste',
label: 'Minha propriedade Customizada',
propertyLevel: 'SYSTEM'
}
const propKeyPayload = {
propertyKey: 'MinhaPropCustomizada'
}
const updatePayload = {
propertyKey: 'MinhaPropCustomizada',
type: 'String',
propertyValue: 'Meu teste - Alterado',
label: 'Minha propriedade Customizada - Alterada',
propertyLevel: 'SYSTEM'
}
api.authentication.login({username, password}).then(function (json) {
if(json.body.resetPasswordInfo) {
throw new Error('Usuário informado inválido para os testes, é necessário fazer o login na plataforma ao menos uma vez após a sua criação para realizar a troca da senha.');
}
api.accessToken = JSON.parse(json.body.jsonToken).access_token;
api.configuration.createCustomProperty(createPayload)
.then(function (json) {
if (json.statusCode != 200) {
console.error(json);
} else {
console.log(json.body);
}
api.configuration.getCustomProperty(propKeyPayload)
.then(function (json) {
if (json.statusCode != 200) {
console.error(json);
} else {
console.log(json.body);
}
api.configuration.updateCustomProperty(updatePayload)
.then(function (json) {
if (json.statusCode != 200) {
console.error(json);
} else {
console.log(json.body);
}
api.configuration.getCustomProperty(propKeyPayload)
.then(function (json) {
if (json.statusCode != 200) {
console.error(json);
} else {
console.log(json.body);
}
api.configuration.deleteCustomProperty(propKeyPayload)
.then(function (json) {
if (json.statusCode != 200) {
console.error(json);
} else {
console.log(json.body);
}
}).catch(function (error) {
console.error('Erro na tentativa de excluir propriedade de configuração: ', error);
});
}).catch(function (error) {
console.error('Erro na tentativa de ler propriedade de configuração: ', error);
});
}).catch(function (error) {
console.error('Erro na tentativa de atualizar propriedade de configuração: ', error);
});
}).catch(function (error) {
console.error('Erro na tentativa de ler propriedade de configuração: ', error);
});
}).catch(function (error) {
console.error('Erro na tentativa de criar propriedade de configuração: ', error);
});
api.configuration.listServiceProperties(servicePropertiesPayload)
.then(function (json) {
if (json.statusCode != 200) {
console.error(json);
} else {
console.log(json.body);
}
}).catch(function (error) {
console.error('Erro ao tentar recuperar a lista de todas as propriedades de domínios/serviços: ', error);
});
if (api.accessToken) {
api.authentication.logout().catch(function (error) {
console.error('Erro na tentativa de efetuar logout: ', error);
});
}
}).catch(function (error) {
console.error('Erro na tentativa de efetuar login: ', error);
});