Documentation
¶
Index ¶
Constants ¶
const ( APIVersion1 = iota APIVersion3 )
APIVersion supported.
const ( GrandLotoZipName = "grandloto_201912.zip" GrandLotoNoelZipName = "lotonoel_201703.zip" SuperLoto199605ZipName = "superloto_199605.zip" SuperLoto200810ZipName = "superloto_200810.zip" SuperLoto201703ZipName = "superloto_201703.zip" SuperLoto201907ZipName = "superloto_201907.zip" Loto197605ZipName = "loto_197605.zip" Loto200810ZipName = "loto_200810.zip" Loto201703ZipName = "loto_201703.zip" Loto201902ZipName = "loto_201902.zip" Loto201911ZipName = "loto_201911.zip" )
ZIP file names for the different lotto history datasets from the FDJ API. Used in the URL to fetch the source.
const ( GrandLotoV3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afg6" GrandLotoNoelV3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66aff6" SuperLoto199605V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afh6" SuperLoto200810V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afi6" SuperLoto201703V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afj6" SuperLoto201907V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afk6" Loto197605V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afl6" Loto200810V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afm6" Loto201703V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afn6" Loto201902V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afo6" Loto201911V3UUID = "1a2b3c4d-9876-4562-b3fc-2c963f66afp6" )
UUIDs for the different lotto history datasets from the FDJ API. Used in the URL to fetch the source.
const (
APIBasePath = "https://media.fdj.fr/static/csv/loto"
)
APIBasePath is the base endpoint for the FDJ history service (API V1).
const (
APIV3BasePath = "https://www.sto.api.fdj.fr/anonymous/service-draw-info/v3/documentations"
)
APIV3BasePath is the base endpoint for the FDJ history service (API V3).
Variables ¶
var ( ErrInvalidResponseHTTP = errors.New("response http is invalid") ErrInvalidHTTPRequest = errors.New("http request is invalid") ErrUnexpectedHTTPStatus = errors.New("unexpected http status code") ErrHTTPClientDo = errors.New("http client do request error") )
HTTP Errors types.
var ( ErrNoContext = errors.New("context is nil") ErrInvalidDrawType = errors.New("draw type instance is invalid") ErrInvalidCSVType = errors.New("csv type instance is invalid") ErrInvalidContextDecoder = errors.New("context decoder is invalid") ErrDrawTypeKeyNotFound = errors.New("draw type key not found in the context recorder") )
Application errors types.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
// LoadAPI loads the history source from the FDJ archive.
LoadSource(ctx context.Context, source []SourceInfo) error
// DownloadSource downloads the history source from the FDJ archive.
DownloadSource(ctx context.Context, path string, source []SourceInfo) error
// SourceUpdatedAt returns the last update time of the history source.
SourceUpdatedAt(ctx context.Context, source SourceInfo) (time.Time, error)
// LoadFile loads the history source from a file.
// source is used to know the type of the source.
// File must be a csv file with ';' separator.
LoadFile(path string, source SourceInfo) error
// NDraws returns the number of draws.
NDraws(filter Filter) int64
// Draws returns the draws depending on the filter.
Draws(filter Filter, order draw.OrderType) []draw.Draw
// DuplicatedDrawIDs returns the draws ID was considering like duplicated.
DuplicatedDrawIDs() []string
// Reset resets the draws records.
Reset()
}
API is the interface to load the history source. It can load the history source from the FDJ archive or from a file. To get a default api instance, use NewAPI function.
type APIVersion ¶ added in v1.2.0
type APIVersion int16
APIVersion is the version used to call fdj's API.
type Filter ¶
type Filter struct {
Day draw.Day
SuperLotto bool
GrandLotto bool
XmasLotto bool
ClassicLotto bool
OldLotto bool
}
Filter is the filter of draw. if day is empty, it will match all day. if old lotto is false, it will not match old lotto, otherwise it will match all. if super lotto is false, it will not match super lotto. if grand lotto is false, it will not match grand lotto. if xmas lotto is false, it will not match xmas lotto. if classic lotto is false, it will not match classic lotto. classic lotto is the default draw type (from november 2019).
type Source ¶
type Source int16
Source represents a lotto history source.
type SourceInfo ¶
type SourceInfo struct {
APIBase string
APIPath string
Type draw.Type
Version draw.Version
Name Source
}
SourceInfo contains metadata about a source. APIBase is the base URL of the source. APIPath is the path to the ZIP file containing the history from the FDJ api. Type is the draw type. Version is the draw version used for the conversion. Name identifies the source.
func GetSourceInfo ¶
func GetSourceInfo(source Source, version APIVersion) SourceInfo
GetSourceInfo returns metadata for the given source. If the source is not found, it returns the most recent source (Loto201911, November 2019).
func SourceInfoAll ¶
func SourceInfoAll(version APIVersion) []SourceInfo
SourceInfoAll returns all the source info.
func (SourceInfo) URL ¶
func (s SourceInfo) URL() string
URL returns the full URL to download the source.