Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

infogare-api.js

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

infogare-api.js - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

2

package.json
{
"name": "infogare-api.js",
"version": "1.0.13",
"version": "1.0.14",
"main": "src/core/index.js",

@@ -5,0 +5,0 @@ "scripts": {

import Station from '../modules/Station';
import { Train, TrainRER } from '../modules/Train';
import User from '../modules/User';

@@ -10,2 +11,10 @@

export declare function getStation(uid: String, stationId: String): Station;
export declare function getStation(uid: String, stationId: String): Station;
export declare function getStations(uid: String): Station[];
export declare function getStationsByFolder(uid: String, folder: String): Station[];
export declare function getTrains(uid: String, stationId: String): Train[] | TrainRER[];
export declare function getTrain(uid: String, stationId: String, trainId: String): Train | TrainRER;

@@ -326,3 +326,2 @@ const User = require('./User');

const trainJSON = await response.json();
console.assert(trainJSON.mission || !trainJSON.mission);
if (!trainJSON.mission) {

@@ -336,4 +335,40 @@ const train = new Train(trainJSON);

}
/**
* Update a train from a station
* @param {string} uid The UID of the user
* @param {string} id The station ID
* @param {string} trainId The train ID
* @param {Train} train The train
* @returns Nothing
*/
async updateTrain(uid, id, trainId, train) {
if (!uid) {
throw new Error('uid is required');
}
if (!id) {
throw new Error('id is required');
}
if (!trainId) {
throw new Error('trainId is required');
}
if (!train) {
throw new Error('train is required');
}
if (!this.appId) {
throw new Error('appId is required');
}
const response = await fetch(`${App.apiEndpoint}/user/${uid}/gares/${id}/trains/${trainId}?appId=${this.appId}`, {
method: 'PATCH',
body: JSON.stringify(train),
headers: {
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new StationException(response, 'update train ' + trainId);
}
}
}
module.exports = App;

@@ -104,2 +104,27 @@ class Train {

}
toJSON() {
return {
id: this.id,
alternance: this.alternance,
alternanceType: this.alternanceType,
arivalTime: this.arivalTime,
compo: this.compo,
customLabel: this.customLabel,
days: this.days,
delayTime: this.delayTime,
delayType: this.delayType,
departure: this.departure,
departureTime: this.departureTime,
destination: this.destination,
from: this.from,
hall: this.hall,
number: this.number,
provenance: this.provenance,
show: this.show,
to: this.to,
track: this.track,
type: this.type
}
}
}

@@ -189,4 +214,24 @@

}
toJSON() {
return {
id: this.id,
arivalTime: this.arivalTime,
delayTime: this.delayTime,
delayType: this.delayType,
departureTime: this.departureTime,
departureMode: this.departureMode,
destination: this.destination,
from: this.from,
mission: this.mission,
number: this.number,
provenance: this.provenance,
show: this.show,
to: this.to,
trainLength: this.trainLength,
type: this.type
}
}
}
module.exports = { Train, TrainRER };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc