Enetpulse fixture and preodds

This commit is contained in:
Yared Yemane 2025-10-15 16:42:00 +03:00
parent e429810ebc
commit fc69ca3f52
4 changed files with 32 additions and 453 deletions

View File

@ -3058,7 +3058,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Fixtures" "EnetPulse"
], ],
"summary": "Get all stored fixtures", "summary": "Get all stored fixtures",
"responses": { "responses": {
@ -3102,7 +3102,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Fixtures" "EnetPulse"
], ],
"summary": "Get fixtures with preodds", "summary": "Get fixtures with preodds",
"responses": { "responses": {
@ -3146,7 +3146,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Preodds" "EnetPulse"
], ],
"summary": "Get all preodds", "summary": "Get all preodds",
"responses": { "responses": {
@ -3190,7 +3190,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Results" "EnetPulse"
], ],
"summary": "Get all results", "summary": "Get all results",
"responses": { "responses": {
@ -3234,7 +3234,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Sports" "EnetPulse"
], ],
"summary": "Get all sports", "summary": "Get all sports",
"responses": { "responses": {
@ -3278,7 +3278,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Tournament Stages" "EnetPulse"
], ],
"summary": "Get all tournament stages", "summary": "Get all tournament stages",
"responses": { "responses": {
@ -3322,7 +3322,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Tournament Templates" "EnetPulse"
], ],
"summary": "Get all tournament templates", "summary": "Get all tournament templates",
"responses": { "responses": {
@ -3366,7 +3366,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Tournaments" "EnetPulse"
], ],
"summary": "Get all tournaments", "summary": "Get all tournaments",
"responses": { "responses": {
@ -4300,108 +4300,6 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/odds/pre-match": {
"get": {
"description": "Fetches pre-match odds from EnetPulse for a given event",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"EnetPulse - PreMatch"
],
"summary": "Get pre-match odds for an event",
"parameters": [
{
"type": "integer",
"description": "Event ID",
"name": "objectFK",
"in": "query",
"required": true
},
{
"type": "array",
"items": {
"type": "integer"
},
"collectionFormat": "csv",
"description": "Odds provider IDs (comma separated)",
"name": "oddsProviderFK",
"in": "query"
},
{
"type": "integer",
"description": "Outcome type ID",
"name": "outcomeTypeFK",
"in": "query"
},
{
"type": "integer",
"description": "Outcome scope ID",
"name": "outcomeScopeFK",
"in": "query"
},
{
"type": "integer",
"description": "Outcome subtype ID",
"name": "outcomeSubtypeFK",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "integer",
"description": "Language type ID",
"name": "languageTypeFK",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/domain.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/domain.PreMatchOddsResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/domain.ErrorResponse"
}
},
"502": {
"description": "Bad Gateway",
"schema": {
"$ref": "#/definitions/domain.ErrorResponse"
}
}
}
}
},
"/api/v1/odds/upcoming/{upcoming_id}": { "/api/v1/odds/upcoming/{upcoming_id}": {
"get": { "get": {
"description": "Retrieve prematch odds by upcoming event ID (FI from Bet365) with optional pagination", "description": "Retrieve prematch odds by upcoming event ID (FI from Bet365) with optional pagination",
@ -12402,41 +12300,6 @@ const docTemplate = `{
} }
} }
}, },
"domain.PreMatchOddsResponse": {
"type": "object",
"properties": {
"eventFK": {
"description": "Define fields according to the Enetpulse preodds response structure\nExample:",
"type": "integer"
},
"odds": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.PreMatchOutcome"
}
}
}
},
"domain.PreMatchOutcome": {
"type": "object",
"properties": {
"oddsProviderFK": {
"type": "integer"
},
"oddsValue": {
"type": "number"
},
"outcomeFK": {
"type": "integer"
},
"outcomeTypeFK": {
"type": "integer"
},
"outcomeValue": {
"type": "string"
}
}
},
"domain.ProviderRequest": { "domain.ProviderRequest": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -3050,7 +3050,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Fixtures" "EnetPulse"
], ],
"summary": "Get all stored fixtures", "summary": "Get all stored fixtures",
"responses": { "responses": {
@ -3094,7 +3094,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Fixtures" "EnetPulse"
], ],
"summary": "Get fixtures with preodds", "summary": "Get fixtures with preodds",
"responses": { "responses": {
@ -3138,7 +3138,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Preodds" "EnetPulse"
], ],
"summary": "Get all preodds", "summary": "Get all preodds",
"responses": { "responses": {
@ -3182,7 +3182,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Results" "EnetPulse"
], ],
"summary": "Get all results", "summary": "Get all results",
"responses": { "responses": {
@ -3226,7 +3226,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Sports" "EnetPulse"
], ],
"summary": "Get all sports", "summary": "Get all sports",
"responses": { "responses": {
@ -3270,7 +3270,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Tournament Stages" "EnetPulse"
], ],
"summary": "Get all tournament stages", "summary": "Get all tournament stages",
"responses": { "responses": {
@ -3314,7 +3314,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Tournament Templates" "EnetPulse"
], ],
"summary": "Get all tournament templates", "summary": "Get all tournament templates",
"responses": { "responses": {
@ -3358,7 +3358,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"EnetPulse - Tournaments" "EnetPulse"
], ],
"summary": "Get all tournaments", "summary": "Get all tournaments",
"responses": { "responses": {
@ -4292,108 +4292,6 @@
} }
} }
}, },
"/api/v1/odds/pre-match": {
"get": {
"description": "Fetches pre-match odds from EnetPulse for a given event",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"EnetPulse - PreMatch"
],
"summary": "Get pre-match odds for an event",
"parameters": [
{
"type": "integer",
"description": "Event ID",
"name": "objectFK",
"in": "query",
"required": true
},
{
"type": "array",
"items": {
"type": "integer"
},
"collectionFormat": "csv",
"description": "Odds provider IDs (comma separated)",
"name": "oddsProviderFK",
"in": "query"
},
{
"type": "integer",
"description": "Outcome type ID",
"name": "outcomeTypeFK",
"in": "query"
},
{
"type": "integer",
"description": "Outcome scope ID",
"name": "outcomeScopeFK",
"in": "query"
},
{
"type": "integer",
"description": "Outcome subtype ID",
"name": "outcomeSubtypeFK",
"in": "query"
},
{
"type": "integer",
"description": "Limit results",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset results",
"name": "offset",
"in": "query"
},
{
"type": "integer",
"description": "Language type ID",
"name": "languageTypeFK",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/domain.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/domain.PreMatchOddsResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/domain.ErrorResponse"
}
},
"502": {
"description": "Bad Gateway",
"schema": {
"$ref": "#/definitions/domain.ErrorResponse"
}
}
}
}
},
"/api/v1/odds/upcoming/{upcoming_id}": { "/api/v1/odds/upcoming/{upcoming_id}": {
"get": { "get": {
"description": "Retrieve prematch odds by upcoming event ID (FI from Bet365) with optional pagination", "description": "Retrieve prematch odds by upcoming event ID (FI from Bet365) with optional pagination",
@ -12394,41 +12292,6 @@
} }
} }
}, },
"domain.PreMatchOddsResponse": {
"type": "object",
"properties": {
"eventFK": {
"description": "Define fields according to the Enetpulse preodds response structure\nExample:",
"type": "integer"
},
"odds": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.PreMatchOutcome"
}
}
}
},
"domain.PreMatchOutcome": {
"type": "object",
"properties": {
"oddsProviderFK": {
"type": "integer"
},
"oddsValue": {
"type": "number"
},
"outcomeFK": {
"type": "integer"
},
"outcomeTypeFK": {
"type": "integer"
},
"outcomeValue": {
"type": "string"
}
}
},
"domain.ProviderRequest": { "domain.ProviderRequest": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -1757,31 +1757,6 @@ definitions:
thumbnail: thumbnail:
type: string type: string
type: object type: object
domain.PreMatchOddsResponse:
properties:
eventFK:
description: |-
Define fields according to the Enetpulse preodds response structure
Example:
type: integer
odds:
items:
$ref: '#/definitions/domain.PreMatchOutcome'
type: array
type: object
domain.PreMatchOutcome:
properties:
oddsProviderFK:
type: integer
oddsValue:
type: number
outcomeFK:
type: integer
outcomeTypeFK:
type: integer
outcomeValue:
type: string
type: object
domain.ProviderRequest: domain.ProviderRequest:
properties: properties:
brandId: brandId:
@ -6186,7 +6161,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get all stored fixtures summary: Get all stored fixtures
tags: tags:
- EnetPulse - Fixtures - EnetPulse
/api/v1/enetpulse/fixtures/preodds: /api/v1/enetpulse/fixtures/preodds:
get: get:
consumes: consumes:
@ -6213,7 +6188,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get fixtures with preodds summary: Get fixtures with preodds
tags: tags:
- EnetPulse - Fixtures - EnetPulse
/api/v1/enetpulse/preodds: /api/v1/enetpulse/preodds:
get: get:
consumes: consumes:
@ -6239,7 +6214,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get all preodds summary: Get all preodds
tags: tags:
- EnetPulse - Preodds - EnetPulse
/api/v1/enetpulse/results: /api/v1/enetpulse/results:
get: get:
consumes: consumes:
@ -6265,7 +6240,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get all results summary: Get all results
tags: tags:
- EnetPulse - Results - EnetPulse
/api/v1/enetpulse/sports: /api/v1/enetpulse/sports:
get: get:
consumes: consumes:
@ -6291,7 +6266,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get all sports summary: Get all sports
tags: tags:
- EnetPulse - Sports - EnetPulse
/api/v1/enetpulse/tournament-stages: /api/v1/enetpulse/tournament-stages:
get: get:
consumes: consumes:
@ -6317,7 +6292,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get all tournament stages summary: Get all tournament stages
tags: tags:
- EnetPulse - Tournament Stages - EnetPulse
/api/v1/enetpulse/tournament-templates: /api/v1/enetpulse/tournament-templates:
get: get:
consumes: consumes:
@ -6343,7 +6318,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get all tournament templates summary: Get all tournament templates
tags: tags:
- EnetPulse - Tournament Templates - EnetPulse
/api/v1/enetpulse/tournaments: /api/v1/enetpulse/tournaments:
get: get:
consumes: consumes:
@ -6369,7 +6344,7 @@ paths:
$ref: '#/definitions/domain.ErrorResponse' $ref: '#/definitions/domain.ErrorResponse'
summary: Get all tournaments summary: Get all tournaments
tags: tags:
- EnetPulse - Tournaments - EnetPulse
/api/v1/events: /api/v1/events:
get: get:
consumes: consumes:
@ -6966,71 +6941,6 @@ paths:
summary: Retrieve all odds summary: Retrieve all odds
tags: tags:
- prematch - prematch
/api/v1/odds/pre-match:
get:
consumes:
- application/json
description: Fetches pre-match odds from EnetPulse for a given event
parameters:
- description: Event ID
in: query
name: objectFK
required: true
type: integer
- collectionFormat: csv
description: Odds provider IDs (comma separated)
in: query
items:
type: integer
name: oddsProviderFK
type: array
- description: Outcome type ID
in: query
name: outcomeTypeFK
type: integer
- description: Outcome scope ID
in: query
name: outcomeScopeFK
type: integer
- description: Outcome subtype ID
in: query
name: outcomeSubtypeFK
type: integer
- description: Limit results
in: query
name: limit
type: integer
- description: Offset results
in: query
name: offset
type: integer
- description: Language type ID
in: query
name: languageTypeFK
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/domain.Response'
- properties:
data:
$ref: '#/definitions/domain.PreMatchOddsResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/domain.ErrorResponse'
"502":
description: Bad Gateway
schema:
$ref: '#/definitions/domain.ErrorResponse'
summary: Get pre-match odds for an event
tags:
- EnetPulse - PreMatch
/api/v1/odds/upcoming/{upcoming_id}: /api/v1/odds/upcoming/{upcoming_id}:
get: get:
consumes: consumes:

View File

@ -9,67 +9,10 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )
// GetPreMatchOdds godoc
// @Summary Get pre-match odds for an event
// @Description Fetches pre-match odds from EnetPulse for a given event
// @Tags EnetPulse - PreMatch
// @Accept json
// @Produce json
// @Param objectFK query int true "Event ID"
// @Param oddsProviderFK query []int false "Odds provider IDs (comma separated)"
// @Param outcomeTypeFK query int false "Outcome type ID"
// @Param outcomeScopeFK query int false "Outcome scope ID"
// @Param outcomeSubtypeFK query int false "Outcome subtype ID"
// @Param limit query int false "Limit results"
// @Param offset query int false "Offset results"
// @Param languageTypeFK query int false "Language type ID"
// @Success 200 {object} domain.Response{data=domain.PreMatchOddsResponse}
// @Failure 400 {object} domain.ErrorResponse
// @Failure 502 {object} domain.ErrorResponse
// @Router /api/v1/odds/pre-match [get]
func (h *Handler) GetPreMatchOdds(c *fiber.Ctx) error {
// Parse query parameters
objectFK := c.QueryInt("objectFK")
if objectFK == 0 {
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
Message: "Event ID (objectFK) is required",
Error: "missing or invalid objectFK",
})
}
params := domain.PreMatchOddsRequest{
ObjectFK: int64(objectFK),
OddsProviderFK: intSliceToInt64Slice(parseIntSlice(c.Query("oddsProviderFK"))), // convert []int to []int64
OutcomeTypeFK: int64(c.QueryInt("outcomeTypeFK")),
OutcomeScopeFK: int64(c.QueryInt("outcomeScopeFK")),
OutcomeSubtypeFK: int64(c.QueryInt("outcomeSubtypeFK")),
Limit: c.QueryInt("limit"),
Offset: c.QueryInt("offset"),
LanguageTypeFK: int64(c.QueryInt("languageTypeFK")),
}
// Call service
res, err := h.enetPulseSvc.FetchPreMatchOdds(c.Context(), params)
if err != nil {
log.Println("FetchPreMatchOdds error:", err)
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
Message: "Failed to fetch pre-match odds",
Error: err.Error(),
})
}
return c.Status(fiber.StatusOK).JSON(domain.Response{
Message: "Pre-match odds fetched successfully",
Data: res,
StatusCode: fiber.StatusOK,
Success: true,
})
}
// GetAllSports godoc // GetAllSports godoc
// @Summary Get all sports // @Summary Get all sports
// @Description Fetches all sports stored in the database // @Description Fetches all sports stored in the database
// @Tags EnetPulse - Sports // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseSport} // @Success 200 {object} domain.Response{data=[]domain.EnetpulseSport}
@ -97,7 +40,7 @@ func (h *Handler) GetAllSports(c *fiber.Ctx) error {
// GetAllTournamentTemplates godoc // GetAllTournamentTemplates godoc
// @Summary Get all tournament templates // @Summary Get all tournament templates
// @Description Fetches all tournament templates stored in the database // @Description Fetches all tournament templates stored in the database
// @Tags EnetPulse - Tournament Templates // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseTournamentTemplate} // @Success 200 {object} domain.Response{data=[]domain.EnetpulseTournamentTemplate}
@ -125,7 +68,7 @@ func (h *Handler) GetAllTournamentTemplates(c *fiber.Ctx) error {
// GetAllTournaments godoc // GetAllTournaments godoc
// @Summary Get all tournaments // @Summary Get all tournaments
// @Description Fetches all tournaments stored in the database // @Description Fetches all tournaments stored in the database
// @Tags EnetPulse - Tournaments // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseTournament} // @Success 200 {object} domain.Response{data=[]domain.EnetpulseTournament}
@ -153,7 +96,7 @@ func (h *Handler) GetAllTournaments(c *fiber.Ctx) error {
// GetAllTournamentStages godoc // GetAllTournamentStages godoc
// @Summary Get all tournament stages // @Summary Get all tournament stages
// @Description Fetches all tournament stages stored in the database // @Description Fetches all tournament stages stored in the database
// @Tags EnetPulse - Tournament Stages // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseTournamentStage} // @Success 200 {object} domain.Response{data=[]domain.EnetpulseTournamentStage}
@ -181,7 +124,7 @@ func (h *Handler) GetAllTournamentStages(c *fiber.Ctx) error {
// GetFixturesByDate godoc // GetFixturesByDate godoc
// @Summary Get all stored fixtures // @Summary Get all stored fixtures
// @Description Fetches all fixtures stored in the database // @Description Fetches all fixtures stored in the database
// @Tags EnetPulse - Fixtures // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseFixture} // @Success 200 {object} domain.Response{data=[]domain.EnetpulseFixture}
@ -209,7 +152,7 @@ func (h *Handler) GetFixturesByDate(c *fiber.Ctx) error {
// GetAllResults godoc // GetAllResults godoc
// @Summary Get all results // @Summary Get all results
// @Description Fetches all EnetPulse match results stored in the database // @Description Fetches all EnetPulse match results stored in the database
// @Tags EnetPulse - Results // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseResult} // @Success 200 {object} domain.Response{data=[]domain.EnetpulseResult}
@ -237,7 +180,7 @@ func (h *Handler) GetAllResults(c *fiber.Ctx) error {
// GetAllPreodds godoc // GetAllPreodds godoc
// @Summary Get all preodds // @Summary Get all preodds
// @Description Fetches all EnetPulse pre-match odds stored in the database // @Description Fetches all EnetPulse pre-match odds stored in the database
// @Tags EnetPulse - Preodds // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulsePreodds} // @Success 200 {object} domain.Response{data=[]domain.EnetpulsePreodds}
@ -265,7 +208,7 @@ func (h *Handler) GetAllPreodds(c *fiber.Ctx) error {
// GetFixturesWithPreodds godoc // GetFixturesWithPreodds godoc
// @Summary Get fixtures with preodds // @Summary Get fixtures with preodds
// @Description Fetches all EnetPulse fixtures along with their associated pre-match odds // @Description Fetches all EnetPulse fixtures along with their associated pre-match odds
// @Tags EnetPulse - Fixtures // @Tags EnetPulse
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} domain.Response{data=[]domain.EnetpulseFixtureWithPreodds} // @Success 200 {object} domain.Response{data=[]domain.EnetpulseFixtureWithPreodds}