Documentation
¶
Index ¶
- func CheckErrorType(err error, EType ErrorTypes) bool
- type Brief
- type Client
- type ClientOption
- type Data
- type ErrorTypes
- type Events
- type Frequency
- type Logger
- type Properties
- type StopInfo
- type StopMetaData
- type Thread
- type TimeInfo
- type TimeInfoYandex
- type TransportInfo
- type YandexClientError
- type YandexMapError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckErrorType ¶
func CheckErrorType(err error, EType ErrorTypes) bool
Types ¶
type Brief ¶
type Brief struct { DepartureTime *string `json:"departureTime"` Events []Events `json:"Events"` Frequency Frequency `json:"Frequency"` }
Brief contains unit's schedule info. It may or may not have DepartureTime
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client interacts with yandex maps API
func New ¶
func New(opts ...ClientOption) (*Client, error)
New creates new yandexClient and gets csrfToken to be able to perform requests
func (*Client) FetchStopInfo ¶
func (c *Client) FetchStopInfo(ctx context.Context, stopID string, prognosis bool) (response StopInfo, err error)
FetchStopInfo gets stop info by specific stop id. If first request gets `invalid csrf token` response it applies it and retries
func (*Client) UpdateToken ¶
UpdateToken gets new csrfToken if needed
type ClientOption ¶
ClientOption applies options to client
func WithCsrfToken ¶
func WithCsrfToken(token string) ClientOption
func WithHost ¶
func WithHost(host string) ClientOption
func WithLocale ¶
func WithLocale(locale string) ClientOption
func WithLogger ¶
func WithLogger(l Logger) ClientOption
func WithTimeout ¶
func WithTimeout(t time.Duration) ClientOption
type ErrorTypes ¶
type ErrorTypes int
const ( ErrorUnknown ErrorTypes = iota ErrorWrongStatusCode ErrorEmptyToken )
func ExtractErrorType ¶
func ExtractErrorType(err error) ErrorTypes
type Properties ¶
type Properties struct { StopMetaData StopMetaData `json:"StopMetaData"` CurrentTime int64 `json:"currentTime"` }
Properties model
type StopInfo ¶
type StopInfo struct { CsrfToken string `json:"csrfToken,omitempty"` Error *YandexMapError `json:"error,omitempty"` Data *Data `json:"data,omitempty"` }
StopInfo contains information about incoming transport for stop and csrfToken in case server responded with refresh token demand
type StopMetaData ¶
type StopMetaData struct {
Transport []TransportInfo `json:"Transport"`
}
StopMetaData model
type TimeInfo ¶
func (*TimeInfo) UnmarshalJSON ¶
type TimeInfoYandex ¶
type TimeInfoYandex struct {
Value string `json:"value"`
}
type TransportInfo ¶
type TransportInfo struct { Name string `json:"name"` Type string `json:"type"` Threads []Thread `json:"threads"` }
TransportInfo contains departure time and route name
type YandexClientError ¶
type YandexClientError struct { Message string // contains filtered or unexported fields }
YandexClientError is an error returned by client
func NewEmptyTokenError ¶
func NewEmptyTokenError() YandexClientError
func NewWrongStatusCodeError ¶
func NewWrongStatusCodeError(gotCode int) YandexClientError
func (YandexClientError) Cause ¶
func (err YandexClientError) Cause() error
func (YandexClientError) Error ¶
func (err YandexClientError) Error() string
type YandexMapError ¶
YandexMapError reports error from service
func (*YandexMapError) Error ¶
func (e *YandexMapError) Error() string