imgur

package
v0.0.0-...-8a3b7d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LibraryVersion = "0.1"
)

const

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

Types

type Account

type Account struct {
	ID            int     `json:"id,omitempty"`
	Url           string  `json:"url,omitempty"`
	Bio           string  `json:"bio,omitempty"`
	Reputation    float32 `json:"reputation,omitempty"`
	Created       int     `json:"created,omitempty"`
	ProExpiration bool    `json:"pro_expiration,omitempty"`
}

Account Model

type AccountResponse

type AccountResponse struct {
	Success bool    `json:"success,omitempty"`
	Status  int     `json:"status,omitempty"`
	Data    Account `json:"data,omitempty"`
}

AccountResponse

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

AccountService Imgur API docs: https://api.imgur.com/models/account

func (*AccountService) Account

func (s *AccountService) Account(username string) (*Account, *http.Response, error)

You can request the account information about any user.

type Album

type Album struct {
	ID     string  `json:"id,omitempty"`
	Title  string  `json:"title,omitempty"`
	Link   string  `json:"link,omitempty"`
	Images []Image `json:"images,omitempty"`
}

type AlbumResponse

type AlbumResponse struct {
	Success bool  `json:"success,omitempty"`
	Status  int   `json:"status,omitempty"`
	Data    Album `json:"data,omitempty"`
}

type AlbumService

type AlbumService struct {
	// contains filtered or unexported fields
}

AlbumService Digital Ocean API docs: https://api.imgur.com/models/album

func (*AlbumService) GetAlbum

func (s *AlbumService) GetAlbum(id string) (*Album, *http.Response, error)

type Client

type Client struct {
	Option *Option

	BaseURL   *url.URL
	UserAgent string

	GalleryService *GalleryService
	AccountService *AccountService
	AlbumService   *AlbumService
	// contains filtered or unexported fields
}

A Client manages communication with the Digital Ocean API.

func NewClient

func NewClient(option *Option) (*Client, error)

NewClient returns a new Imgur API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request.

type ErrorData

type ErrorData struct {
	Error   string `json:"error,omitempty"`
	Request string `json:"request,omitempty"`
	Method  string `json:"method,omitempty"`
}

ErrorData https://api.imgur.com/errorhandling

type ErrorResponse

type ErrorResponse struct {
	Response  *http.Response
	Success   bool `json:"success,omitempty"`
	Status    int  `json:"status,omitempty"`
	ErrorData ErrorData
}

An ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string
type Gallery struct {
	Images []Image `json:"images,omitempty"`
}

type GalleryAlbumResponse

type GalleryAlbumResponse struct {
	Success bool    `json:"success,omitempty"`
	Status  int     `json:"status,omitempty"`
	Data    []Image `json:"data,omitempty"`
}

type GalleryService

type GalleryService struct {
	// contains filtered or unexported fields
}

GalleryService Imgur API

func (*GalleryService) GetAlbum

func (s *GalleryService) GetAlbum() ([]Image, *http.Response, error)

func (*GalleryService) GetTag

func (s *GalleryService) GetTag(tagName string) (*Tag, *http.Response, error)

type GalleryTagResponse

type GalleryTagResponse struct {
	Success bool `json:"success,omitempty"`
	Status  int  `json:"status,omitempty"`
	Data    Tag  `json:"data,omitempty"`
}

type Image

type Image struct {
	ID   string `json:"id,omitempty"`
	Link string `json:"link,omitempty"`
}

type MockClient

type MockClient struct {
	Mux         *http.ServeMux
	Client      *Client
	Server      *httptest.Server
	FixturesDir string
}

A MockClient manages communication with the imgur API mock.

func NewMockClient

func NewMockClient() *MockClient

NewMockClient returns a new imgur API client mock.

func (*MockClient) Close

func (r *MockClient) Close()

Close Close Mocl

func (*MockClient) ReadJSON

func (r *MockClient) ReadJSON(filename string) string

ReadJSON Read json from file

type Option

type Option struct {
	ClientID string
}

Option Optional parameters

type ResponseStatus

type ResponseStatus struct {
	Success bool
	Status  int
}

An Response by API request.

type Tag

type Tag struct {
	Name       string  `json:"name,omitempty"`
	Followers  int     `json:"followers,omitempty"`
	TotalItems int     `json:"total_items,omitempty"`
	Images     []Image `json:"items,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL