2017 © Pedro Peláez
 

library ns-api

Communicates with the NS api

image

wubs/ns-api

Communicates with the NS api

  • Wednesday, November 22, 2017
  • by megawubs
  • Repository
  • 1 Watchers
  • 3 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

ns-api

Laravel ns-api wrapper, (*1)

Installation

In your project root, type:, (*2)

$ composer require wubs/ns-api

After it is installed, add 'Wubs\NS\NSServiceProvider', to app/config.php in the providers array and add 'NS' => 'Wubs\NS\Facades\NS', to the aliases array, also in app/config.php., (*3)

Laravel usage

Train Stations

Receive a collection of all the train stations:, (*4)

<?php
$stations = NS::stations();

This returns a Collection of Station objects a Station object has the following properties:, (*5)

<?php
$station = $stations->first();
$station->name;
$station->code;
$station->country;
$station->lat;
$station->long;
$station->alias;

Failures

To receive a list of planned and unplanned failures:, (*6)

<?php
$failures = NS::failures(ut'); //full name or code from a station
$planned = $failures->planned; //Collection of planned failures
$unplanned = $failures->unplanned; //Collection of unplanned failures

A Failure object has the following properties:, (*7)

<?php
$failure->id;
$failure->route;
$failure->reason;
$failure->message;
$failure->date; //Carbon date object

Travel Advise

A travel advise exists of multiple objects. One Advise Object has one ore more Notification objects in a Collection alo, it has muliple Step objects. Each Step object has multiple WayPoint objects in a Collection WayPoints are the train stations that are part of your travel advise, but you don't stop there. The first and the last items in this Collection are the start and end station for that part of the travel advise., (*8)

<?php
$advises = NS::advise('Aalten', "Zurich"); //Returns a Collection with Advise objects
$advise = $advises->first();
$advise->notifications; //Collection|Notification[]
$advise->numberOfSwitches;
$advise->plannedTravelDuration;
$advise->actualTravelDuration;
$advise->departureDelay;
$advise->arrivalDelay;
$advise->optimal;
$advise->plannedDepartureTime; //Carbon
$advise->actualDepartureTime; //Carbon
$advise->plannedArrivalTime; //Carbon
$advise->actualArrivalTime; //Carbon
$advise->state;
$advise->steps; //Collection|Steps[]

$notification = $advise->notifications->first();
$notification->id;
$notification->serious;
$notification->text;

$step = $advise->steps->first();
$step->carrier;
$step->carrierType;
$step->tripNumber;
$step->status;
$step->tripDetails;
$step->plannedFailureId;
$step->unplannedFailureId;
$step->transitType;
$step->wayPoints; //Collection|WayPoint[]

$wayPoint = $step->wayPoints->first();
$wayPoint->name;
$wayPoint->time; //Carbon
$wayPoint->departureDelay;
$wayPoint->track;

The Versions

22/11 2017

dev-master

9999999-dev

Communicates with the NS api

  Sources   Download

The Requires

 

The Development Requires

api wrapper ns

22/11 2017

1.0.0

1.0.0.0

Communicates with the NS api

  Sources   Download

The Requires

 

The Development Requires

api wrapper ns

15/05 2015

0.0.13

0.0.13.0

Communicates with the NS api

  Sources   Download

The Requires

 

The Development Requires

api wrapper ns

30/04 2015

0.0.12

0.0.12.0

Communicates with the NS api

  Sources   Download

The Requires

 

The Development Requires

api wrapper ns

29/04 2015

0.0.11

0.0.11.0

Communicates with the NS api

  Sources   Download

The Requires

 

The Development Requires

api wrapper ns

22/04 2015

0.0.01

0.0.01.0

Communicates with the NS api

  Sources   Download

The Requires

 

The Development Requires

api wrapper ns