Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

abizareyhan/trafi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Trafi Unofficial SDK

The Unofficial SDK of Trafi for PHP.

About

Installation

Install Trafi Unofficial SDK using Composer.

$ composer require abizareyhan/trafi

After updating composer, add the ServiceProvider to the providers array in config/app.php

Abizareyhan\Trafi\TrafiServiceProvider::class,

You can use the facade for shorter code:

'Trafi' => Abizareyhan\Trafi\Facades\Trafi::class,

Usage

$client = new Abizareyhan\Trafi\HTTPClient\CurlHTTPClient();
$trafi = new Abizareyhan\Trafi\Trafi($client);

//Getting Current Events
$response = $trafi->getEvents();
$events = $response->getJSONDecodedBody();

//Getting Stops inside Bounds
$bounds = new Abizareyhan\Trafi\Bounds(
  [
    -6.0537830087495905, //Top Left Latitude
    106.63549041748047 //Top Left Longitude
  ],
  [
    -6.0537830087495905, //Top Right Latitude
    107.04747772216797 //Top Right Longitude
  ],
  [
    -6.1903288844762585, //Bottom Left Latitude
    106.63549041748047 //Bottom Left Longitude
  ],
  [
    -6.1903288844762585, //Bottom Right Latitude
    107.04747772216797 //Bottom Right Longitude
  ]
);
 
$response = $trafi->getStops($bounds);
$stops = $response->getJSONDecodedBody();

//Getting Transjakarta Realtime Coordinate inside Bounds
$bounds = new Abizareyhan\Trafi\Bounds(
  [
    -6.0537830087495905, //Top Left Latitude
    106.63549041748047 //Top Left Longitude
  ],
  [
    -6.0537830087495905, //Top Right Latitude
    107.04747772216797 //Top Right Longitude
  ],
  [
    -6.1903288844762585, //Bottom Left Latitude
    106.63549041748047 //Bottom Left Longitude
  ],
  [
    -6.1903288844762585, //Bottom Right Latitude
    107.04747772216797 //Bottom Right Longitude
  ]
);
 
$response = $trafi->getTransports($bounds);
$transports = $response->getJSONDecodedBody();

About

The Unofficial Trafi SDK for Laravel

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages