metronetwork

package
v0.0.0-...-69338bc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ESTACION_SELECTOR = ".estadoEstaciones > li"
View Source
const HolidayURL = "https://apis.digital.gob.cl/fl/feriados/%d/%d/%d"
View Source
const KeyValURL = "https://www.metro.cl/api/estadoRedDetalle.php"
View Source
const STATUS_SELECTOR = "#estadoRed .row.pTop30 > .col-md-12 > .row"
View Source
const TimeURL = "https://www.metro.cl/api/horariosEstacion.php?cod=%s"
View Source
const URL = "https://metro.cl/tu-viaje/estado-red"

Variables

View Source
var ToStatusCode = map[string]StatusCode{
	"estado1": 0,
	"estado2": 1,
	"estado3": 2,
	"estado4": 3,
}

Functions

This section is empty.

Types

type CompositeTime

type CompositeTime struct {
	Open  WeekTime `json:"open"`
	Close WeekTime `json:"close"`
}

func (*CompositeTime) IsClosed

func (ct *CompositeTime) IsClosed(isHoliday bool) (bool, error)

type DayResponse

type DayResponse struct {
	LunesViernes string `json:"lunes_viernes"`
	Sabado       string `json:"sabado"`
	Domingo      string `json:"domingo"`
}

type KeyValResponse

type KeyValResponse map[string]struct {
	Estaciones []struct {
		Nombre string `json:"nombre"`
		Codigo string `json:"codigo"`
	} `json:"estaciones"`
}

type LineResponse

type LineResponse struct {
	Name                     string             `json:"name"`
	ID                       string             `json:"id"`
	Issues                   bool               `json:"issues"`
	StationsClosedBySchedule int                `json:"stations_closed_by_schedule"`
	Stations                 []*StationResponse `json:"stations"`
}

type OpenCloseResponse

type OpenCloseResponse struct {
	Abrir  DayResponse `json:"abrir"`
	Cerrar DayResponse `json:"cerrar"`
}

type Parser

type Parser struct {
	HTTPRequest  http.Request
	StationTimes map[string]*CompositeTime
	IsHoliday    bool
}

func (*Parser) GetCronTasks

func (p *Parser) GetCronTasks() []*common.CronTask

func (*Parser) GetRoute

func (bp *Parser) GetRoute() string

func (*Parser) Parse

func (bp *Parser) Parse(c *gin.Context)

func (*Parser) StartParser

func (bp *Parser) StartParser()

func (*Parser) StopParser

func (bp *Parser) StopParser()

type Response

type Response struct {
	APIStatus string          `json:"api_status"`
	Time      string          `json:"time"`
	Issues    bool            `json:"issues"`
	Lines     []*LineResponse `json:"lines"`
}

type ScheduleResponse

type ScheduleResponse struct {
	Estacion OpenCloseResponse `json:"estacion"`
}

type StationResponse

type StationResponse struct {
	Name               string         `json:"name"`
	ID                 string         `json:"id"`
	Status             StatusCode     `json:"status"`
	Lines              []string       `json:"lines,omitempty"`
	Description        string         `json:"description,omitempty"`
	Reason             string         `json:"reason,omitempty"`
	IsClosedBySchedule bool           `json:"is_closed_by_schedule"`
	Schedule           *CompositeTime `json:"schedule"`
}

type StatusCode

type StatusCode int

type WeekTime

type WeekTime struct {
	Weekdays string `json:"weekdays"`
	Saturday string `json:"saturday"`
	Holidays string `json:"holidays"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL