定制 wubs/ns-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wubs/ns-api

最新稳定版本:1.0.0

Composer 安装命令:

composer require wubs/ns-api

包简介

Communicates with the NS api

README 文档

README

Laravel ns-api wrapper

Installation

In your project root, type:

$ 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.

Laravel usage

Train Stations

Receive a collection of all the train stations:

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

This returns a Collection of Station objects a Station object has the following properties:

<?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:

<?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:

<?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.

<?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;

统计信息

  • 总下载量: 48
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-04-21