@beauraines/rtm-api 1.13.1 → 1.14.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/.github/workflows/publish.yml +1 -1
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/location/helper.js +39 -0
- package/src/location/index.js +82 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.14.0](https://github.com/beauraines/rtm-api/compare/v1.13.1...v1.14.0) (2025-12-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **Locations:** adds support. for get Locations ([4694b54](https://github.com/beauraines/rtm-api/commit/4694b54f8b6e4096dc235e83f83f8164c8f164c7))
|
|
11
|
+
* **Locations:** adds support. for get Locations ([#74](https://github.com/beauraines/rtm-api/issues/74)) ([76a6e05](https://github.com/beauraines/rtm-api/commit/76a6e059ad6717e43e64fb6f4584d2fbc9838d2e))
|
|
12
|
+
|
|
5
13
|
### [1.13.1](https://github.com/beauraines/rtm-api/compare/v1.13.0...v1.13.1) (2025-12-17)
|
|
6
14
|
|
|
7
15
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const RTMLocation = require('./index.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* API Call: rtm.locations.getList
|
|
8
|
+
* @param user RTMUser
|
|
9
|
+
* @param callback Callback function(err, locations)
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
function get(user, callback) {
|
|
13
|
+
user.get('rtm.locations.getList', function(err, resp) {
|
|
14
|
+
if ( err ) {
|
|
15
|
+
return callback(err);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// List of locations to return
|
|
19
|
+
let rtn = [];
|
|
20
|
+
|
|
21
|
+
// Parse each of the locations
|
|
22
|
+
let locations = resp.locations.location;
|
|
23
|
+
for ( let i = 0; i < locations.length; i++ ) {
|
|
24
|
+
rtn.push(
|
|
25
|
+
new RTMLocation(locations[i])
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Call the callback
|
|
30
|
+
return callback(null, rtn);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
get: get
|
|
39
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ### RTM Location
|
|
6
|
+
*
|
|
7
|
+
* This Class is used to represent the properties of an RTM Location.
|
|
8
|
+
*
|
|
9
|
+
* All of the location properties from RTM are directly accessible from this Class.
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* let location = new RTMLocation(...);
|
|
13
|
+
* let name = location.name;
|
|
14
|
+
* ```
|
|
15
|
+
* @class
|
|
16
|
+
*/
|
|
17
|
+
class RTMLocation {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new RTM Location
|
|
21
|
+
* @param {object} props The properties from the RTM API response `resp.locations.location`
|
|
22
|
+
*/
|
|
23
|
+
constructor(props) {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Location ID
|
|
27
|
+
* @type {Number}
|
|
28
|
+
*/
|
|
29
|
+
this.id = parseFloat(props.id);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Location Name
|
|
33
|
+
* @type {string}
|
|
34
|
+
*/
|
|
35
|
+
this.name = props.name;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Location Longitude
|
|
40
|
+
* @type {Number}
|
|
41
|
+
*/
|
|
42
|
+
this.longitude = parseInt(props.longitude);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Location Latitude
|
|
46
|
+
* @type {Number}
|
|
47
|
+
*/
|
|
48
|
+
this.latitude = parseInt(props.latitude);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Location Zoom
|
|
53
|
+
* @type {Number}
|
|
54
|
+
*/
|
|
55
|
+
this.zoom = parseInt(props.zoom);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Location Address
|
|
59
|
+
* @type {string}
|
|
60
|
+
*/
|
|
61
|
+
this.address = props.address;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* All of the RTM Location properties
|
|
67
|
+
* @type {object}
|
|
68
|
+
*/
|
|
69
|
+
get props() {
|
|
70
|
+
let rtn = {};
|
|
71
|
+
for ( let key in this ) {
|
|
72
|
+
if ( this.hasOwnProperty(key) && key !== '_index' ) {
|
|
73
|
+
rtn[key] = this[key];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return rtn;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
module.exports = RTMLocation;
|