Documentation ¶
Overview ¶
Package api is the implementation of the DeviantArt API including the authentication using the Implicit Grant OAuth2
Index ¶
- Constants
- type BrowseTags
- type Collection
- type DeviantartAPI
- func (a *DeviantartAPI) AddRoundTrippers()
- func (a *DeviantartAPI) BrowseTags(tag string, offset uint, limit uint) (*BrowseTags, error)
- func (a *DeviantartAPI) Collection(user string, folderID string, offset uint, limit uint) (*Collection, error)
- func (a *DeviantartAPI) CollectionFolderIDToUUID(username string, folderID int) (string, error)
- func (a *DeviantartAPI) CollectionFolders(user string, offset uint, limit uint) (*Folders, error)
- func (a *DeviantartAPI) CollectionNameFromID(username string, folderID int) (string, error)
- func (a *DeviantartAPI) CollectionNameFromURL(feURL string) (string, error)
- func (a *DeviantartAPI) CollectionNameFromUUID(username string, folderUUID string) (string, error)
- func (a *DeviantartAPI) DeviationContent(deviationID string) (*DeviationContent, error)
- func (a *DeviantartAPI) DeviationDownload(deviationID string) (*DeviationDownload, error)
- func (a *DeviantartAPI) DeviationDownloadFallback(deviationURL string) (*DeviationDownload, error)
- func (a *DeviantartAPI) FeedHome(cursor string) (*FeedBucketResponse, error)
- func (a *DeviantartAPI) FeedHomeBucket(bucketID string, offset uint) (*FeedBucketResponse, error)
- func (a *DeviantartAPI) Gallery(user string, folderID string, offset uint, limit uint) (*GalleryResponse, error)
- func (a *DeviantartAPI) GalleryAll(user string, offset uint, limit uint) (*GalleryResponse, error)
- func (a *DeviantartAPI) GalleryFolderIDToUUID(username string, folderID int) (string, error)
- func (a *DeviantartAPI) GalleryFolders(user string, offset uint, limit uint) (*Folders, error)
- func (a *DeviantartAPI) GalleryNameFromID(username string, folderID int) (string, error)
- func (a *DeviantartAPI) Placebo() (*Placebo, error)
- type Deviation
- type DeviationContent
- type DeviationDownload
- type Error
- type FeedBucketResponse
- type Folder
- type Folders
- type GalleryResponse
- type ImplicitGrantDeviantart
- type PaginatedResults
- type Placebo
Constants ¶
const BucketDeviationSubmitted = "deviation_submitted"
BucketDeviationSubmitted is the bucket ID for your deviation feed
const MaxDeviationsPerPage = 24
MaxDeviationsPerPage is the maximum amount of results you can retrieve from the API in one request
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrowseTags ¶
type BrowseTags struct {
PaginatedResults
}
BrowseTags contains all relevant information of the API response of the browse function of the tags endpoint
type Collection ¶
type Collection struct {
PaginatedResults
}
Collection contains all relevant information of the API response of the collections endpoint
type DeviantartAPI ¶
type DeviantartAPI struct { Session watcherHttp.SessionInterface OAuth2Config *oauth2.Config // contains filtered or unexported fields }
DeviantartAPI contains all required items to communicate with the API
func NewDeviantartAPI ¶
func NewDeviantartAPI(moduleKey string, account *models.Account) *DeviantartAPI
NewDeviantartAPI returns the settings of the DeviantArt API
func (*DeviantartAPI) AddRoundTrippers ¶
func (a *DeviantartAPI) AddRoundTrippers()
AddRoundTrippers adds the round trippers for CloudFlare, adds a custom user agent and implements the implicit OAuth2 authentication and sets the Token round tripper
func (*DeviantartAPI) BrowseTags ¶
func (a *DeviantartAPI) BrowseTags(tag string, offset uint, limit uint) (*BrowseTags, error)
BrowseTags implements the API endpoint https://www.deviantart.com/api/v1/oauth2/browse/tags
func (*DeviantartAPI) Collection ¶
func (a *DeviantartAPI) Collection(user string, folderID string, offset uint, limit uint) (*Collection, error)
Collection implements the API endpoint https://www.deviantart.com/api/v1/oauth2/collections/{folderid}
func (*DeviantartAPI) CollectionFolderIDToUUID ¶
func (a *DeviantartAPI) CollectionFolderIDToUUID(username string, folderID int) (string, error)
CollectionFolderIDToUUID converts an integer folder ID in combination with the username to the API format folder UUID nolint: dupl
func (*DeviantartAPI) CollectionFolders ¶
CollectionFolders implements the API endpoint https://www.deviantart.com/api/v1/oauth2/collections/folders
func (*DeviantartAPI) CollectionNameFromID ¶
func (a *DeviantartAPI) CollectionNameFromID(username string, folderID int) (string, error)
CollectionNameFromID returns the title of the collection extracted from the frontend, only works with integer IDs
func (*DeviantartAPI) CollectionNameFromURL ¶
func (a *DeviantartAPI) CollectionNameFromURL(feURL string) (string, error)
CollectionNameFromURL returns the collection name from the passed URL with the Eclipse theme
func (*DeviantartAPI) CollectionNameFromUUID ¶
func (a *DeviantartAPI) CollectionNameFromUUID(username string, folderUUID string) (string, error)
CollectionNameFromUUID returns the collection name based on the collection folder UUID
func (*DeviantartAPI) DeviationContent ¶
func (a *DeviantartAPI) DeviationContent(deviationID string) (*DeviationContent, error)
DeviationContent implements the API endpoint https://www.deviantart.com/api/v1/oauth2/deviation/content
func (*DeviantartAPI) DeviationDownload ¶
func (a *DeviantartAPI) DeviationDownload(deviationID string) (*DeviationDownload, error)
DeviationDownload implements the API endpoint https://www.deviantart.com/api/v1/oauth2/deviation/download/{deviationid}
func (*DeviantartAPI) DeviationDownloadFallback ¶
func (a *DeviantartAPI) DeviationDownloadFallback(deviationURL string) (*DeviationDownload, error)
DeviationDownloadFallback is a fallback solution for the API endpoint https://www.deviantart.com/api/v1/oauth2/deviation/download/{deviationid} since the endpoint returns a lot of internal server error responses, while the web interface works properly
func (*DeviantartAPI) FeedHome ¶
func (a *DeviantartAPI) FeedHome(cursor string) (*FeedBucketResponse, error)
FeedHome implements the API endpoint https://www.deviantart.com/api/v1/oauth2/feed/home/
func (*DeviantartAPI) FeedHomeBucket ¶
func (a *DeviantartAPI) FeedHomeBucket(bucketID string, offset uint) (*FeedBucketResponse, error)
FeedHomeBucket implements the API endpoint https://www.deviantart.com/api/v1/oauth2/feed/home/{bucketid}
func (*DeviantartAPI) Gallery ¶
func (a *DeviantartAPI) Gallery(user string, folderID string, offset uint, limit uint) (*GalleryResponse, error)
Gallery implements the API endpoint https://www.deviantart.com/api/v1/oauth2/gallery/{folderID}
func (*DeviantartAPI) GalleryAll ¶
func (a *DeviantartAPI) GalleryAll(user string, offset uint, limit uint) (*GalleryResponse, error)
GalleryAll implements the API endpoint https://www.deviantart.com/api/v1/oauth2/gallery/all
func (*DeviantartAPI) GalleryFolderIDToUUID ¶
func (a *DeviantartAPI) GalleryFolderIDToUUID(username string, folderID int) (string, error)
GalleryFolderIDToUUID converts an integer folder ID in combination with the username to the API format folder UUID nolint: dupl
func (*DeviantartAPI) GalleryFolders ¶
GalleryFolders implements the API endpoint https://www.deviantart.com/api/v1/oauth2/gallery/folders
func (*DeviantartAPI) GalleryNameFromID ¶
func (a *DeviantartAPI) GalleryNameFromID(username string, folderID int) (string, error)
GalleryNameFromID returns the title of the gallery extracted from the frontend, only works with integer IDs
func (*DeviantartAPI) Placebo ¶
func (a *DeviantartAPI) Placebo() (*Placebo, error)
Placebo implements the API endpoint https://www.deviantart.com/api/v1/oauth2/placebo
type Deviation ¶
type Deviation struct { Author struct { UserID string `json:"userid"` Username string `json:"username"` } `json:"author"` Content *struct { Src string `json:"src"` } `json:"content"` Flash *struct { Src string `json:"src"` } `json:"flash"` Thumbs []struct { Src string `json:"src"` } `json:"thumbs"` // used for comparison of thumbs and and download, not actually returned by the API DeviationDownload *DeviationDownload DeviationID string `json:"deviationid"` DeviationURL string `json:"url"` Title string `json:"title"` PublishedTime string `json:"published_time"` Excerpt *string `json:"excerpt"` IsDownloadable bool `json:"is_downloadable"` }
Deviation contains all relevant information on artworks/deviations returned from the API
type DeviationContent ¶
type DeviationContent struct {
HTML string `json:"html"`
}
DeviationContent contains all relevant information of the deviation content response of the API
type DeviationDownload ¶
type DeviationDownload struct {
Src string `json:"src"`
}
DeviationDownload contains all relevant information of the deviation download response of the API
type Error ¶
type Error struct { ErrorMessage string `json:"error"` ErrorDescription string `json:"error_description"` ErrorDetails map[string]string `json:"error_details"` ErrorCode json.Number `json:"error_code"` Status string `json:"status"` }
Error is the struct of the error API responses
type FeedBucketResponse ¶
type FeedBucketResponse struct { Items []struct { Timestamp string `json:"ts"` ByUser struct { UserID string `json:"userid"` Username string `json:"username"` } `json:"by_user"` Deviations []*Deviation `json:"deviations"` } `json:"items"` Cursor string `json:"cursor"` HasMore bool `json:"has_more"` }
FeedBucketResponse contains the next cursor and the items of the current bucket at cursor position
type Folder ¶
Folder contains all available information of the API response regarding to the folder information
type Folders ¶
type Folders struct { Results []Folder `json:"results"` HasMore bool `json:"has_more"` NextOffset *int `json:"next_offset"` }
Folders contains all relevant information of the API response of the folders function of the collection and gallery endpoint
type GalleryResponse ¶
type GalleryResponse struct {
PaginatedResults
}
GalleryResponse contains all relevant information from the functions of the gallery endpoint
type ImplicitGrantDeviantart ¶
type ImplicitGrantDeviantart struct { implicitoauth2.ImplicitGrant // contains filtered or unexported fields }
ImplicitGrantDeviantart is the implementation of the ImplicitGrant interface
func NewImplicitGrantDeviantart ¶
func NewImplicitGrantDeviantart( cfg *oauth2.Config, client *http.Client, account *models.Account, ) *ImplicitGrantDeviantart
NewImplicitGrantDeviantart returns the ImplicitGrantDeviantArt struct implementing the Implicit Grant OAuth2 flow
func (*ImplicitGrantDeviantart) Authorize ¶
func (g *ImplicitGrantDeviantart) Authorize() error
Authorize implements the interface function of the Implicit Grant OAuth2 flow for DeviantArt (only new style)
func (*ImplicitGrantDeviantart) Login ¶
func (g *ImplicitGrantDeviantart) Login() error
Login implements the interface function of the Implicit Grant OAuth2 flow for DeviantArt