opengate-js 12.3.0 → 12.5.0
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/.yarnrc +3 -0
- package/bower.json +1 -1
- package/dist/{opengate-api-bower-12.3.0.js → opengate-api-bower-12.5.0.js} +44279 -42874
- package/dist/opengate-api-bower-12.5.0.js.map +1 -0
- package/dist/opengate-api-bower-12.5.0.min.js +41 -0
- package/dist/opengate-api-bower-12.5.0.min.js.map +1 -0
- package/dist/src/provision/BaseProvision.js +15 -12
- package/dist/src/provision/BaseProvision.js.map +1 -1
- package/dist/src/searching/StaticSearch.js +3 -0
- package/dist/src/searching/StaticSearch.js.map +1 -1
- package/dist/src/users/Users.js +29 -26
- package/dist/src/users/Users.js.map +1 -1
- package/dist/src/util/NorthAmpliaREST.js +5 -2
- package/dist/src/util/NorthAmpliaREST.js.map +1 -1
- package/docs/ast/source/provision/BaseProvision.js.json +4601 -3652
- package/docs/ast/source/searching/StaticSearch.js.json +31687 -31292
- package/docs/ast/source/users/Users.js.json +12204 -14497
- package/docs/ast/source/util/NorthAmpliaREST.js.json +8576 -7446
- package/docs/class/src/users/Users.js~User.html +144 -3
- package/docs/class/src/util/NorthAmpliaREST.js~NorthAmpliaREST.html +3 -3
- package/docs/coverage.json +5 -5
- package/docs/dump.json +558 -477
- package/docs/file/src/provision/BaseProvision.js.html +15 -12
- package/docs/file/src/searching/StaticSearch.js.html +4 -0
- package/docs/file/src/users/Users.js.html +27 -27
- package/docs/file/src/util/NorthAmpliaREST.js.html +7 -3
- package/docs/package.json +2 -2
- package/docs/script/search_index.js +6 -0
- package/docs/source.html +231 -231
- package/features/features/provision/users/create_delete_user.feature +41 -6
- package/features/features/provision/users/find_user.feature +54 -10
- package/features/features/provision/users/reset_password.feature +4 -5
- package/features/features/provision/users/reset_password_mock.feature +4 -5
- package/features/features/provision/users/update_user.feature +36 -8
- package/features/features/searching/catalogs/searching_iot_datastream_period.feature +2 -1
- package/features/features/searching/catalogs/searching_userLanguages.feature +1 -1
- package/features/step_definitions/given_step_definitions_using_model.js +46 -2
- package/features/step_definitions/when_step_definitions.js +1 -1
- package/package.json +2 -2
- package/src/provision/BaseProvision.js +15 -12
- package/src/searching/StaticSearch.js +4 -0
- package/src/users/Users.js +27 -27
- package/src/util/NorthAmpliaREST.js +7 -3
- package/dist/opengate-api-bower-12.3.0.js.map +0 -1
- package/dist/opengate-api-bower-12.3.0.min.js +0 -40
- package/dist/opengate-api-bower-12.3.0.min.js.map +0 -1
|
@@ -478,28 +478,31 @@ export default class BaseProvision {
|
|
|
478
478
|
return promise;
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
_doNorthPost(resource, element) {
|
|
481
|
+
_doNorthPost(resource, element, returnBody) {
|
|
482
482
|
var defered = q.defer();
|
|
483
483
|
var promise = defered.promise;
|
|
484
484
|
this._ogapi.Napi.post(resource, element, this._timeout, this._getExtraHeaders(), this._getUrlParameters(), this._getServiceBaseURL())
|
|
485
485
|
.then((res) => {
|
|
486
|
+
const response = {
|
|
487
|
+
statusCode: res.statusCode
|
|
488
|
+
}
|
|
486
489
|
if (res.statusCode === 201) {
|
|
487
490
|
if (typeof this._onCreated === "function") {
|
|
488
491
|
this._onCreated(res.header.location);
|
|
489
492
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
493
|
+
response.location = res.header.location
|
|
494
|
+
if(returnBody){
|
|
495
|
+
response.data = res.body
|
|
496
|
+
}
|
|
497
|
+
defered.resolve(response);
|
|
494
498
|
} else if (res.statusCode === 200) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
499
|
+
if(returnBody){
|
|
500
|
+
response.data = res.body
|
|
501
|
+
}
|
|
502
|
+
defered.resolve(response);
|
|
498
503
|
} else {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
statusCode: res.statusCode
|
|
502
|
-
});
|
|
504
|
+
response.errors = res.errors
|
|
505
|
+
defered.reject(response);
|
|
503
506
|
}
|
|
504
507
|
})
|
|
505
508
|
.catch((error) => {
|
|
@@ -973,6 +973,10 @@ export default class StaticSearch extends Search {
|
|
|
973
973
|
{
|
|
974
974
|
'code': 'en',
|
|
975
975
|
'language': 'Inglés/English'
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
'code': 'pt',
|
|
979
|
+
'language': 'Portugués/Portuguese'
|
|
976
980
|
}
|
|
977
981
|
],
|
|
978
982
|
'countryCodes': [{
|
|
@@ -509,32 +509,7 @@ export default class User extends BaseProvision {
|
|
|
509
509
|
return data;
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
-
|
|
513
|
-
var defered = q.defer();
|
|
514
|
-
var promise = defered.promise;
|
|
515
|
-
|
|
516
|
-
this._ogapi.Napi.post(url, data, undefined, this._getExtraHeaders(), this._getUrlParameters())
|
|
517
|
-
.then((res) => {
|
|
518
|
-
if (res.statusCode === 200) {
|
|
519
|
-
defered.resolve({
|
|
520
|
-
statusCode: res.statusCode
|
|
521
|
-
});
|
|
522
|
-
} else if (res.status === 200) {
|
|
523
|
-
defered.resolve({
|
|
524
|
-
statusCode: res.status
|
|
525
|
-
});
|
|
526
|
-
} else {
|
|
527
|
-
defered.reject({
|
|
528
|
-
errors: res.errors,
|
|
529
|
-
statusCode: res.statusCode
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
})
|
|
533
|
-
.catch((error) => {
|
|
534
|
-
defered.reject(error);
|
|
535
|
-
});
|
|
536
|
-
return promise;
|
|
537
|
-
}
|
|
512
|
+
|
|
538
513
|
/**
|
|
539
514
|
* This invoke a request to OpenGate North API and the callback is managed by promises
|
|
540
515
|
* This function updates a password of a user
|
|
@@ -616,7 +591,32 @@ export default class User extends BaseProvision {
|
|
|
616
591
|
|
|
617
592
|
return this._doNorthPost(url, data);
|
|
618
593
|
}
|
|
619
|
-
|
|
594
|
+
/**
|
|
595
|
+
* This invoke a request to OpenGate North API and the callback is managed by promises
|
|
596
|
+
* This function get a JWT for user
|
|
597
|
+
* @param {String} email - required field
|
|
598
|
+
* @param {String} password - required field
|
|
599
|
+
* @return {Promise}
|
|
600
|
+
* @property {function (result:object, statusCode:number)} then - When request it is OK
|
|
601
|
+
* @property {function (error:string)} catch - When request it is NOK
|
|
602
|
+
* @example
|
|
603
|
+
* ogapi.usersBuilder().login(email, password);
|
|
604
|
+
*/
|
|
605
|
+
login(email, password) {
|
|
606
|
+
this._email = email;
|
|
607
|
+
this._password = password;
|
|
608
|
+
if (_.isEmpty(this._email) || _.isEmpty(this._password)) {
|
|
609
|
+
throw new Error('OGAPI_USER_LOGIN_EMAIL_AND_PASSWORD_PARAMETER_MUST_BE_DEFINED');
|
|
610
|
+
}
|
|
611
|
+
const data = {
|
|
612
|
+
email: this._email,
|
|
613
|
+
password: this._password
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
const url = this._resource + '/login';
|
|
617
|
+
|
|
618
|
+
return this._doNorthPost(url, data, true)
|
|
619
|
+
}
|
|
620
620
|
}</code></pre>
|
|
621
621
|
|
|
622
622
|
</div>
|
|
@@ -296,7 +296,7 @@ const mock = _mock(request);
|
|
|
296
296
|
*/
|
|
297
297
|
export default class NorthAmpliaREST {
|
|
298
298
|
/**
|
|
299
|
-
* @param {{ url: string,port: string,version: string,apiKey: string}} _options - this is configuration about Opengate North API.
|
|
299
|
+
* @param {{ url: string,port: string,version: string,apiKey: string,JTW: string}} _options - this is configuration about Opengate North API.
|
|
300
300
|
* @param {function} backend - this is a backend selected to manage a request to Opengate North API.
|
|
301
301
|
*/
|
|
302
302
|
constructor(_options, headers) {
|
|
@@ -642,9 +642,13 @@ export default class NorthAmpliaREST {
|
|
|
642
642
|
let defered = q.defer();
|
|
643
643
|
let promise = defered.promise;
|
|
644
644
|
let apiKey = this._options.apiKey;
|
|
645
|
+
let JWT = this._options.jwt;
|
|
645
646
|
let _req = _timeout === -1 ? req : req.timeout(_timeout);
|
|
646
|
-
|
|
647
|
-
if
|
|
647
|
+
|
|
648
|
+
if(JWT) {
|
|
649
|
+
_req = _req.set('Authorization', 'Bearer ' + JWT);
|
|
650
|
+
}
|
|
651
|
+
else if(apiKey) {
|
|
648
652
|
_req = _req.set('X-ApiKey', this._options.apiKey);
|
|
649
653
|
}
|
|
650
654
|
|
package/docs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opengate-js",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/opengate-api-npm.js",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"babelify": "^6.1.0",
|
|
37
37
|
"chai": "^3.5.0",
|
|
38
38
|
"chai-as-promised": "^5.3.0",
|
|
39
|
-
"cucumber": "^
|
|
39
|
+
"cucumber": "^3.0.0",
|
|
40
40
|
"eslint": "^7.8.1",
|
|
41
41
|
"gulp": "^4.0.2",
|
|
42
42
|
"gulp-babel": "^5.1.0",
|
|
@@ -10439,6 +10439,12 @@ window.esdocSearchIndex = [
|
|
|
10439
10439
|
"src/users/Users.js~User#constructor",
|
|
10440
10440
|
"method"
|
|
10441
10441
|
],
|
|
10442
|
+
[
|
|
10443
|
+
"src/users/users.js~user#login",
|
|
10444
|
+
"class/src/users/Users.js~User.html#instance-method-login",
|
|
10445
|
+
"src/users/Users.js~User#login",
|
|
10446
|
+
"method"
|
|
10447
|
+
],
|
|
10442
10448
|
[
|
|
10443
10449
|
"src/users/users.js~user#requestresetpassword",
|
|
10444
10450
|
"class/src/users/Users.js~User.html#instance-method-requestResetPassword",
|