diff --git a/.gitignore b/.gitignore index 29a5f2f..659e393 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ dev.session.sql __debug_bin server .vscode +openapi.json # Binaries for programs and plugins *.exe @@ -12,6 +13,7 @@ server *.dylib collector newsbot.db +tmp/ # Test binary, built with `go test -c` *.test diff --git a/api/api.gen.go b/api/api.gen.go new file mode 100644 index 0000000..8931148 --- /dev/null +++ b/api/api.gen.go @@ -0,0 +1,3756 @@ +// Package api provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. +package api + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/oapi-codegen/runtime" +) + +const ( + BearerScopes = "Bearer.Scopes" +) + +// DomainArticleAndSourceModel defines model for domain.ArticleAndSourceModel. +type DomainArticleAndSourceModel struct { + Article *DomainArticleDto `json:"article,omitempty"` + Source *DomainSourceDto `json:"source,omitempty"` +} + +// DomainArticleDetailedResponse defines model for domain.ArticleDetailedResponse. +type DomainArticleDetailedResponse struct { + IsError *bool `json:"isError,omitempty"` + Message *string `json:"message,omitempty"` + Payload *DomainArticleAndSourceModel `json:"payload,omitempty"` +} + +// DomainArticleDto defines model for domain.ArticleDto. +type DomainArticleDto struct { + AuthorImage *string `json:"authorImage,omitempty"` + AuthorName *string `json:"authorName,omitempty"` + Description *string `json:"description,omitempty"` + Id *int `json:"id,omitempty"` + IsVideo *bool `json:"isVideo,omitempty"` + PubDate *string `json:"pubDate,omitempty"` + SourceId *int `json:"sourceId,omitempty"` + Tags *string `json:"tags,omitempty"` + Thumbnail *string `json:"thumbnail,omitempty"` + Title *string `json:"title,omitempty"` + Url *string `json:"url,omitempty"` +} + +// DomainArticleResponse defines model for domain.ArticleResponse. +type DomainArticleResponse struct { + IsError *bool `json:"isError,omitempty"` + Message *string `json:"message,omitempty"` + Payload *[]DomainArticleDto `json:"payload,omitempty"` +} + +// DomainBaseResponse defines model for domain.BaseResponse. +type DomainBaseResponse struct { + IsError *bool `json:"isError,omitempty"` + Message *string `json:"message,omitempty"` +} + +// DomainDiscordWebHookDto defines model for domain.DiscordWebHookDto. +type DomainDiscordWebHookDto struct { + Channel *string `json:"channel,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Id *int `json:"id,omitempty"` + Server *string `json:"server,omitempty"` + + // Url Name string `json:"name"` + // Key string `json:"key"` + Url *string `json:"url,omitempty"` +} + +// DomainDiscordWebhookResponse defines model for domain.DiscordWebhookResponse. +type DomainDiscordWebhookResponse struct { + IsError *bool `json:"isError,omitempty"` + Message *string `json:"message,omitempty"` + Payload *[]DomainDiscordWebHookDto `json:"payload,omitempty"` +} + +// DomainLoginResponse defines model for domain.LoginResponse. +type DomainLoginResponse struct { + IsError *bool `json:"isError,omitempty"` + Message *string `json:"message,omitempty"` + RefreshToken *string `json:"refreshToken,omitempty"` + Token *string `json:"token,omitempty"` + Type *string `json:"type,omitempty"` +} + +// DomainNewSourceParamRequest defines model for domain.NewSourceParamRequest. +type DomainNewSourceParamRequest struct { + Name *string `json:"name,omitempty"` + Tags *string `json:"tags,omitempty"` + Url *string `json:"url,omitempty"` +} + +// DomainRefreshTokenRequest defines model for domain.RefreshTokenRequest. +type DomainRefreshTokenRequest struct { + RefreshToken *string `json:"refreshToken,omitempty"` + Username *string `json:"username,omitempty"` +} + +// DomainSourceDto defines model for domain.SourceDto. +type DomainSourceDto struct { + Enabled *bool `json:"enabled,omitempty"` + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Source *string `json:"source,omitempty"` + Tags *string `json:"tags,omitempty"` + Url *string `json:"url,omitempty"` +} + +// DomainSourcesResponse defines model for domain.SourcesResponse. +type DomainSourcesResponse struct { + IsError *bool `json:"isError,omitempty"` + Message *string `json:"message,omitempty"` + Payload *[]DomainSourceDto `json:"payload,omitempty"` +} + +// DomainUpdateScopesRequest defines model for domain.UpdateScopesRequest. +type DomainUpdateScopesRequest struct { + Scopes []string `json:"scopes"` + Username *string `json:"username,omitempty"` +} + +// GetV1ArticlesParams defines parameters for GetV1Articles. +type GetV1ArticlesParams struct { + // Page page number + Page int `form:"page" json:"page"` +} + +// GetV1ArticlesBySourceIdParams defines parameters for GetV1ArticlesBySourceId. +type GetV1ArticlesBySourceIdParams struct { + // Page Page to query + Page *int `form:"page,omitempty" json:"page,omitempty"` +} + +// GetV1DiscordWebhooksByServerAndChannelParams defines parameters for GetV1DiscordWebhooksByServerAndChannel. +type GetV1DiscordWebhooksByServerAndChannelParams struct { + // Server Fancy Server + Server string `form:"server" json:"server"` + + // Channel memes + Channel string `form:"channel" json:"channel"` +} + +// PostV1DiscordWebhooksNewParams defines parameters for PostV1DiscordWebhooksNew. +type PostV1DiscordWebhooksNewParams struct { + // Url url + Url string `form:"url" json:"url"` + + // Server Server name + Server string `form:"server" json:"server"` + + // Channel Channel name + Channel string `form:"channel" json:"channel"` +} + +// GetV1SourcesParams defines parameters for GetV1Sources. +type GetV1SourcesParams struct { + // Page page number + Page *string `form:"page,omitempty" json:"page,omitempty"` +} + +// GetV1SourcesBySourceParams defines parameters for GetV1SourcesBySource. +type GetV1SourcesBySourceParams struct { + // Source Source Name + Source string `form:"source" json:"source"` + + // Page page number + Page *string `form:"page,omitempty" json:"page,omitempty"` +} + +// GetV1SourcesBySourceAndNameParams defines parameters for GetV1SourcesBySourceAndName. +type GetV1SourcesBySourceAndNameParams struct { + // Name dadjokes + Name string `form:"name" json:"name"` + + // Source reddit + Source string `form:"source" json:"source"` +} + +// PostV1SourcesNewRedditParams defines parameters for PostV1SourcesNewReddit. +type PostV1SourcesNewRedditParams struct { + // Name name + Name string `form:"name" json:"name"` + + // Url url + Url string `form:"url" json:"url"` +} + +// PostV1SourcesNewTwitchParams defines parameters for PostV1SourcesNewTwitch. +type PostV1SourcesNewTwitchParams struct { + // Name name + Name string `form:"name" json:"name"` +} + +// PostV1SourcesNewYoutubeParams defines parameters for PostV1SourcesNewYoutube. +type PostV1SourcesNewYoutubeParams struct { + // Name name + Name string `form:"name" json:"name"` + + // Url url + Url string `form:"url" json:"url"` +} + +// PostV1UsersLoginMultipartBody defines parameters for PostV1UsersLogin. +type PostV1UsersLoginMultipartBody struct { + Password *string `json:"password,omitempty"` + Username *string `json:"username,omitempty"` +} + +// PostV1UsersRegisterMultipartBody defines parameters for PostV1UsersRegister. +type PostV1UsersRegisterMultipartBody struct { + Password *string `json:"password,omitempty"` + Username *string `json:"username,omitempty"` +} + +// PostV1UsersLoginMultipartRequestBody defines body for PostV1UsersLogin for multipart/form-data ContentType. +type PostV1UsersLoginMultipartRequestBody PostV1UsersLoginMultipartBody + +// PostV1UsersRegisterMultipartRequestBody defines body for PostV1UsersRegister for multipart/form-data ContentType. +type PostV1UsersRegisterMultipartRequestBody PostV1UsersRegisterMultipartBody + +// PostV1UsersScopesAddJSONRequestBody defines body for PostV1UsersScopesAdd for application/json ContentType. +type PostV1UsersScopesAddJSONRequestBody = DomainUpdateScopesRequest + +// PostV1UsersScopesRemoveJSONRequestBody defines body for PostV1UsersScopesRemove for application/json ContentType. +type PostV1UsersScopesRemoveJSONRequestBody = DomainUpdateScopesRequest + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // GetV1Articles request + GetV1Articles(ctx context.Context, params *GetV1ArticlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1ArticlesBySourceId request + GetV1ArticlesBySourceId(ctx context.Context, id string, params *GetV1ArticlesBySourceIdParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1ArticlesId request + GetV1ArticlesId(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1ArticlesIdDetails request + GetV1ArticlesIdDetails(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1DiscordWebhooks request + GetV1DiscordWebhooks(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1DiscordWebhooksByServerAndChannel request + GetV1DiscordWebhooksByServerAndChannel(ctx context.Context, params *GetV1DiscordWebhooksByServerAndChannelParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1DiscordWebhooksNew request + PostV1DiscordWebhooksNew(ctx context.Context, params *PostV1DiscordWebhooksNewParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteV1DiscordWebhooksId request + DeleteV1DiscordWebhooksId(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1DiscordWebhooksId request + GetV1DiscordWebhooksId(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1DiscordWebhooksIdDisable request + PostV1DiscordWebhooksIdDisable(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1DiscordWebhooksIdEnable request + PostV1DiscordWebhooksIdEnable(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1Sources request + GetV1Sources(ctx context.Context, params *GetV1SourcesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1SourcesBySource request + GetV1SourcesBySource(ctx context.Context, params *GetV1SourcesBySourceParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1SourcesBySourceAndName request + GetV1SourcesBySourceAndName(ctx context.Context, params *GetV1SourcesBySourceAndNameParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1SourcesNewReddit request + PostV1SourcesNewReddit(ctx context.Context, params *PostV1SourcesNewRedditParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1SourcesNewRssWithBody request with any body + PostV1SourcesNewRssWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1SourcesNewTwitch request + PostV1SourcesNewTwitch(ctx context.Context, params *PostV1SourcesNewTwitchParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1SourcesNewYoutube request + PostV1SourcesNewYoutube(ctx context.Context, params *PostV1SourcesNewYoutubeParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetV1SourcesId request + GetV1SourcesId(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1SourcesId request + PostV1SourcesId(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1SourcesIdDisable request + PostV1SourcesIdDisable(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1SourcesIdEnable request + PostV1SourcesIdEnable(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1UsersLoginWithBody request with any body + PostV1UsersLoginWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1UsersRefreshSessionToken request + PostV1UsersRefreshSessionToken(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1UsersRefreshTokenWithBody request with any body + PostV1UsersRefreshTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1UsersRegisterWithBody request with any body + PostV1UsersRegisterWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1UsersScopesAddWithBody request with any body + PostV1UsersScopesAddWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostV1UsersScopesAdd(ctx context.Context, body PostV1UsersScopesAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostV1UsersScopesRemoveWithBody request with any body + PostV1UsersScopesRemoveWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostV1UsersScopesRemove(ctx context.Context, body PostV1UsersScopesRemoveJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) GetV1Articles(ctx context.Context, params *GetV1ArticlesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1ArticlesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1ArticlesBySourceId(ctx context.Context, id string, params *GetV1ArticlesBySourceIdParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1ArticlesBySourceIdRequest(c.Server, id, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1ArticlesId(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1ArticlesIdRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1ArticlesIdDetails(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1ArticlesIdDetailsRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1DiscordWebhooks(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1DiscordWebhooksRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1DiscordWebhooksByServerAndChannel(ctx context.Context, params *GetV1DiscordWebhooksByServerAndChannelParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1DiscordWebhooksByServerAndChannelRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1DiscordWebhooksNew(ctx context.Context, params *PostV1DiscordWebhooksNewParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1DiscordWebhooksNewRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteV1DiscordWebhooksId(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteV1DiscordWebhooksIdRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1DiscordWebhooksId(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1DiscordWebhooksIdRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1DiscordWebhooksIdDisable(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1DiscordWebhooksIdDisableRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1DiscordWebhooksIdEnable(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1DiscordWebhooksIdEnableRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1Sources(ctx context.Context, params *GetV1SourcesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1SourcesRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1SourcesBySource(ctx context.Context, params *GetV1SourcesBySourceParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1SourcesBySourceRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1SourcesBySourceAndName(ctx context.Context, params *GetV1SourcesBySourceAndNameParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1SourcesBySourceAndNameRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1SourcesNewReddit(ctx context.Context, params *PostV1SourcesNewRedditParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1SourcesNewRedditRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1SourcesNewRssWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1SourcesNewRssRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1SourcesNewTwitch(ctx context.Context, params *PostV1SourcesNewTwitchParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1SourcesNewTwitchRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1SourcesNewYoutube(ctx context.Context, params *PostV1SourcesNewYoutubeParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1SourcesNewYoutubeRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetV1SourcesId(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetV1SourcesIdRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1SourcesId(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1SourcesIdRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1SourcesIdDisable(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1SourcesIdDisableRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1SourcesIdEnable(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1SourcesIdEnableRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersLoginWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersLoginRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersRefreshSessionToken(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersRefreshSessionTokenRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersRefreshTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersRefreshTokenRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersRegisterWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersRegisterRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersScopesAddWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersScopesAddRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersScopesAdd(ctx context.Context, body PostV1UsersScopesAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersScopesAddRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersScopesRemoveWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersScopesRemoveRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostV1UsersScopesRemove(ctx context.Context, body PostV1UsersScopesRemoveJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostV1UsersScopesRemoveRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewGetV1ArticlesRequest generates requests for GetV1Articles +func NewGetV1ArticlesRequest(server string, params *GetV1ArticlesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/articles") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "page", runtime.ParamLocationQuery, params.Page); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1ArticlesBySourceIdRequest generates requests for GetV1ArticlesBySourceId +func NewGetV1ArticlesBySourceIdRequest(server string, id string, params *GetV1ArticlesBySourceIdParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/articles/by/source/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Page != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "page", runtime.ParamLocationQuery, *params.Page); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1ArticlesIdRequest generates requests for GetV1ArticlesId +func NewGetV1ArticlesIdRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/articles/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1ArticlesIdDetailsRequest generates requests for GetV1ArticlesIdDetails +func NewGetV1ArticlesIdDetailsRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/articles/%s/details", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1DiscordWebhooksRequest generates requests for GetV1DiscordWebhooks +func NewGetV1DiscordWebhooksRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/discord/webhooks") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1DiscordWebhooksByServerAndChannelRequest generates requests for GetV1DiscordWebhooksByServerAndChannel +func NewGetV1DiscordWebhooksByServerAndChannelRequest(server string, params *GetV1DiscordWebhooksByServerAndChannelParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/discord/webhooks/by/serverAndChannel") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "server", runtime.ParamLocationQuery, params.Server); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "channel", runtime.ParamLocationQuery, params.Channel); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1DiscordWebhooksNewRequest generates requests for PostV1DiscordWebhooksNew +func NewPostV1DiscordWebhooksNewRequest(server string, params *PostV1DiscordWebhooksNewParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/discord/webhooks/new") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "url", runtime.ParamLocationQuery, params.Url); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "server", runtime.ParamLocationQuery, params.Server); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "channel", runtime.ParamLocationQuery, params.Channel); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteV1DiscordWebhooksIdRequest generates requests for DeleteV1DiscordWebhooksId +func NewDeleteV1DiscordWebhooksIdRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/discord/webhooks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1DiscordWebhooksIdRequest generates requests for GetV1DiscordWebhooksId +func NewGetV1DiscordWebhooksIdRequest(server string, id int) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/discord/webhooks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1DiscordWebhooksIdDisableRequest generates requests for PostV1DiscordWebhooksIdDisable +func NewPostV1DiscordWebhooksIdDisableRequest(server string, id int) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/discord/webhooks/%s/disable", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1DiscordWebhooksIdEnableRequest generates requests for PostV1DiscordWebhooksIdEnable +func NewPostV1DiscordWebhooksIdEnableRequest(server string, id int) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/discord/webhooks/%s/enable", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1SourcesRequest generates requests for GetV1Sources +func NewGetV1SourcesRequest(server string, params *GetV1SourcesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Page != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "page", runtime.ParamLocationQuery, *params.Page); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1SourcesBySourceRequest generates requests for GetV1SourcesBySource +func NewGetV1SourcesBySourceRequest(server string, params *GetV1SourcesBySourceParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/by/source") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "source", runtime.ParamLocationQuery, params.Source); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.Page != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "page", runtime.ParamLocationQuery, *params.Page); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1SourcesBySourceAndNameRequest generates requests for GetV1SourcesBySourceAndName +func NewGetV1SourcesBySourceAndNameRequest(server string, params *GetV1SourcesBySourceAndNameParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/by/sourceAndName") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, params.Name); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "source", runtime.ParamLocationQuery, params.Source); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1SourcesNewRedditRequest generates requests for PostV1SourcesNewReddit +func NewPostV1SourcesNewRedditRequest(server string, params *PostV1SourcesNewRedditParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/new/reddit") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, params.Name); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "url", runtime.ParamLocationQuery, params.Url); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1SourcesNewRssRequestWithBody generates requests for PostV1SourcesNewRss with any type of body +func NewPostV1SourcesNewRssRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/new/rss") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostV1SourcesNewTwitchRequest generates requests for PostV1SourcesNewTwitch +func NewPostV1SourcesNewTwitchRequest(server string, params *PostV1SourcesNewTwitchParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/new/twitch") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, params.Name); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1SourcesNewYoutubeRequest generates requests for PostV1SourcesNewYoutube +func NewPostV1SourcesNewYoutubeRequest(server string, params *PostV1SourcesNewYoutubeParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/new/youtube") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, params.Name); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "url", runtime.ParamLocationQuery, params.Url); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetV1SourcesIdRequest generates requests for GetV1SourcesId +func NewGetV1SourcesIdRequest(server string, id int) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1SourcesIdRequest generates requests for PostV1SourcesId +func NewPostV1SourcesIdRequest(server string, id int) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1SourcesIdDisableRequest generates requests for PostV1SourcesIdDisable +func NewPostV1SourcesIdDisableRequest(server string, id int) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/%s/disable", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1SourcesIdEnableRequest generates requests for PostV1SourcesIdEnable +func NewPostV1SourcesIdEnableRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/sources/%s/enable", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1UsersLoginRequestWithBody generates requests for PostV1UsersLogin with any type of body +func NewPostV1UsersLoginRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/users/login") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostV1UsersRefreshSessionTokenRequest generates requests for PostV1UsersRefreshSessionToken +func NewPostV1UsersRefreshSessionTokenRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/users/refresh/sessionToken") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPostV1UsersRefreshTokenRequestWithBody generates requests for PostV1UsersRefreshToken with any type of body +func NewPostV1UsersRefreshTokenRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/users/refresh/token") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostV1UsersRegisterRequestWithBody generates requests for PostV1UsersRegister with any type of body +func NewPostV1UsersRegisterRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/users/register") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostV1UsersScopesAddRequest calls the generic PostV1UsersScopesAdd builder with application/json body +func NewPostV1UsersScopesAddRequest(server string, body PostV1UsersScopesAddJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostV1UsersScopesAddRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostV1UsersScopesAddRequestWithBody generates requests for PostV1UsersScopesAdd with any type of body +func NewPostV1UsersScopesAddRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/users/scopes/add") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostV1UsersScopesRemoveRequest calls the generic PostV1UsersScopesRemove builder with application/json body +func NewPostV1UsersScopesRemoveRequest(server string, body PostV1UsersScopesRemoveJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostV1UsersScopesRemoveRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostV1UsersScopesRemoveRequestWithBody generates requests for PostV1UsersScopesRemove with any type of body +func NewPostV1UsersScopesRemoveRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/users/scopes/remove") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // GetV1ArticlesWithResponse request + GetV1ArticlesWithResponse(ctx context.Context, params *GetV1ArticlesParams, reqEditors ...RequestEditorFn) (*GetV1ArticlesResponse, error) + + // GetV1ArticlesBySourceIdWithResponse request + GetV1ArticlesBySourceIdWithResponse(ctx context.Context, id string, params *GetV1ArticlesBySourceIdParams, reqEditors ...RequestEditorFn) (*GetV1ArticlesBySourceIdResponse, error) + + // GetV1ArticlesIdWithResponse request + GetV1ArticlesIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetV1ArticlesIdResponse, error) + + // GetV1ArticlesIdDetailsWithResponse request + GetV1ArticlesIdDetailsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetV1ArticlesIdDetailsResponse, error) + + // GetV1DiscordWebhooksWithResponse request + GetV1DiscordWebhooksWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetV1DiscordWebhooksResponse, error) + + // GetV1DiscordWebhooksByServerAndChannelWithResponse request + GetV1DiscordWebhooksByServerAndChannelWithResponse(ctx context.Context, params *GetV1DiscordWebhooksByServerAndChannelParams, reqEditors ...RequestEditorFn) (*GetV1DiscordWebhooksByServerAndChannelResponse, error) + + // PostV1DiscordWebhooksNewWithResponse request + PostV1DiscordWebhooksNewWithResponse(ctx context.Context, params *PostV1DiscordWebhooksNewParams, reqEditors ...RequestEditorFn) (*PostV1DiscordWebhooksNewResponse, error) + + // DeleteV1DiscordWebhooksIdWithResponse request + DeleteV1DiscordWebhooksIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteV1DiscordWebhooksIdResponse, error) + + // GetV1DiscordWebhooksIdWithResponse request + GetV1DiscordWebhooksIdWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*GetV1DiscordWebhooksIdResponse, error) + + // PostV1DiscordWebhooksIdDisableWithResponse request + PostV1DiscordWebhooksIdDisableWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1DiscordWebhooksIdDisableResponse, error) + + // PostV1DiscordWebhooksIdEnableWithResponse request + PostV1DiscordWebhooksIdEnableWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1DiscordWebhooksIdEnableResponse, error) + + // GetV1SourcesWithResponse request + GetV1SourcesWithResponse(ctx context.Context, params *GetV1SourcesParams, reqEditors ...RequestEditorFn) (*GetV1SourcesResponse, error) + + // GetV1SourcesBySourceWithResponse request + GetV1SourcesBySourceWithResponse(ctx context.Context, params *GetV1SourcesBySourceParams, reqEditors ...RequestEditorFn) (*GetV1SourcesBySourceResponse, error) + + // GetV1SourcesBySourceAndNameWithResponse request + GetV1SourcesBySourceAndNameWithResponse(ctx context.Context, params *GetV1SourcesBySourceAndNameParams, reqEditors ...RequestEditorFn) (*GetV1SourcesBySourceAndNameResponse, error) + + // PostV1SourcesNewRedditWithResponse request + PostV1SourcesNewRedditWithResponse(ctx context.Context, params *PostV1SourcesNewRedditParams, reqEditors ...RequestEditorFn) (*PostV1SourcesNewRedditResponse, error) + + // PostV1SourcesNewRssWithBodyWithResponse request with any body + PostV1SourcesNewRssWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1SourcesNewRssResponse, error) + + // PostV1SourcesNewTwitchWithResponse request + PostV1SourcesNewTwitchWithResponse(ctx context.Context, params *PostV1SourcesNewTwitchParams, reqEditors ...RequestEditorFn) (*PostV1SourcesNewTwitchResponse, error) + + // PostV1SourcesNewYoutubeWithResponse request + PostV1SourcesNewYoutubeWithResponse(ctx context.Context, params *PostV1SourcesNewYoutubeParams, reqEditors ...RequestEditorFn) (*PostV1SourcesNewYoutubeResponse, error) + + // GetV1SourcesIdWithResponse request + GetV1SourcesIdWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*GetV1SourcesIdResponse, error) + + // PostV1SourcesIdWithResponse request + PostV1SourcesIdWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1SourcesIdResponse, error) + + // PostV1SourcesIdDisableWithResponse request + PostV1SourcesIdDisableWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1SourcesIdDisableResponse, error) + + // PostV1SourcesIdEnableWithResponse request + PostV1SourcesIdEnableWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*PostV1SourcesIdEnableResponse, error) + + // PostV1UsersLoginWithBodyWithResponse request with any body + PostV1UsersLoginWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersLoginResponse, error) + + // PostV1UsersRefreshSessionTokenWithResponse request + PostV1UsersRefreshSessionTokenWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostV1UsersRefreshSessionTokenResponse, error) + + // PostV1UsersRefreshTokenWithBodyWithResponse request with any body + PostV1UsersRefreshTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersRefreshTokenResponse, error) + + // PostV1UsersRegisterWithBodyWithResponse request with any body + PostV1UsersRegisterWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersRegisterResponse, error) + + // PostV1UsersScopesAddWithBodyWithResponse request with any body + PostV1UsersScopesAddWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersScopesAddResponse, error) + + PostV1UsersScopesAddWithResponse(ctx context.Context, body PostV1UsersScopesAddJSONRequestBody, reqEditors ...RequestEditorFn) (*PostV1UsersScopesAddResponse, error) + + // PostV1UsersScopesRemoveWithBodyWithResponse request with any body + PostV1UsersScopesRemoveWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersScopesRemoveResponse, error) + + PostV1UsersScopesRemoveWithResponse(ctx context.Context, body PostV1UsersScopesRemoveJSONRequestBody, reqEditors ...RequestEditorFn) (*PostV1UsersScopesRemoveResponse, error) +} + +type GetV1ArticlesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainArticleResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1ArticlesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1ArticlesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1ArticlesBySourceIdResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainArticleResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1ArticlesBySourceIdResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1ArticlesBySourceIdResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1ArticlesIdResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainArticleResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1ArticlesIdResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1ArticlesIdResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1ArticlesIdDetailsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainArticleDetailedResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1ArticlesIdDetailsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1ArticlesIdDetailsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1DiscordWebhooksResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainDiscordWebhookResponse + JSON400 *DomainDiscordWebhookResponse + JSON500 *DomainDiscordWebhookResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1DiscordWebhooksResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1DiscordWebhooksResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1DiscordWebhooksByServerAndChannelResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainDiscordWebhookResponse + JSON400 *DomainDiscordWebhookResponse + JSON500 *DomainDiscordWebhookResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1DiscordWebhooksByServerAndChannelResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1DiscordWebhooksByServerAndChannelResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1DiscordWebhooksNewResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1DiscordWebhooksNewResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1DiscordWebhooksNewResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteV1DiscordWebhooksIdResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r DeleteV1DiscordWebhooksIdResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteV1DiscordWebhooksIdResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1DiscordWebhooksIdResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainDiscordWebhookResponse + JSON400 *DomainDiscordWebhookResponse + JSON500 *DomainDiscordWebhookResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1DiscordWebhooksIdResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1DiscordWebhooksIdResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1DiscordWebhooksIdDisableResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1DiscordWebhooksIdDisableResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1DiscordWebhooksIdDisableResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1DiscordWebhooksIdEnableResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1DiscordWebhooksIdEnableResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1DiscordWebhooksIdEnableResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1SourcesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainSourcesResponse + JSON400 *DomainSourcesResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1SourcesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1SourcesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1SourcesBySourceResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainSourcesResponse + JSON400 *DomainSourcesResponse + JSON500 *DomainSourcesResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1SourcesBySourceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1SourcesBySourceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1SourcesBySourceAndNameResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainSourcesResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1SourcesBySourceAndNameResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1SourcesBySourceAndNameResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1SourcesNewRedditResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1SourcesNewRedditResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1SourcesNewRedditResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1SourcesNewRssResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1SourcesNewRssResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1SourcesNewRssResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1SourcesNewTwitchResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1SourcesNewTwitchResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1SourcesNewTwitchResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1SourcesNewYoutubeResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1SourcesNewYoutubeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1SourcesNewYoutubeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetV1SourcesIdResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainSourcesResponse + JSON400 *DomainSourcesResponse + JSON500 *DomainSourcesResponse +} + +// Status returns HTTPResponse.Status +func (r GetV1SourcesIdResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetV1SourcesIdResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1SourcesIdResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1SourcesIdResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1SourcesIdResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1SourcesIdDisableResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1SourcesIdDisableResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1SourcesIdDisableResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1SourcesIdEnableResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1SourcesIdEnableResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1SourcesIdEnableResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1UsersLoginResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainLoginResponse + JSON400 *DomainLoginResponse + JSON500 *DomainLoginResponse +} + +// Status returns HTTPResponse.Status +func (r PostV1UsersLoginResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1UsersLoginResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1UsersRefreshSessionTokenResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainBaseResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r PostV1UsersRefreshSessionTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1UsersRefreshSessionTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1UsersRefreshTokenResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PostV1UsersRefreshTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1UsersRefreshTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1UsersRegisterResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *DomainBaseResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r PostV1UsersRegisterResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1UsersRegisterResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1UsersScopesAddResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainBaseResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r PostV1UsersScopesAddResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1UsersScopesAddResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostV1UsersScopesRemoveResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DomainBaseResponse + JSON400 *DomainBaseResponse + JSON500 *DomainBaseResponse +} + +// Status returns HTTPResponse.Status +func (r PostV1UsersScopesRemoveResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostV1UsersScopesRemoveResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// GetV1ArticlesWithResponse request returning *GetV1ArticlesResponse +func (c *ClientWithResponses) GetV1ArticlesWithResponse(ctx context.Context, params *GetV1ArticlesParams, reqEditors ...RequestEditorFn) (*GetV1ArticlesResponse, error) { + rsp, err := c.GetV1Articles(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1ArticlesResponse(rsp) +} + +// GetV1ArticlesBySourceIdWithResponse request returning *GetV1ArticlesBySourceIdResponse +func (c *ClientWithResponses) GetV1ArticlesBySourceIdWithResponse(ctx context.Context, id string, params *GetV1ArticlesBySourceIdParams, reqEditors ...RequestEditorFn) (*GetV1ArticlesBySourceIdResponse, error) { + rsp, err := c.GetV1ArticlesBySourceId(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1ArticlesBySourceIdResponse(rsp) +} + +// GetV1ArticlesIdWithResponse request returning *GetV1ArticlesIdResponse +func (c *ClientWithResponses) GetV1ArticlesIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetV1ArticlesIdResponse, error) { + rsp, err := c.GetV1ArticlesId(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1ArticlesIdResponse(rsp) +} + +// GetV1ArticlesIdDetailsWithResponse request returning *GetV1ArticlesIdDetailsResponse +func (c *ClientWithResponses) GetV1ArticlesIdDetailsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetV1ArticlesIdDetailsResponse, error) { + rsp, err := c.GetV1ArticlesIdDetails(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1ArticlesIdDetailsResponse(rsp) +} + +// GetV1DiscordWebhooksWithResponse request returning *GetV1DiscordWebhooksResponse +func (c *ClientWithResponses) GetV1DiscordWebhooksWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetV1DiscordWebhooksResponse, error) { + rsp, err := c.GetV1DiscordWebhooks(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1DiscordWebhooksResponse(rsp) +} + +// GetV1DiscordWebhooksByServerAndChannelWithResponse request returning *GetV1DiscordWebhooksByServerAndChannelResponse +func (c *ClientWithResponses) GetV1DiscordWebhooksByServerAndChannelWithResponse(ctx context.Context, params *GetV1DiscordWebhooksByServerAndChannelParams, reqEditors ...RequestEditorFn) (*GetV1DiscordWebhooksByServerAndChannelResponse, error) { + rsp, err := c.GetV1DiscordWebhooksByServerAndChannel(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1DiscordWebhooksByServerAndChannelResponse(rsp) +} + +// PostV1DiscordWebhooksNewWithResponse request returning *PostV1DiscordWebhooksNewResponse +func (c *ClientWithResponses) PostV1DiscordWebhooksNewWithResponse(ctx context.Context, params *PostV1DiscordWebhooksNewParams, reqEditors ...RequestEditorFn) (*PostV1DiscordWebhooksNewResponse, error) { + rsp, err := c.PostV1DiscordWebhooksNew(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1DiscordWebhooksNewResponse(rsp) +} + +// DeleteV1DiscordWebhooksIdWithResponse request returning *DeleteV1DiscordWebhooksIdResponse +func (c *ClientWithResponses) DeleteV1DiscordWebhooksIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteV1DiscordWebhooksIdResponse, error) { + rsp, err := c.DeleteV1DiscordWebhooksId(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteV1DiscordWebhooksIdResponse(rsp) +} + +// GetV1DiscordWebhooksIdWithResponse request returning *GetV1DiscordWebhooksIdResponse +func (c *ClientWithResponses) GetV1DiscordWebhooksIdWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*GetV1DiscordWebhooksIdResponse, error) { + rsp, err := c.GetV1DiscordWebhooksId(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1DiscordWebhooksIdResponse(rsp) +} + +// PostV1DiscordWebhooksIdDisableWithResponse request returning *PostV1DiscordWebhooksIdDisableResponse +func (c *ClientWithResponses) PostV1DiscordWebhooksIdDisableWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1DiscordWebhooksIdDisableResponse, error) { + rsp, err := c.PostV1DiscordWebhooksIdDisable(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1DiscordWebhooksIdDisableResponse(rsp) +} + +// PostV1DiscordWebhooksIdEnableWithResponse request returning *PostV1DiscordWebhooksIdEnableResponse +func (c *ClientWithResponses) PostV1DiscordWebhooksIdEnableWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1DiscordWebhooksIdEnableResponse, error) { + rsp, err := c.PostV1DiscordWebhooksIdEnable(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1DiscordWebhooksIdEnableResponse(rsp) +} + +// GetV1SourcesWithResponse request returning *GetV1SourcesResponse +func (c *ClientWithResponses) GetV1SourcesWithResponse(ctx context.Context, params *GetV1SourcesParams, reqEditors ...RequestEditorFn) (*GetV1SourcesResponse, error) { + rsp, err := c.GetV1Sources(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1SourcesResponse(rsp) +} + +// GetV1SourcesBySourceWithResponse request returning *GetV1SourcesBySourceResponse +func (c *ClientWithResponses) GetV1SourcesBySourceWithResponse(ctx context.Context, params *GetV1SourcesBySourceParams, reqEditors ...RequestEditorFn) (*GetV1SourcesBySourceResponse, error) { + rsp, err := c.GetV1SourcesBySource(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1SourcesBySourceResponse(rsp) +} + +// GetV1SourcesBySourceAndNameWithResponse request returning *GetV1SourcesBySourceAndNameResponse +func (c *ClientWithResponses) GetV1SourcesBySourceAndNameWithResponse(ctx context.Context, params *GetV1SourcesBySourceAndNameParams, reqEditors ...RequestEditorFn) (*GetV1SourcesBySourceAndNameResponse, error) { + rsp, err := c.GetV1SourcesBySourceAndName(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1SourcesBySourceAndNameResponse(rsp) +} + +// PostV1SourcesNewRedditWithResponse request returning *PostV1SourcesNewRedditResponse +func (c *ClientWithResponses) PostV1SourcesNewRedditWithResponse(ctx context.Context, params *PostV1SourcesNewRedditParams, reqEditors ...RequestEditorFn) (*PostV1SourcesNewRedditResponse, error) { + rsp, err := c.PostV1SourcesNewReddit(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1SourcesNewRedditResponse(rsp) +} + +// PostV1SourcesNewRssWithBodyWithResponse request with arbitrary body returning *PostV1SourcesNewRssResponse +func (c *ClientWithResponses) PostV1SourcesNewRssWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1SourcesNewRssResponse, error) { + rsp, err := c.PostV1SourcesNewRssWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1SourcesNewRssResponse(rsp) +} + +// PostV1SourcesNewTwitchWithResponse request returning *PostV1SourcesNewTwitchResponse +func (c *ClientWithResponses) PostV1SourcesNewTwitchWithResponse(ctx context.Context, params *PostV1SourcesNewTwitchParams, reqEditors ...RequestEditorFn) (*PostV1SourcesNewTwitchResponse, error) { + rsp, err := c.PostV1SourcesNewTwitch(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1SourcesNewTwitchResponse(rsp) +} + +// PostV1SourcesNewYoutubeWithResponse request returning *PostV1SourcesNewYoutubeResponse +func (c *ClientWithResponses) PostV1SourcesNewYoutubeWithResponse(ctx context.Context, params *PostV1SourcesNewYoutubeParams, reqEditors ...RequestEditorFn) (*PostV1SourcesNewYoutubeResponse, error) { + rsp, err := c.PostV1SourcesNewYoutube(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1SourcesNewYoutubeResponse(rsp) +} + +// GetV1SourcesIdWithResponse request returning *GetV1SourcesIdResponse +func (c *ClientWithResponses) GetV1SourcesIdWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*GetV1SourcesIdResponse, error) { + rsp, err := c.GetV1SourcesId(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetV1SourcesIdResponse(rsp) +} + +// PostV1SourcesIdWithResponse request returning *PostV1SourcesIdResponse +func (c *ClientWithResponses) PostV1SourcesIdWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1SourcesIdResponse, error) { + rsp, err := c.PostV1SourcesId(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1SourcesIdResponse(rsp) +} + +// PostV1SourcesIdDisableWithResponse request returning *PostV1SourcesIdDisableResponse +func (c *ClientWithResponses) PostV1SourcesIdDisableWithResponse(ctx context.Context, id int, reqEditors ...RequestEditorFn) (*PostV1SourcesIdDisableResponse, error) { + rsp, err := c.PostV1SourcesIdDisable(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1SourcesIdDisableResponse(rsp) +} + +// PostV1SourcesIdEnableWithResponse request returning *PostV1SourcesIdEnableResponse +func (c *ClientWithResponses) PostV1SourcesIdEnableWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*PostV1SourcesIdEnableResponse, error) { + rsp, err := c.PostV1SourcesIdEnable(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1SourcesIdEnableResponse(rsp) +} + +// PostV1UsersLoginWithBodyWithResponse request with arbitrary body returning *PostV1UsersLoginResponse +func (c *ClientWithResponses) PostV1UsersLoginWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersLoginResponse, error) { + rsp, err := c.PostV1UsersLoginWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersLoginResponse(rsp) +} + +// PostV1UsersRefreshSessionTokenWithResponse request returning *PostV1UsersRefreshSessionTokenResponse +func (c *ClientWithResponses) PostV1UsersRefreshSessionTokenWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostV1UsersRefreshSessionTokenResponse, error) { + rsp, err := c.PostV1UsersRefreshSessionToken(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersRefreshSessionTokenResponse(rsp) +} + +// PostV1UsersRefreshTokenWithBodyWithResponse request with arbitrary body returning *PostV1UsersRefreshTokenResponse +func (c *ClientWithResponses) PostV1UsersRefreshTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersRefreshTokenResponse, error) { + rsp, err := c.PostV1UsersRefreshTokenWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersRefreshTokenResponse(rsp) +} + +// PostV1UsersRegisterWithBodyWithResponse request with arbitrary body returning *PostV1UsersRegisterResponse +func (c *ClientWithResponses) PostV1UsersRegisterWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersRegisterResponse, error) { + rsp, err := c.PostV1UsersRegisterWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersRegisterResponse(rsp) +} + +// PostV1UsersScopesAddWithBodyWithResponse request with arbitrary body returning *PostV1UsersScopesAddResponse +func (c *ClientWithResponses) PostV1UsersScopesAddWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersScopesAddResponse, error) { + rsp, err := c.PostV1UsersScopesAddWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersScopesAddResponse(rsp) +} + +func (c *ClientWithResponses) PostV1UsersScopesAddWithResponse(ctx context.Context, body PostV1UsersScopesAddJSONRequestBody, reqEditors ...RequestEditorFn) (*PostV1UsersScopesAddResponse, error) { + rsp, err := c.PostV1UsersScopesAdd(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersScopesAddResponse(rsp) +} + +// PostV1UsersScopesRemoveWithBodyWithResponse request with arbitrary body returning *PostV1UsersScopesRemoveResponse +func (c *ClientWithResponses) PostV1UsersScopesRemoveWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostV1UsersScopesRemoveResponse, error) { + rsp, err := c.PostV1UsersScopesRemoveWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersScopesRemoveResponse(rsp) +} + +func (c *ClientWithResponses) PostV1UsersScopesRemoveWithResponse(ctx context.Context, body PostV1UsersScopesRemoveJSONRequestBody, reqEditors ...RequestEditorFn) (*PostV1UsersScopesRemoveResponse, error) { + rsp, err := c.PostV1UsersScopesRemove(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostV1UsersScopesRemoveResponse(rsp) +} + +// ParseGetV1ArticlesResponse parses an HTTP response from a GetV1ArticlesWithResponse call +func ParseGetV1ArticlesResponse(rsp *http.Response) (*GetV1ArticlesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1ArticlesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainArticleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetV1ArticlesBySourceIdResponse parses an HTTP response from a GetV1ArticlesBySourceIdWithResponse call +func ParseGetV1ArticlesBySourceIdResponse(rsp *http.Response) (*GetV1ArticlesBySourceIdResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1ArticlesBySourceIdResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainArticleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetV1ArticlesIdResponse parses an HTTP response from a GetV1ArticlesIdWithResponse call +func ParseGetV1ArticlesIdResponse(rsp *http.Response) (*GetV1ArticlesIdResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1ArticlesIdResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainArticleResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetV1ArticlesIdDetailsResponse parses an HTTP response from a GetV1ArticlesIdDetailsWithResponse call +func ParseGetV1ArticlesIdDetailsResponse(rsp *http.Response) (*GetV1ArticlesIdDetailsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1ArticlesIdDetailsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainArticleDetailedResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetV1DiscordWebhooksResponse parses an HTTP response from a GetV1DiscordWebhooksWithResponse call +func ParseGetV1DiscordWebhooksResponse(rsp *http.Response) (*GetV1DiscordWebhooksResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1DiscordWebhooksResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetV1DiscordWebhooksByServerAndChannelResponse parses an HTTP response from a GetV1DiscordWebhooksByServerAndChannelWithResponse call +func ParseGetV1DiscordWebhooksByServerAndChannelResponse(rsp *http.Response) (*GetV1DiscordWebhooksByServerAndChannelResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1DiscordWebhooksByServerAndChannelResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1DiscordWebhooksNewResponse parses an HTTP response from a PostV1DiscordWebhooksNewWithResponse call +func ParsePostV1DiscordWebhooksNewResponse(rsp *http.Response) (*PostV1DiscordWebhooksNewResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1DiscordWebhooksNewResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseDeleteV1DiscordWebhooksIdResponse parses an HTTP response from a DeleteV1DiscordWebhooksIdWithResponse call +func ParseDeleteV1DiscordWebhooksIdResponse(rsp *http.Response) (*DeleteV1DiscordWebhooksIdResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteV1DiscordWebhooksIdResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetV1DiscordWebhooksIdResponse parses an HTTP response from a GetV1DiscordWebhooksIdWithResponse call +func ParseGetV1DiscordWebhooksIdResponse(rsp *http.Response) (*GetV1DiscordWebhooksIdResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1DiscordWebhooksIdResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainDiscordWebhookResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1DiscordWebhooksIdDisableResponse parses an HTTP response from a PostV1DiscordWebhooksIdDisableWithResponse call +func ParsePostV1DiscordWebhooksIdDisableResponse(rsp *http.Response) (*PostV1DiscordWebhooksIdDisableResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1DiscordWebhooksIdDisableResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1DiscordWebhooksIdEnableResponse parses an HTTP response from a PostV1DiscordWebhooksIdEnableWithResponse call +func ParsePostV1DiscordWebhooksIdEnableResponse(rsp *http.Response) (*PostV1DiscordWebhooksIdEnableResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1DiscordWebhooksIdEnableResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetV1SourcesResponse parses an HTTP response from a GetV1SourcesWithResponse call +func ParseGetV1SourcesResponse(rsp *http.Response) (*GetV1SourcesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1SourcesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + } + + return response, nil +} + +// ParseGetV1SourcesBySourceResponse parses an HTTP response from a GetV1SourcesBySourceWithResponse call +func ParseGetV1SourcesBySourceResponse(rsp *http.Response) (*GetV1SourcesBySourceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1SourcesBySourceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetV1SourcesBySourceAndNameResponse parses an HTTP response from a GetV1SourcesBySourceAndNameWithResponse call +func ParseGetV1SourcesBySourceAndNameResponse(rsp *http.Response) (*GetV1SourcesBySourceAndNameResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1SourcesBySourceAndNameResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1SourcesNewRedditResponse parses an HTTP response from a PostV1SourcesNewRedditWithResponse call +func ParsePostV1SourcesNewRedditResponse(rsp *http.Response) (*PostV1SourcesNewRedditResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1SourcesNewRedditResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1SourcesNewRssResponse parses an HTTP response from a PostV1SourcesNewRssWithResponse call +func ParsePostV1SourcesNewRssResponse(rsp *http.Response) (*PostV1SourcesNewRssResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1SourcesNewRssResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1SourcesNewTwitchResponse parses an HTTP response from a PostV1SourcesNewTwitchWithResponse call +func ParsePostV1SourcesNewTwitchResponse(rsp *http.Response) (*PostV1SourcesNewTwitchResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1SourcesNewTwitchResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1SourcesNewYoutubeResponse parses an HTTP response from a PostV1SourcesNewYoutubeWithResponse call +func ParsePostV1SourcesNewYoutubeResponse(rsp *http.Response) (*PostV1SourcesNewYoutubeResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1SourcesNewYoutubeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetV1SourcesIdResponse parses an HTTP response from a GetV1SourcesIdWithResponse call +func ParseGetV1SourcesIdResponse(rsp *http.Response) (*GetV1SourcesIdResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetV1SourcesIdResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainSourcesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1SourcesIdResponse parses an HTTP response from a PostV1SourcesIdWithResponse call +func ParsePostV1SourcesIdResponse(rsp *http.Response) (*PostV1SourcesIdResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1SourcesIdResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1SourcesIdDisableResponse parses an HTTP response from a PostV1SourcesIdDisableWithResponse call +func ParsePostV1SourcesIdDisableResponse(rsp *http.Response) (*PostV1SourcesIdDisableResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1SourcesIdDisableResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1SourcesIdEnableResponse parses an HTTP response from a PostV1SourcesIdEnableWithResponse call +func ParsePostV1SourcesIdEnableResponse(rsp *http.Response) (*PostV1SourcesIdEnableResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1SourcesIdEnableResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1UsersLoginResponse parses an HTTP response from a PostV1UsersLoginWithResponse call +func ParsePostV1UsersLoginResponse(rsp *http.Response) (*PostV1UsersLoginResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1UsersLoginResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainLoginResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainLoginResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainLoginResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1UsersRefreshSessionTokenResponse parses an HTTP response from a PostV1UsersRefreshSessionTokenWithResponse call +func ParsePostV1UsersRefreshSessionTokenResponse(rsp *http.Response) (*PostV1UsersRefreshSessionTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1UsersRefreshSessionTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1UsersRefreshTokenResponse parses an HTTP response from a PostV1UsersRefreshTokenWithResponse call +func ParsePostV1UsersRefreshTokenResponse(rsp *http.Response) (*PostV1UsersRefreshTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1UsersRefreshTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParsePostV1UsersRegisterResponse parses an HTTP response from a PostV1UsersRegisterWithResponse call +func ParsePostV1UsersRegisterResponse(rsp *http.Response) (*PostV1UsersRegisterResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1UsersRegisterResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1UsersScopesAddResponse parses an HTTP response from a PostV1UsersScopesAddWithResponse call +func ParsePostV1UsersScopesAddResponse(rsp *http.Response) (*PostV1UsersScopesAddResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1UsersScopesAddResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParsePostV1UsersScopesRemoveResponse parses an HTTP response from a PostV1UsersScopesRemoveWithResponse call +func ParsePostV1UsersScopesRemoveResponse(rsp *http.Response) (*PostV1UsersScopesRemoveResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostV1UsersScopesRemoveResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest DomainBaseResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} diff --git a/api/client.yaml b/api/client.yaml new file mode 100644 index 0000000..2c1480a --- /dev/null +++ b/api/client.yaml @@ -0,0 +1,6 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/deepmap/oapi-codegen/HEAD/configuration-schema.json +package: api +output: api.gen.go +generate: + models: true + client: true \ No newline at end of file diff --git a/cmd/server.go b/cmd/server.go index dad9a4b..4f0ac04 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -16,13 +16,13 @@ import ( "git.jamestombleson.com/jtom38/newsbot-api/internal/services/cron" ) -// @title NewsBot collector -// @version 0.1 -// @BasePath /api -// @securityDefinitions.apikey Bearer -// @in header -// @name Authorization -// @description Type "Bearer" followed by a space and JWT token. +// @title NewsBot collector +// @version 0.1 +// @BasePath /api +// @securityDefinitions.apikey Bearer +// @in header +// @name Authorization +// @description Type "Bearer" followed by a space and JWT token. func main() { ctx := context.Background() diff --git a/docs/docs.go b/docs/docs.go index 61c249f..fd059ef 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -32,10 +32,11 @@ const docTemplate = `{ "summary": "Lists the top 25 records ordering from newest to oldest.", "parameters": [ { - "type": "string", + "type": "integer", "description": "page number", "name": "page", - "in": "query" + "in": "query", + "required": true } ], "responses": { @@ -60,7 +61,7 @@ const docTemplate = `{ } } }, - "/v1/articles/by/sourceId": { + "/v1/articles/by/source/{id}": { "get": { "security": [ { @@ -79,7 +80,7 @@ const docTemplate = `{ "type": "string", "description": "source id", "name": "id", - "in": "query", + "in": "path", "required": true }, { @@ -111,7 +112,7 @@ const docTemplate = `{ } } }, - "/v1/articles/{ID}": { + "/v1/articles/{id}": { "get": { "security": [ { @@ -129,7 +130,7 @@ const docTemplate = `{ { "type": "string", "description": "int", - "name": "ID", + "name": "id", "in": "path", "required": true } @@ -156,7 +157,7 @@ const docTemplate = `{ } } }, - "/v1/articles/{ID}/details": { + "/v1/articles/{id}/details": { "get": { "security": [ { @@ -174,7 +175,7 @@ const docTemplate = `{ { "type": "string", "description": "int", - "name": "ID", + "name": "id", "in": "path", "required": true } @@ -345,7 +346,50 @@ const docTemplate = `{ } } }, - "/v1/discord/webhooks/{ID}": { + "/v1/discord/webhooks/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "DiscordWebhook" + ], + "summary": "Returns the top 100 entries from the queue to be processed.", + "parameters": [ + { + "type": "integer", + "description": "id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.DiscordWebhookResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.DiscordWebhookResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.DiscordWebhookResponse" + } + } + } + }, "delete": { "security": [ { @@ -387,7 +431,7 @@ const docTemplate = `{ } } }, - "/v1/discord/webhooks/{ID}/disable": { + "/v1/discord/webhooks/{id}/disable": { "post": { "security": [ { @@ -429,7 +473,7 @@ const docTemplate = `{ } } }, - "/v1/discord/webhooks/{ID}/enable": { + "/v1/discord/webhooks/{id}/enable": { "post": { "security": [ { @@ -471,51 +515,6 @@ const docTemplate = `{ } } }, - "/v1/discord/webhooks/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "produces": [ - "application/json" - ], - "tags": [ - "DiscordWebhook" - ], - "summary": "Returns the top 100 entries from the queue to be processed.", - "parameters": [ - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.DiscordWebhookResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.DiscordWebhookResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.DiscordWebhookResponse" - } - } - } - } - }, "/v1/sources": { "get": { "security": [ @@ -1512,24 +1511,16 @@ const docTemplate = `{ } } } - }, - "securityDefinitions": { - "Bearer": { - "description": "Type \"Bearer\" followed by a space and JWT token.", - "type": "apiKey", - "name": "Authorization", - "in": "header" - } } }` // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ - Version: "0.1", + Version: "", Host: "", - BasePath: "/api", + BasePath: "", Schemes: []string{}, - Title: "NewsBot collector", + Title: "", Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, diff --git a/docs/swagger.json b/docs/swagger.json index f67f4ad..f5fc99a 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1,11 +1,8 @@ { "swagger": "2.0", "info": { - "title": "NewsBot collector", - "contact": {}, - "version": "0.1" + "contact": {} }, - "basePath": "/api", "paths": { "/v1/articles": { "get": { @@ -23,10 +20,11 @@ "summary": "Lists the top 25 records ordering from newest to oldest.", "parameters": [ { - "type": "string", + "type": "integer", "description": "page number", "name": "page", - "in": "query" + "in": "query", + "required": true } ], "responses": { @@ -51,7 +49,7 @@ } } }, - "/v1/articles/by/sourceId": { + "/v1/articles/by/source/{id}": { "get": { "security": [ { @@ -70,7 +68,7 @@ "type": "string", "description": "source id", "name": "id", - "in": "query", + "in": "path", "required": true }, { @@ -102,7 +100,7 @@ } } }, - "/v1/articles/{ID}": { + "/v1/articles/{id}": { "get": { "security": [ { @@ -120,7 +118,7 @@ { "type": "string", "description": "int", - "name": "ID", + "name": "id", "in": "path", "required": true } @@ -147,7 +145,7 @@ } } }, - "/v1/articles/{ID}/details": { + "/v1/articles/{id}/details": { "get": { "security": [ { @@ -165,7 +163,7 @@ { "type": "string", "description": "int", - "name": "ID", + "name": "id", "in": "path", "required": true } @@ -336,7 +334,50 @@ } } }, - "/v1/discord/webhooks/{ID}": { + "/v1/discord/webhooks/{id}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "DiscordWebhook" + ], + "summary": "Returns the top 100 entries from the queue to be processed.", + "parameters": [ + { + "type": "integer", + "description": "id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.DiscordWebhookResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.DiscordWebhookResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.DiscordWebhookResponse" + } + } + } + }, "delete": { "security": [ { @@ -378,7 +419,7 @@ } } }, - "/v1/discord/webhooks/{ID}/disable": { + "/v1/discord/webhooks/{id}/disable": { "post": { "security": [ { @@ -420,7 +461,7 @@ } } }, - "/v1/discord/webhooks/{ID}/enable": { + "/v1/discord/webhooks/{id}/enable": { "post": { "security": [ { @@ -462,51 +503,6 @@ } } }, - "/v1/discord/webhooks/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "produces": [ - "application/json" - ], - "tags": [ - "DiscordWebhook" - ], - "summary": "Returns the top 100 entries from the queue to be processed.", - "parameters": [ - { - "type": "integer", - "description": "id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.DiscordWebhookResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/domain.DiscordWebhookResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/domain.DiscordWebhookResponse" - } - } - } - } - }, "/v1/sources": { "get": { "security": [ @@ -1503,13 +1499,5 @@ } } } - }, - "securityDefinitions": { - "Bearer": { - "description": "Type \"Bearer\" followed by a space and JWT token.", - "type": "apiKey", - "name": "Authorization", - "in": "header" - } } } \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 973d9f4..8401f5d 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,4 +1,3 @@ -basePath: /api definitions: domain.ArticleAndSourceModel: properties: @@ -154,8 +153,6 @@ definitions: type: object info: contact: {} - title: NewsBot collector - version: "0.1" paths: /v1/articles: get: @@ -163,7 +160,8 @@ paths: - description: page number in: query name: page - type: string + required: true + type: integer produces: - application/json responses: @@ -184,12 +182,12 @@ paths: summary: Lists the top 25 records ordering from newest to oldest. tags: - Articles - /v1/articles/{ID}: + /v1/articles/{id}: get: parameters: - description: int in: path - name: ID + name: id required: true type: string produces: @@ -212,12 +210,12 @@ paths: summary: Returns an article based on defined ID. tags: - Articles - /v1/articles/{ID}/details: + /v1/articles/{id}/details: get: parameters: - description: int in: path - name: ID + name: id required: true type: string produces: @@ -240,11 +238,11 @@ paths: summary: Returns an article and source based on defined ID. tags: - Articles - /v1/articles/by/sourceId: + /v1/articles/by/source/{id}: get: parameters: - description: source id - in: query + in: path name: id required: true type: string @@ -295,7 +293,7 @@ paths: summary: Returns the top 100 tags: - DiscordWebhook - /v1/discord/webhooks/{ID}: + /v1/discord/webhooks/{id}: delete: parameters: - description: id @@ -321,59 +319,6 @@ paths: summary: Deletes a record by ID. tags: - DiscordWebhook - /v1/discord/webhooks/{ID}/disable: - post: - parameters: - - description: id - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.DiscordWebhookResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.DiscordWebhookResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.DiscordWebhookResponse' - security: - - Bearer: [] - summary: Disables a Webhook from being used. - tags: - - DiscordWebhook - /v1/discord/webhooks/{ID}/enable: - post: - parameters: - - description: id - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/domain.DiscordWebhookResponse' - "400": - description: Bad Request - schema: - $ref: '#/definitions/domain.DiscordWebhookResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/domain.DiscordWebhookResponse' - security: - - Bearer: [] - summary: Enables a source to continue processing. - tags: - - DiscordWebhook - /v1/discord/webhooks/{id}: get: parameters: - description: id @@ -401,6 +346,58 @@ paths: summary: Returns the top 100 entries from the queue to be processed. tags: - DiscordWebhook + /v1/discord/webhooks/{id}/disable: + post: + parameters: + - description: id + in: path + name: id + required: true + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.DiscordWebhookResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.DiscordWebhookResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.DiscordWebhookResponse' + security: + - Bearer: [] + summary: Disables a Webhook from being used. + tags: + - DiscordWebhook + /v1/discord/webhooks/{id}/enable: + post: + parameters: + - description: id + in: path + name: id + required: true + type: integer + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.DiscordWebhookResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/domain.DiscordWebhookResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.DiscordWebhookResponse' + security: + - Bearer: [] + summary: Enables a source to continue processing. + tags: + - DiscordWebhook /v1/discord/webhooks/by/serverAndChannel: get: parameters: @@ -945,10 +942,4 @@ paths: summary: Adds a new scope to a user account tags: - Users -securityDefinitions: - Bearer: - description: Type "Bearer" followed by a space and JWT token. - in: header - name: Authorization - type: apiKey swagger: "2.0" diff --git a/internal/handler/v1/articles.go b/internal/handler/v1/articles.go index 9f086cd..e3fe7c5 100644 --- a/internal/handler/v1/articles.go +++ b/internal/handler/v1/articles.go @@ -10,15 +10,15 @@ import ( ) // ListArticles -// @Summary Lists the top 25 records ordering from newest to oldest. -// @Produce application/json -// @Param page query string false "page number" -// @Tags Articles -// @Router /v1/articles [get] -// @Success 200 {object} domain.ArticleResponse -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Lists the top 25 records ordering from newest to oldest. +// @Produce application/json +// @Param page query int true "page number" test +// @Tags Articles +// @Router /v1/articles [get] +// @Success 200 {object} domain.ArticleResponse +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (s *Handler) listArticles(c echo.Context) error { resp := domain.ArticleResponse{ BaseResponse: domain.BaseResponse{ @@ -48,15 +48,15 @@ func (s *Handler) listArticles(c echo.Context) error { } // GetArticle -// @Summary Returns an article based on defined ID. -// @Param ID path string true "int" -// @Produce application/json -// @Tags Articles -// @Router /v1/articles/{ID} [get] -// @Success 200 {object} domain.ArticleResponse "OK" -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Returns an article based on defined ID. +// @Param id path string true "int" +// @Produce application/json +// @Tags Articles +// @Router /v1/articles/{id} [get] +// @Success 200 {object} domain.ArticleResponse "OK" +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (s *Handler) getArticle(c echo.Context) error { p := domain.ArticleResponse{ BaseResponse: domain.BaseResponse{ @@ -90,15 +90,15 @@ func (s *Handler) getArticle(c echo.Context) error { } // GetArticleDetails -// @Summary Returns an article and source based on defined ID. -// @Param ID path string true "int" -// @Produce application/json -// @Tags Articles -// @Router /v1/articles/{ID}/details [get] -// @Success 200 {object} domain.ArticleDetailedResponse "OK" -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Returns an article and source based on defined ID. +// @Param id path string true "int" +// @Produce application/json +// @Tags Articles +// @Router /v1/articles/{id}/details [get] +// @Success 200 {object} domain.ArticleDetailedResponse "OK" +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (s *Handler) getArticleDetails(c echo.Context) error { p := domain.ArticleDetailedResponse{ BaseResponse: domain.BaseResponse{ @@ -135,16 +135,16 @@ func (s *Handler) getArticleDetails(c echo.Context) error { } // ListArticlesBySourceID -// @Summary Finds the articles based on the SourceID provided. Returns the top 25. -// @Param id query string true "source id" -// @Param page query int false "Page to query" -// @Produce application/json -// @Tags Articles -// @Router /v1/articles/by/sourceId [get] -// @Success 200 {object} domain.ArticleResponse "OK" -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Finds the articles based on the SourceID provided. Returns the top 25. +// @Param id path string true "source id" +// @Param page query int false "Page to query" +// @Produce application/json +// @Tags Articles +// @Router /v1/articles/by/source/{id} [get] +// @Success 200 {object} domain.ArticleResponse "OK" +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (s *Handler) ListArticlesBySourceId(c echo.Context) error { p := domain.ArticleResponse{ BaseResponse: domain.BaseResponse{ diff --git a/internal/handler/v1/discordwebhooks.go b/internal/handler/v1/discordwebhooks.go index 33abda2..03fece8 100644 --- a/internal/handler/v1/discordwebhooks.go +++ b/internal/handler/v1/discordwebhooks.go @@ -11,14 +11,14 @@ import ( ) // ListDiscordWebhooks -// @Summary Returns the top 100 -// @Produce application/json -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks [get] -// @Success 200 {object} domain.DiscordWebhookResponse -// @Failure 400 {object} domain.DiscordWebhookResponse -// @Failure 500 {object} domain.DiscordWebhookResponse -// @Security Bearer +// @Summary Returns the top 100 +// @Produce application/json +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks [get] +// @Success 200 {object} domain.DiscordWebhookResponse +// @Failure 400 {object} domain.DiscordWebhookResponse +// @Failure 500 {object} domain.DiscordWebhookResponse +// @Security Bearer func (s *Handler) ListDiscordWebHooks(c echo.Context) error { p := domain.DiscordWebhookResponse{ BaseResponse: domain.BaseResponse{ @@ -43,15 +43,15 @@ func (s *Handler) ListDiscordWebHooks(c echo.Context) error { } // GetDiscordWebHook -// @Summary Returns the top 100 entries from the queue to be processed. -// @Produce application/json -// @Param id path int true "id" -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks/{id} [get] -// @Success 200 {object} domain.DiscordWebhookResponse "OK" -// @Failure 400 {object} domain.DiscordWebhookResponse -// @Failure 500 {object} domain.DiscordWebhookResponse -// @Security Bearer +// @Summary Returns the top 100 entries from the queue to be processed. +// @Produce application/json +// @Param id path int true "id" +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks/{id} [get] +// @Success 200 {object} domain.DiscordWebhookResponse "OK" +// @Failure 400 {object} domain.DiscordWebhookResponse +// @Failure 500 {object} domain.DiscordWebhookResponse +// @Security Bearer func (s *Handler) GetDiscordWebHooksById(c echo.Context) error { p := domain.DiscordWebhookResponse{ BaseResponse: domain.BaseResponse{ @@ -83,16 +83,16 @@ func (s *Handler) GetDiscordWebHooksById(c echo.Context) error { } // GetDiscordWebHookByServerAndChannel -// @Summary Returns all the known web hooks based on the Server and Channel given. -// @Produce application/json -// @Param server query string true "Fancy Server" -// @Param channel query string true "memes" -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks/by/serverAndChannel [get] -// @Success 200 {object} domain.DiscordWebhookResponse "OK" -// @Failure 400 {object} domain.DiscordWebhookResponse -// @Failure 500 {object} domain.DiscordWebhookResponse -// @Security Bearer +// @Summary Returns all the known web hooks based on the Server and Channel given. +// @Produce application/json +// @Param server query string true "Fancy Server" +// @Param channel query string true "memes" +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks/by/serverAndChannel [get] +// @Success 200 {object} domain.DiscordWebhookResponse "OK" +// @Failure 400 {object} domain.DiscordWebhookResponse +// @Failure 500 {object} domain.DiscordWebhookResponse +// @Security Bearer func (s *Handler) GetDiscordWebHooksByServerAndChannel(c echo.Context) error { p := domain.DiscordWebhookResponse{ BaseResponse: domain.BaseResponse{ @@ -131,16 +131,16 @@ func (s *Handler) GetDiscordWebHooksByServerAndChannel(c echo.Context) error { } // NewDiscordWebHook -// @Summary Creates a new record for a discord web hook to post data to. -// @Param url query string true "url" -// @Param server query string true "Server name" -// @Param channel query string true "Channel name" -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks/new [post] -// @Success 200 {object} domain.DiscordWebhookResponse "OK" -// @Failure 400 {object} domain.DiscordWebhookResponse -// @Failure 500 {object} domain.DiscordWebhookResponse -// @Security Bearer +// @Summary Creates a new record for a discord web hook to post data to. +// @Param url query string true "url" +// @Param server query string true "Server name" +// @Param channel query string true "Channel name" +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks/new [post] +// @Success 200 {object} domain.DiscordWebhookResponse "OK" +// @Failure 400 {object} domain.DiscordWebhookResponse +// @Failure 500 {object} domain.DiscordWebhookResponse +// @Security Bearer func (s *Handler) NewDiscordWebHook(c echo.Context) error { p := domain.DiscordWebhookResponse{ BaseResponse: domain.BaseResponse{ @@ -208,14 +208,14 @@ func (s *Handler) NewDiscordWebHook(c echo.Context) error { } // DisableDiscordWebHooks -// @Summary Disables a Webhook from being used. -// @Param id path int true "id" -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks/{ID}/disable [post] -// @Success 200 {object} domain.DiscordWebhookResponse "OK" -// @Failure 400 {object} domain.DiscordWebhookResponse -// @Failure 500 {object} domain.DiscordWebhookResponse -// @Security Bearer +// @Summary Disables a Webhook from being used. +// @Param id path int true "id" +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks/{id}/disable [post] +// @Success 200 {object} domain.DiscordWebhookResponse "OK" +// @Failure 400 {object} domain.DiscordWebhookResponse +// @Failure 500 {object} domain.DiscordWebhookResponse +// @Security Bearer func (s *Handler) disableDiscordWebHook(c echo.Context) error { p := domain.DiscordWebhookResponse{ BaseResponse: domain.BaseResponse{ @@ -276,14 +276,14 @@ func (s *Handler) disableDiscordWebHook(c echo.Context) error { } // EnableDiscordWebHook -// @Summary Enables a source to continue processing. -// @Param id path int true "id" -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks/{ID}/enable [post] -// @Success 200 {object} domain.DiscordWebhookResponse "OK" -// @Failure 400 {object} domain.DiscordWebhookResponse -// @Failure 500 {object} domain.DiscordWebhookResponse -// @Security Bearer +// @Summary Enables a source to continue processing. +// @Param id path int true "id" +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks/{id}/enable [post] +// @Success 200 {object} domain.DiscordWebhookResponse "OK" +// @Failure 400 {object} domain.DiscordWebhookResponse +// @Failure 500 {object} domain.DiscordWebhookResponse +// @Security Bearer func (s *Handler) enableDiscordWebHook(c echo.Context) error { p := domain.DiscordWebhookResponse{ BaseResponse: domain.BaseResponse{ @@ -342,14 +342,14 @@ func (s *Handler) enableDiscordWebHook(c echo.Context) error { } // DeleteDiscordWebHook -// @Summary Deletes a record by ID. -// @Param id path string true "id" -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks/{ID} [delete] -// @Success 200 {object} domain.DiscordWebhookResponse "OK" -// @Failure 400 {object} domain.DiscordWebhookResponse -// @Failure 500 {object} domain.DiscordWebhookResponse -// @Security Bearer +// @Summary Deletes a record by ID. +// @Param id path string true "id" +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks/{id} [delete] +// @Success 200 {object} domain.DiscordWebhookResponse "OK" +// @Failure 400 {object} domain.DiscordWebhookResponse +// @Failure 500 {object} domain.DiscordWebhookResponse +// @Security Bearer func (s *Handler) deleteDiscordWebHook(c echo.Context) error { p := domain.DiscordWebhookResponse{ BaseResponse: domain.BaseResponse{ @@ -409,13 +409,13 @@ func (s *Handler) deleteDiscordWebHook(c echo.Context) error { } // UpdateDiscordWebHook -// @Summary Updates a valid discord webhook ID based on the body given. -// @Param id path string true "id" -// @Tags DiscordWebhook -// @Router /v1/discord/webhooks/{id} [patch] -// @Success 200 {object} domain.DiscordWebhookResponse "OK" -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse +// @Summary Updates a valid discord webhook ID based on the body given. +// @Param id path string true "id" +// @Tags DiscordWebhook +// @Router /v1/discord/webhooks/{id} [patch] +// @Success 200 {object} domain.DiscordWebhookResponse "OK" +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse //func (s *Handler) UpdateDiscordWebHook(c echo.Context) error { // id, err := strconv.Atoi(c.Param("ID")) // if err != nil { diff --git a/internal/handler/v1/sources.go b/internal/handler/v1/sources.go index 8ccc224..bc71d2b 100644 --- a/internal/handler/v1/sources.go +++ b/internal/handler/v1/sources.go @@ -8,18 +8,19 @@ import ( "git.jamestombleson.com/jtom38/newsbot-api/domain" "git.jamestombleson.com/jtom38/newsbot-api/internal/dtoconv" + "git.jamestombleson.com/jtom38/newsbot-api/internal/entity" "github.com/labstack/echo/v4" ) // ListSources -// @Summary Lists the top 50 records -// @Param page query string false "page number" -// @Produce application/json -// @Tags Source -// @Router /v1/sources [get] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse "Unable to reach SQL or Data problems" -// @Security Bearer +// @Summary Lists the top 50 records +// @Param page query string false "page number" +// @Produce application/json +// @Tags Source +// @Router /v1/sources [get] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse "Unable to reach SQL or Data problems" +// @Security Bearer func (s *Handler) listSources(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -52,16 +53,16 @@ func (s *Handler) listSources(c echo.Context) error { } // ListSourcesBySource -// @Summary Lists the top 50 records based on the name given. Example: reddit -// @Param source query string true "Source Name" -// @Param page query string false "page number" -// @Produce application/json -// @Tags Source -// @Router /v1/sources/by/source [get] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Lists the top 50 records based on the name given. Example: reddit +// @Param source query string true "Source Name" +// @Param page query string false "page number" +// @Produce application/json +// @Tags Source +// @Router /v1/sources/by/source [get] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) listSourcesBySource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -100,15 +101,15 @@ func (s *Handler) listSourcesBySource(c echo.Context) error { } // GetSource -// @Summary Returns a single entity by ID -// @Param id path int true "id" -// @Produce application/json -// @Tags Source -// @Router /v1/sources/{id} [get] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Returns a single entity by ID +// @Param id path int true "id" +// @Produce application/json +// @Tags Source +// @Router /v1/sources/{id} [get] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) getSource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -142,16 +143,16 @@ func (s *Handler) getSource(c echo.Context) error { } // GetSourceByNameAndSource -// @Summary Returns a single entity by ID -// @Param name query string true "dadjokes" -// @Param source query string true "reddit" -// @Produce application/json -// @Tags Source -// @Router /v1/sources/by/sourceAndName [get] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Returns a single entity by ID +// @Param name query string true "dadjokes" +// @Param source query string true "reddit" +// @Produce application/json +// @Tags Source +// @Router /v1/sources/by/sourceAndName [get] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (s *Handler) GetSourceBySourceAndName(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -187,15 +188,15 @@ func (s *Handler) GetSourceBySourceAndName(c echo.Context) error { } // NewRedditSource -// @Summary Creates a new reddit source to monitor. -// @Param name query string true "name" -// @Param url query string true "url" -// @Tags Source -// @Router /v1/sources/new/reddit [post] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Creates a new reddit source to monitor. +// @Param name query string true "name" +// @Param url query string true "url" +// @Tags Source +// @Router /v1/sources/new/reddit [post] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) newRedditSource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -261,15 +262,15 @@ func (s *Handler) newRedditSource(c echo.Context) error { } // NewYoutubeSource -// @Summary Creates a new youtube source to monitor. -// @Param name query string true "name" -// @Param url query string true "url" -// @Tags Source -// @Router /v1/sources/new/youtube [post] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Creates a new youtube source to monitor. +// @Param name query string true "name" +// @Param url query string true "url" +// @Tags Source +// @Router /v1/sources/new/youtube [post] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) newYoutubeSource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -334,14 +335,14 @@ func (s *Handler) newYoutubeSource(c echo.Context) error { } // NewTwitchSource -// @Summary Creates a new twitch source to monitor. -// @Param name query string true "name" -// @Tags Source -// @Router /v1/sources/new/twitch [post] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Creates a new twitch source to monitor. +// @Param name query string true "name" +// @Tags Source +// @Router /v1/sources/new/twitch [post] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) newTwitchSource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -396,14 +397,14 @@ func (s *Handler) newTwitchSource(c echo.Context) error { } // NewRssSource -// @Summary Creates a new rss source to monitor. -// @Param request body domain.NewSourceParamRequest true "body" -// @Tags Source -// @Router /v1/sources/new/rss [post] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Creates a new rss source to monitor. +// @Param request body domain.NewSourceParamRequest true "body" +// @Tags Source +// @Router /v1/sources/new/rss [post] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) newRssSource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -419,7 +420,8 @@ func (s *Handler) newRssSource(c echo.Context) error { } param := domain.NewSourceParamRequest{} - err = (&echo.DefaultBinder{}).BindBody(c, ¶m) + err = c.Bind(¶m) + //err = (&echo.DefaultBinder{}).BindBody(c, ¶m) if err != nil { p.BaseResponse.Message = err.Error() return c.JSON(http.StatusBadRequest, p) @@ -431,8 +433,15 @@ func (s *Handler) newRssSource(c echo.Context) error { } // Check if the record already exists + blankRecord := entity.SourceEntity{} item, err := s.repo.Sources.GetBySourceAndName(c.Request().Context(), domain.SourceCollectorRss, param.Name) - if err == nil { + if err != nil { + p.IsError = true + return c.JSON(http.StatusInternalServerError, p) + } + + // No record was found, but no error returned + if item != blankRecord { var dto []domain.SourceDto dto = append(dto, dtoconv.SourceToDto(item)) p.Payload = dto @@ -440,6 +449,14 @@ func (s *Handler) newRssSource(c echo.Context) error { return c.JSON(http.StatusOK, p) } + //if err == nil { + // var dto []domain.SourceDto + // dto = append(dto, dtoconv.SourceToDto(item)) + // p.Payload = dto + // p.BaseResponse.IsError = false + // return c.JSON(http.StatusOK, p) + //} + tags := fmt.Sprintf("rss, %v, %s", param.Name, param.Tags) rows, err := s.repo.Sources.Create(c.Request().Context(), domain.SourceCollectorRss, param.Name, param.Url, tags, true) if err != nil { @@ -466,14 +483,14 @@ func (s *Handler) newRssSource(c echo.Context) error { } // DeleteSource -// @Summary Marks a source as deleted based on its ID value. -// @Param id path int true "id" -// @Tags Source -// @Router /v1/sources/{id} [POST] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Marks a source as deleted based on its ID value. +// @Param id path int true "id" +// @Tags Source +// @Router /v1/sources/{id} [POST] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) deleteSources(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -526,14 +543,14 @@ func (s *Handler) deleteSources(c echo.Context) error { } // DisableSource -// @Summary Disables a source from processing. -// @Param id path int true "id" -// @Tags Source -// @Router /v1/sources/{id}/disable [post] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Disables a source from processing. +// @Param id path int true "id" +// @Tags Source +// @Router /v1/sources/{id}/disable [post] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) disableSource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ @@ -581,14 +598,14 @@ func (s *Handler) disableSource(c echo.Context) error { } // EnableSource -// @Summary Enables a source to continue processing. -// @Param id path string true "id" -// @Tags Source -// @Router /v1/sources/{id}/enable [post] -// @Success 200 {object} domain.SourcesResponse "ok" -// @Failure 400 {object} domain.SourcesResponse -// @Failure 500 {object} domain.SourcesResponse -// @Security Bearer +// @Summary Enables a source to continue processing. +// @Param id path string true "id" +// @Tags Source +// @Router /v1/sources/{id}/enable [post] +// @Success 200 {object} domain.SourcesResponse "ok" +// @Failure 400 {object} domain.SourcesResponse +// @Failure 500 {object} domain.SourcesResponse +// @Security Bearer func (s *Handler) enableSource(c echo.Context) error { p := domain.SourcesResponse{ BaseResponse: domain.BaseResponse{ diff --git a/internal/handler/v1/users.go b/internal/handler/v1/users.go index 44d0437..948c92b 100644 --- a/internal/handler/v1/users.go +++ b/internal/handler/v1/users.go @@ -17,15 +17,15 @@ const ( ErrUsernameAlreadyExists = "the requested username already exists" ) -// @Summary Creates a new user -// @Router /v1/users/register [post] -// @Param request formData domain.LoginFormRequest true "form" -// @Accepts x-www-form-urlencoded -// @Produce json -// @Tags Users -// @Success 201 {object} domain.BaseResponse -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse +// @Summary Creates a new user +// @Router /v1/users/register [post] +// @Param request formData domain.LoginFormRequest true "form" +// @Accepts x-www-form-urlencoded +// @Produce json +// @Tags Users +// @Success 201 {object} domain.BaseResponse +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse func (h *Handler) AuthRegister(c echo.Context) error { p := domain.BaseResponse{ Message: ResponseMessageSuccess, @@ -66,15 +66,15 @@ func (h *Handler) AuthRegister(c echo.Context) error { return c.JSON(http.StatusCreated, p) } -// @Summary Logs into the API and returns a bearer token if successful -// @Router /v1/users/login [post] -// @Param request formData domain.LoginFormRequest true "form" -// @Accepts x-www-form-urlencoded -// @Produce json -// @Tags Users -// @Success 200 {object} domain.LoginResponse -// @Failure 400 {object} domain.LoginResponse -// @Failure 500 {object} domain.LoginResponse +// @Summary Logs into the API and returns a bearer token if successful +// @Router /v1/users/login [post] +// @Param request formData domain.LoginFormRequest true "form" +// @Accepts x-www-form-urlencoded +// @Produce json +// @Tags Users +// @Success 200 {object} domain.LoginResponse +// @Failure 400 {object} domain.LoginResponse +// @Failure 500 {object} domain.LoginResponse func (h *Handler) AuthLogin(c echo.Context) error { p := domain.LoginResponse{ BaseResponse: domain.BaseResponse{ @@ -172,14 +172,14 @@ func (h *Handler) createAdminToken(c echo.Context, password string) error { // This will take collect some information about the requested refresh, validate and then return a new jwt token if approved. // Register -// @Summary Generates a new token -// @Router /v1/users/refresh/token [post] -// @Param request body domain.RefreshTokenRequest true "body" -// @Tags Users -// @Success 200 {object} domain.LoginResponse -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Generates a new token +// @Router /v1/users/refresh/token [post] +// @Param request body domain.RefreshTokenRequest true "body" +// @Tags Users +// @Success 200 {object} domain.LoginResponse +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (h *Handler) RefreshJwtToken(c echo.Context) error { p := domain.LoginResponse{ BaseResponse: domain.BaseResponse{ @@ -235,16 +235,16 @@ func (h *Handler) RefreshJwtToken(c echo.Context) error { return c.JSON(http.StatusOK, p) } -// @Summary Adds a new scope to a user account -// @Router /v1/users/scopes/add [post] -// @Param request body domain.UpdateScopesRequest true "body" -// @Tags Users -// @Accept json -// @Produce json -// @Success 200 {object} domain.BaseResponse -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Adds a new scope to a user account +// @Router /v1/users/scopes/add [post] +// @Param request body domain.UpdateScopesRequest true "body" +// @Tags Users +// @Accept json +// @Produce json +// @Success 200 {object} domain.BaseResponse +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (h *Handler) AddScopes(c echo.Context) error { p := domain.BaseResponse{ Message: ResponseMessageSuccess, @@ -274,16 +274,16 @@ func (h *Handler) AddScopes(c echo.Context) error { return c.JSON(http.StatusOK, p) } -// @Summary Adds a new scope to a user account -// @Router /v1/users/scopes/remove [post] -// @Param request body domain.UpdateScopesRequest true "body" -// @Tags Users -// @Accept json -// @Produce json -// @Success 200 {object} domain.BaseResponse -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Adds a new scope to a user account +// @Router /v1/users/scopes/remove [post] +// @Param request body domain.UpdateScopesRequest true "body" +// @Tags Users +// @Accept json +// @Produce json +// @Success 200 {object} domain.BaseResponse +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (h *Handler) RemoveScopes(c echo.Context) error { p := domain.BaseResponse{ Message: ResponseMessageSuccess, @@ -319,15 +319,15 @@ func (h *Handler) RemoveScopes(c echo.Context) error { return c.JSON(http.StatusOK, p) } -// @Summary Revokes the current session token and replaces it with a new one. -// @Router /v1/users/refresh/sessionToken [post] -// @Tags Users -// @Accept json -// @Produce json -// @Success 200 {object} domain.BaseResponse -// @Failure 400 {object} domain.BaseResponse -// @Failure 500 {object} domain.BaseResponse -// @Security Bearer +// @Summary Revokes the current session token and replaces it with a new one. +// @Router /v1/users/refresh/sessionToken [post] +// @Tags Users +// @Accept json +// @Produce json +// @Success 200 {object} domain.BaseResponse +// @Failure 400 {object} domain.BaseResponse +// @Failure 500 {object} domain.BaseResponse +// @Security Bearer func (h *Handler) NewSessionToken(c echo.Context) error { p := domain.BaseResponse{ Message: ResponseMessageSuccess, diff --git a/internal/repository/source.go b/internal/repository/source.go index 203672d..f342b3e 100644 --- a/internal/repository/source.go +++ b/internal/repository/source.go @@ -121,7 +121,7 @@ func (r sourceRepository) GetBySourceAndName(ctx context.Context, source, name s b.Select("*") b.From("Sources").Where( b.Equal("Source", source), - b.Equal("Name", name), + b.Equal("DisplayName", name), ) b.Limit(1) query, args := b.Build() diff --git a/makefile b/makefile index ad19d77..b65e76a 100644 --- a/makefile +++ b/makefile @@ -19,8 +19,13 @@ migrate-dev-down: ## revert sql migrations to dev db goose -dir "./internal/database/migrations" sqlite3 ./cmd/newsbot.db down swag: ## Generates the swagger documentation with the swag tool - ~/go/bin/swag f + ~/go/bin/swag f -g cmd/server.go ~/go/bin/swag init -g cmd/server.go + go run tools/swaggertoopenapi/main.go + oapi-codegen -config api/client.yaml docs/openapi.json + mv api.gen.go api/ -gensql: ## Generates SQL code with sqlc - sqlc generate \ No newline at end of file +install-tools: ## Installs the required tools for this project + go install github.com/swaggo/swag/cmd/swag@v1.8.1 + go install github.com/pressly/goose/v3/cmd/goose@latest + go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.3.0 diff --git a/tools/swaggertoopenapi/main.go b/tools/swaggertoopenapi/main.go new file mode 100644 index 0000000..6404045 --- /dev/null +++ b/tools/swaggertoopenapi/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "git.jamestombleson.com/jtom38/newsbot-api/tools/swaggertoopenapi/src" +) + + +func main() { + err := src.ConvertToOpenApi("docs/swagger.json", "docs/openapi.json", true) + if err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/tools/swaggertoopenapi/src/online.go b/tools/swaggertoopenapi/src/online.go new file mode 100644 index 0000000..29910d2 --- /dev/null +++ b/tools/swaggertoopenapi/src/online.go @@ -0,0 +1,70 @@ +package src + +import ( + "bytes" + "fmt" + "io" + "log" + "net/http" + "os" +) + +const ( + ApplicationJson = "application/json" +) + +func ConvertToOpenApi(filePath, outputPath string, force bool) error { + // check if the file already exists + exists, err := os.Stat(outputPath) + if exists != nil { + // if force was given, attempt to remove it + if force { + err = os.Remove(outputPath) + if err != nil { + return err + } + } else { + return fmt.Errorf("'%s' already exists and force was not approved", outputPath) + } + } + + log.Printf("Reading '%s'", filePath) + content, err := os.ReadFile(filePath) + if err != nil { + return err + } + + client := http.Client{} + req, err := http.NewRequest(http.MethodPost, "https://converter.swagger.io/api/convert", bytes.NewReader(content)) + if err != nil { + return err + } + req.Header.Add("Accept", ApplicationJson) + req.Header.Add("Content-Type", ApplicationJson) + + log.Println("Converting to OpenAPI spec") + resp, err := client.Do(req) + if err != nil { + return err + } + + log.Println("Reading the response") + respContent, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + log.Println("Writing converted data to openapi.json") + writer, err := os.Create(outputPath) + if err != nil { + return err + } + defer writer.Close() + + _, err = writer.Write(respContent) + if err != nil { + return err + } + + return nil +} diff --git a/tools/swaggertoopenapi/src/online_test.go b/tools/swaggertoopenapi/src/online_test.go new file mode 100644 index 0000000..30e34b3 --- /dev/null +++ b/tools/swaggertoopenapi/src/online_test.go @@ -0,0 +1,14 @@ +package src_test + +import ( + "testing" + + "git.jamestombleson.com/jtom38/newsbot-api/tools/swaggerToOpenapi/src" +) + +func TestConvertOnline(t *testing.T) { + err := src.ConvertToOpenApi("../../docs/swagger.json", "../../docs/openapi.json", true) + if err != nil { + t.FailNow() + } +}