diff --git a/database/dto.go b/database/dto.go new file mode 100644 index 0000000..7b4427e --- /dev/null +++ b/database/dto.go @@ -0,0 +1,45 @@ +package database + +import ( + "strings" + + "github.com/google/uuid" +) + +type SourceDto struct { + ID uuid.UUID `json:"id"` + Site string `json:"site"` + Name string `json:"name"` + Source string `json:"source"` + Type string `json:"type"` + Value string `json:"value"` + Enabled bool `json:"enabled"` + Url string `json:"url"` + Tags []string `json:"tags"` + Deleted bool `json:"deleted"` +} + +func ConvertToSourceDto(i Source) SourceDto { + var deleted bool + if !i.Deleted.Valid { + deleted = true + } + + return SourceDto{ + ID: i.ID, + Site: i.Site, + Name: i.Name, + Source: i.Source, + Type: i.Type, + Value: i.Value.String, + Enabled: i.Enabled, + Url: i.Url, + Tags: splitTags(i.Tags), + Deleted: deleted, + } +} + +func splitTags(t string) []string { + items := strings.Split(t, ", ") + return items +} diff --git a/docs/docs.go b/docs/docs.go index f8eba2b..cc2d5a7 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -237,15 +237,13 @@ const docTemplate = `{ } ], "responses": {} - } - }, - "/discord/webhooks/{ID}/enable": { - "post": { + }, + "delete": { "tags": [ - "Discord", - "Webhook" + "Config", + "Source" ], - "summary": "Enables a source to continue processing.", + "summary": "Deletes a record by ID.", "parameters": [ { "type": "string", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 3996964..8b80c78 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -318,13 +318,15 @@ paths: /discord/webhooks/{ID}: delete: parameters: - - description: id + - description: uuid in: path name: id required: true type: string + produces: + - application/json responses: {} - summary: Deletes a record by ID. + summary: Returns a single entity by ID tags: - Discord - Webhook diff --git a/routes/sources.go b/routes/sources.go index 6d11892..17ce56e 100644 --- a/routes/sources.go +++ b/routes/sources.go @@ -383,6 +383,7 @@ func (s *Server) newTwitchSource(w http.ResponseWriter, r *http.Request) { // DeleteSource // @Summary Marks a source as deleted based on its ID value. +// @Summary Marks a source as deleted based on its ID value. // @Param id path string true "id" // @Tags Source // @Router /sources/{id} [POST]