opaler
v2.0.0
Published
Request your opal card data from opal.com.au.
Downloads
10
Readme
Opaler
Retrieve and parse information from your opal card account.
https://www.opal.com.au/
Opal cards are smartcard tickets that you keep, reload and reuse to pay for travel on public transport in the greater Sydney area of New South Wales, Australia.
Getting Started
Installing
npm install opaler
Usage
import Opaler from 'opaler';
const opaler = new Opaler('YOUR_USERNAME', 'YOUR_PASSWORD');
opaler.getCards().then(cards => {
cards.forEach(card => {
console.log(JSON.stringify(card, null, 2));
})
});
API
#getCards(): Promise<Card[]>
Card
{
cardNumber: string,
displayCardNumber: null,
fareCategoryCode: null,
fareCategoryTitle: null,
cardNickName: string,
cardState: string,
cardBalance: number,
active: boolean,
svPending: number,
toBeActivated: boolean,
displayName: string,
cardIndex: number,
currentCardBalance: number,
}
#getAccount(): Promise<Account>
Account
{
firstName: string,
lastName: string,
address: string,
dateOfBirth: string,
phoneNumber: string,
mobileNumber: string,
emailAddress: string,
nameOnCard: string,
cardType: string,
cardNumber: string,
cardExpires: string,
password: string,
opalPin: string,
securityQuestion: string,
securityAnswer: string,
}
#getOrders(): Promise<Order[]>
Order
{
orderId: string,
orderDate: string,
orderDateTimestamp: number,
cardType: string,
orderStatus: string,
}
#getTransactions(options: TransactionRequestOptions): Promise<Transaction[]>
TransactionRequestOptions
{
month?: number,
year?: number,
pageIndex?: number,
cardIndex: number,
}
month
andyear
can be used to request transactions for a specific timepageIndex
requests a certain page inside the result set if nopageIndex
is set all pages will be fetched continously. Depending on your result size this can take quite a while and is not recommended.cardIndex
refers to the cards index number within the Card[] array returned from #getCards()
Transaction
{
transactionNumber: number,
timestamp: number,
summary: string | null,
mode: string | null,
fare: {
applied: string | null,
price: number,
discount: number,
paid: number,
},
journey: {
number: number,
start: string,
end: string,
} | null,
Versioning
Opaler uses Semantic Versioning for versioning.
For the versions available, see the the published versions on npmjs.com.
License
Copyright (c) 2014 Thorsten Basse
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 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 THE SOFTWARE.