Small wrapper for the transportation card used in Ankara, AnkaraKart.
- Node.js version 8 or higher
- An AnkaraKart
- request (API and Setup)
- request-promise-native (API and Setup)
- moment-timezone (API only)
- iconv-lite (API only)
- cheerio (Setup only)
- node-uuid (Setup only)
It is an API what do you expect.
~/project/$ npm install --save ankarakart
On your project:
const AnkaraKart = require("ankarakart");
const ankarakart = new AnkaraKart();
Returns a Promise containing cardObject
.
If canReturnRaw is set to true
, it will return a Promise containing cardObjectRaw
.
Returns a Promise containing cardUsageArray
.
If canReturnRaw is set to true
, it will return a Promise containing cardUsageArrayRaw
.
If the array is empty, that means the card is never used within the last 30 days.
You really don't need to use it manually, since the two above already uses them.
An object containing the card info.
16 digit string, containing the card number that was supplied to exectute the ankarakart.getCardInfo()
function.
Parsable date string, containing the last date that the card was used.
String, containing the credit that the card has.
String that can be 1, (maybe) 2 or 3.
- 1 is for sucessful query
- 2 is
unknown
- 3 is for invalid card
String, containing the response message from the query server. This can be:
- Sorgulama Başarılı (Query Successful)
- Geçersiz Kart (Invalid Card) (Though, this will return an error; see: Errors)
Contains cardUsageObject
s. Sorted by date. First element of the array is the latest event. If the card haven't been used in the last 30 days, this array will be empty.
16 digit string, containing the card number that was supplied to exectute the ankarakart.getCardUsage()
function.
Parsable date string, contains the date of the current card usage.
String, containing what happened on the current card usage.
This can be:
- İlk Biniş (First Entry)
- İkinci Kişi (Second Person)
- Aktarma (Transfer)
String, contains the car type of the current card usage.
This can be:
- Ankaray
- Metro
- Otobüs (Bus)
Empty
, only happens when you get on a private bus that accepts AnkaraKart.
String, containing the bus code like xx-xxx
. Will be available if this data is not empty. lol
String, containing the bus line like xxx
. Will be available if carNumber
is not empty.
String, containing the credit that was spent on the current card usage.
String, containing the credit that will remain at the current card usage.
The raw object containing the card info.
Same as cardObject.cardNumber
.
Sort of cardObject.date
but formatted like DD.MM.YYYY HH:mm:ss
in GMT+3
Same as cardbObject.credit
.
Same as cardbObject.result
but not translated.
Same as cardbObject.message
but not translated.
The raw array containing cardUsageObjectRaw
s. Sorted by date. First element of the array is the latest event. If the card haven't been used in the last 30 days, this array will be empty.
Same as cardUsageObject.cardNumber
.
Sort of cardUsageObject.date
but formatted like DD/MM/YYYY HH:mm:ss
in GMT+3
Same as cardUsageObject.operation
but not translated.
Same as cardUsageObject.carType
but not translated.
Same as cardUsageObject.carNumber
.
Same as cardUsageObject.carLine
.
Same as cardUsageObject.creditSpent
.
Same as cardUsageObject.creditRemaining
.
Alright, I need to tell you this:
The code has lots of error-catchers, for easy debugging. If the static functions (anything under the non-exported class AnkaraKart.utils
) fail somehow, that is not good.
On invalid cards, the API will also return an error. This for redundancy and to support both async/await and general Promise usage.