Telstra-API - v0.2
Telstra-API is a node.js module that takes the hard work out of using Telstra Developer APIs.
Included APIs
The Connect API and Mobile Connect API will not be included in this module.
Installation
The easiest (and only supported) way to install Telstra-API is by using NPM (Node Package Manager) from the command line.
$ npm install telstra-api
Usage
// Obtain these keys from the Telstra Developer PortalCONSUMER_KEY = "U62RDEGRxb4Jw2p30oHkMnBLJaSJG5IS";CONSUMER_SECRET = "PTbyss26edeKr1cs"; // Scope should contain a list of required APIs, seperated by a space (0x20).SCOPE = "SMS WIFI"; TelstraAPI = ;var t = CONSUMER_KEY CONSUMER_SECRET SCOPE;
NOTE: It is important to make sure you're using the correct CONSUMER_KEY and CONSUMER_SECRET, as well as specifying only the scope(s) that your application has access to in the Telstra Developer Portal, as all authentication failures (not API errors) will result in a printed stack trace, and the application exiting.
SMS API - t.sms
t.sms.send(string <target>, string <message>);
- target: Australian telephone phone number to deliver SMS.
- message: The message to be delivered.
Returns: (String) The message ID of the pending SMS.
t.sms.getFullReplies(String <messageId>);
messageID: The message ID received from a previous call to t.sms.send()
Returns: An object containing:
- String from: The number from which the SMS is received.
- String acknowledgedTimestamp: The time that the message was received by the SMS service.
- String content: The content of the SMS.
t.sms.getFullStatus(String <messageId>);
messageID: The message ID received from a previous call to t.sms.send()
Returns: An object containing:
- String to: The target number supplied to t.sms.send().
- String receivedTimestamp: The time that the message was received by the target network.
- String sentTimestamp: The time that the message was sent.
- String status: A status representing the current send status of the message.
t.sms.getReplies(String <messageId>);
messageID: The message ID received from a previous call to t.sms.send()
Returns: An array of (String) replys - See: t.sms.getFullReplies()
t.sms.getStatus(String <messageId>);
messageID: The message ID received from a previous call to t.sms.send()
Returns: (String) status - See: status in t.sms.getFullStatus()
WiFi API - t.wifi
t.wifi.getHotspots(Number <latitude>, Number <longitude>, Number [radius]);
Retrieves the location of nearby Telstra owned WiFi Hotspots in Australia (Telstra AIR).
- Latitude: The latitude of the centre of the search area.
- Longitude: The longitude of the centre of the search area.
- Radius: The radius (in metres) of the area to be searched. Defaults to 2000.
Returns: (Array) An array of up to 10 Objects containing:
- Number lat: The latitude of the hotspot
- Number long: The longitude of the hotspot.
- String address: A description of the hotspot's location.
- String city: The suburb containing the hotspot.
- String state: The state containing the hotspot.
Promises
Due to the asynchronous nature of this module, we have chosen to implement all methods using Promises. When we refer to a method returning a value, the method will return a promise that should resolve to that value if no error has occured. If an error occurs, the promise will be rejected with an error object containing a descriptive message.
Here's a quick example on how to use a promise returned by a method in this module. For more information on Promises and their usage, please refer to Promises on MDN.
t<api><method>arguments;
License - MIT License (MIT)
Copyright (c) 2016 Joshua 'JD' Davison Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.