five00px

package
v0.0.0-...-80a41e0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2016 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package five00px provides ...

Package five00px provides ...

Package five00px provides ...

Package five00px provides main 500px API implementation

Package five00px provides ...

Package five00px provides ...

Package five00px provides ...

Package five00px provides ...

Package five00px provides ...

Package five00px provides ...

Index

Constants

View Source
const (
	FeaturePopular        = Feature("popular")
	FeatureHRated         = Feature("highest_rated")
	FeatureUpcoming       = Feature("upcoming")
	FeatureEditors        = Feature("editors")
	FeatureFreshToday     = Feature("fresh_today")
	FeatureFreshYesterday = Feature("fresh_yesterday")
	FeatureFreshWeek      = Feature("fresh_week")

	Size70x70   = Size(1)
	Size140x140 = Size(2)
	Size280x280 = Size(3)
	Size900l    = Size(4)

	CategoryAll              = Category(-1)
	CategoryUncategorized    = Category(0)
	CategoryAbstract         = Category(10)
	CategoryAnimals          = Category(11)
	CategoryBW               = Category(5)
	CategoryCelebrities      = Category(1)
	CategoryArch             = Category(9)
	CategoryCommercial       = Category(15)
	CategoryConcert          = Category(16)
	CategoryFamily           = Category(20)
	CategoryFashion          = Category(14)
	CategoryFilm             = Category(2)
	CategoryFineArt          = Category(24)
	CategoryFood             = Category(23)
	CategoryJournalism       = Category(3)
	CategoryLandscapes       = Category(8)
	CategoryMacro            = Category(12)
	CategoryNature           = Category(18)
	CategoryNude             = Category(4)
	CategoryPeople           = Category(7)
	CategoryPerformingArts   = Category(19)
	CategorySport            = Category(17)
	CategoryStillLife        = Category(6)
	CategoryStreet           = Category(21)
	CategoryTransportation   = Category(26)
	CategoryTravel           = Category(13)
	CategoryUnderwater       = Category(22)
	CategoryUrbanExploration = Category(27)
	CategoryWedding          = Category(25)

	SortByCreatedAt     = SortBy("created_at")
	SortByRating        = SortBy("rating")
	SortByHighestRating = SortBy("highest_rating")
	SortByTimesViewed   = SortBy("times_viewed")
	SortByVotesCount    = SortBy("votes_count")
	SortByCommentsCount = SortBy("comments_count")
	SortByTakenAt       = SortBy("taken_at")

	SortOrderAsk  = SortOrder("ask")
	SortOrderDesk = SortOrder("desk")

	UnitsKm = Units("km")
	UnitsMi = Units("mi")

	LicAll                   = License(-1)
	Lic500px                 = License(0)
	LicCrCommonNonComAttr    = License(1)
	LicCrCommonNonComNoDeriv = License(2)
	LicCrCommonNonComShare   = License(3)
	LicCrCommonAttr          = License(4)
	LicCrCommonNoDeriv       = License(5)
	LicCrCommonShare         = License(6)
)

Constants

Variables

View Source
var ErrAuth = errors.New("Authentication error")
View Source
var ErrBadComment = errors.New("The body of the comment was not specified")

ErrBadComment ...

View Source
var ErrInternal = errors.New("Internal error")

ErrInternal ...

View Source
var ErrInvalidInput = errors.New("Invalid user input")

ErrInvalidInput ...

View Source
var ErrPhotoNotAvailable = errors.New("The photo was either deleted, belongs to a deactivated user")

ErrPhotoNotAvailable ...

View Source
var ErrPhotoNotFound = errors.New("Photo with the specified ID does not exist")

ErrPhotoNotFound ...

View Source
var ErrUnprocessableEntity = errors.New("The system had trouble saving the record. You may retry again.")

ErrUnprocessableEntity ...

View Source
var ErrUserAlreadyFriend = errors.New("The user requested has been disabled or already in followers list")

ErrUserAlreadyFriend ...

View Source
var ErrUserNotFound = errors.New("User does not exist in our database")

ErrUserNotFound ...

View Source
var ErrUserNotFriend = errors.New("The user requested has been disabled or not in followers list")

ErrUserNotFriend ...

View Source
var ErrVoteRejected = errors.New("The vote has been rejected; common reasons are:" +
	" current user is inactive, has not completed their profile, is trying to vote" +
	" on their own photo, or has already voted for the photo")

ErrVoteRejected ...

Functions

This section is empty.

Types

type AccessToken

type AccessToken oauth.AccessToken

AccessToken is an alias for oauth.AccessToken structure

type Auth

type Auth struct {
	Facebook     int `json:"facebook"`
	GoogleOauth2 int `json:"google_oauth2"`
	Twitter      int `json:"twitter"`
}

Auth structure contains dictionary of a user's social network authentications.

type Avatars

type Avatars struct {
	Default URLInfo `json:"default"`
	Large   URLInfo `json:"large"`
	Small   URLInfo `json:"small"`
	Tiny    URLInfo `json:"tiny"`
}

Avatars is a dictionary of different avatar sizes

type Categories

type Categories []Category

Categories helper type

func (Categories) String

func (c Categories) String() string

String representation of Categories

func (Categories) Valid

func (c Categories) Valid() bool

Valid if Categories contains valid values

type Category

type Category int

Category helper type

func (Category) String

func (c Category) String() string

String representation for Category

func (Category) Valid

func (c Category) Valid() bool

Valid if Category contains valid values

type Comment

type Comment struct {
	Body         string `json:"body"`
	CreatedAt    string `json:"created_at"`
	Flagged      bool   `json:"flagged"`
	ID           int    `json:"id"`
	ParentID     int    `json:"parent_id"`
	Rating       int    `json:"rating"`
	ToWhomUserID int    `json:"to_whom_user_id"`
	User         User   `json:"user"`
	UserID       int    `json:"user_id"`
	Voted        bool   `json:"voted"`
}

Comment representation

type Comments

type Comments struct {
	MediaType   string    `json:"media_type"`
	CurrentPage int       `json:"current_page"`
	TotalItems  int       `json:"total_items"`
	TotalPages  int       `json:"total_pages"`
	Comments    []Comment `json:"comments"`
}

Comments contains list of comments

type Contacts

type Contacts struct {
	Facebook     string `json:"facebook"`
	Facebookpage string `json:"facebookpage"`
	Googleplus   string `json:"googleplus"`
	Skype        string `json:"skype"`
	Twitter      string `json:"twitter"`
	Website      string `json:"website"`
}

Contacts structure contacts dictionary of user’s contacts, object

type Equipment

type Equipment struct {
	Camera []string `json:"camera"`
	Lens   []string `json:"lens"`
	Misc   []string `json:"misc"`
}

Equipment structure contains dictionary of a user's equipment

type Feature

type Feature string

Feature helper type

func (Feature) String

func (f Feature) String() string

Feature to string

func (Feature) Valid

func (f Feature) Valid() bool

Valid if Feature contains valid value

type Filters

type Filters struct {
	Category interface{} `json:"category"`
	Exclude  interface{} `json:"exclude"`
}

Filters NOTE: Category and Exclude are interfaces as they could be false or int values

type Five00px

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

Five00px client

func New

func New(key, secret string, log *logrus.Logger) Five00px

New call creates and initiate Five00px object. ConsumerKey and ConsumerSecret have to be provided by user

func (*Five00px) AddComment

func (f00 *Five00px) AddComment(id int, comment string) error

AddComment call adds new comment to selected photo

func (*Five00px) AddFriend

func (f00 *Five00px) AddFriend(id int) (*User, error)

AddFriend call adds new friend by user ID. Returns errors: ErrUserNotFound and ErrUserAlreadyFriend

func (*Five00px) AddPhoto

func (f00 *Five00px) AddPhoto(info UploadInfo) (*Photo, error)

AddPhoto call uploads new photo. Information about uploaded photo or upload error will be returned

func (*Five00px) AddVote

func (f00 *Five00px) AddVote(id int, like bool) error

AddVote adds/removes vote from selected photo

func (*Five00px) Auth

func (f00 *Five00px) Auth() (*AccessToken, error)

Auth initiate OAuth authentication call. Default Web broser will be popped up during authentication. Store AccessToken for futher usage with Restore API call. Returns error on authorization failure.

func (*Five00px) DelFriend

func (f00 *Five00px) DelFriend(id int) (*User, error)

DelFriend call deletes friend by user ID. Returns errors: ErrUserNotFound and ErrUserNotFriend

func (*Five00px) DelPhoto

func (f00 *Five00px) DelPhoto(id int) error

DelPhoto removes photo by id

func (*Five00px) GetPhotoByID

func (f00 *Five00px) GetPhotoByID(id int, info *PhotoInfo) (*Photo, error)

GetPhotoByID returns photo by its ID. info may contains additional photo criterias

func (*Five00px) GetUserByEmail

func (f00 *Five00px) GetUserByEmail(email string) (*User, error)

GetUserByEmail returns User struct for a user specified by email.

func (*Five00px) GetUserByID

func (f00 *Five00px) GetUserByID(id int) (*User, error)

GetUserByID call returns User struct for a user specified by id. If id == 0 returns the profile information for the current user.

func (*Five00px) GetUserByName

func (f00 *Five00px) GetUserByName(name string) (*User, error)

GetUserByName returns User struct for a user specified by name.

func (*Five00px) ListComments

func (f00 *Five00px) ListComments(id int, p *Page) (*Comments, error)

ListComments call returns cammonts for selected photo.

func (*Five00px) ListFollowers

func (f00 *Five00px) ListFollowers(id int, p *Page) (*Followers, error)

ListFollowers call returns list of followers for a user specified by ID.

func (*Five00px) ListFriends

func (f00 *Five00px) ListFriends(id int, p *Page) (*Friends, error)

ListFriends call returns list of friends for a user specified by ID.

func (*Five00px) ListPhotos

func (f00 *Five00px) ListPhotos(c StreamCriterias, p *Page) (*Photos, error)

ListPhotos call returns a list of photos for specified phot stream

func (*Five00px) ListVotes

func (f00 *Five00px) ListVotes(id int, p *Page) (*Votes, error)

ListVotes call returns votes fpr selected photo.

func (*Five00px) Restore

func (f00 *Five00px) Restore(t *AccessToken) error

Restore call restores OAuth session without additional authentication call. Does not require to show any additional requests.

func (*Five00px) SearchPhoto

func (f00 *Five00px) SearchPhoto(c SearchCriterias, p *Page) (*Photos, error)

SearchPhoto searches for specific photos

func (*Five00px) SearchUser

func (f00 *Five00px) SearchUser(term string, p *Page) (*Search, error)

SearchUser call returns list of users (up to one hundred) users from search results for a specified search term

type Followers

type Followers struct {
	Users          []User `json:"followers"`
	FollowersCount int    `json:"followers_count"`
	FollowersPages int    `json:"followers_pages"`
	Page           int    `json:"page"`
}

Followers structure is a list of followers for the specified user

type Friends

type Friends struct {
	Users        []User `json:"friends"`
	FriendsCount int    `json:"friends_count"`
	FriendsPages int    `json:"friends_pages"`
	Page         int    `json:"page"`
}

Friends structure is a list of friends for the specified user

type Geo

type Geo struct {
	Latitude  string
	Longitude string
	Radius    string
	Units     Units
}

Geo geo-location point

func (Geo) String

func (g Geo) String() string

String representation for distance units

func (Geo) Valid

func (g Geo) Valid() bool

Valid units are km and mi

type License

type License int

License type

func (License) String

func (l License) String() string

String representation for license

func (License) Valid

func (l License) Valid() bool

Valid license type

type Page

type Page struct {
	Rpp  int
	Page int
}

Page structure stores RPP(Results Per Page) and Page(Return the specified page of the resource) values.

func NewPage

func NewPage() Page

NewPage call returns Page with 500px default values `Results Per Page` 20 and `Page` 1

func (*Page) Vals

func (p *Page) Vals() url.Values

Vals converts Page to url.Values

type Photo

type Photo struct {
	Aperture               string      `json:"aperture"`
	Camera                 string      `json:"camera"`
	Category               Category    `json:"category"`
	CollectionsCount       int         `json:"collections_count"`
	Comments               []Comment   `json:"comments"`
	CommentsCount          int         `json:"comments_count"`
	Converted              interface{} `json:"converted"`
	ConvertedBits          int         `json:"converted_bits"`
	CreatedAt              string      `json:"created_at"`
	CropVersion            int         `json:"crop_version"`
	Description            string      `json:"description"`
	Disliked               bool        `json:"disliked"`
	Favorited              bool        `json:"favorited"`
	FavoritesCount         int         `json:"favorites_count"`
	FocalLength            string      `json:"focal_length"`
	ForSale                bool        `json:"for_sale"`
	ForSaleDate            string      `json:"for_sale_date"`
	Height                 int         `json:"height"`
	HiResUploaded          int         `json:"hi_res_uploaded"`
	HighestRating          float32     `json:"highest_rating"`
	HighestRatingDate      string      `json:"highest_rating_date"`
	ID                     int         `json:"id"`
	ImageFormat            string      `json:"image_format"`
	ImageURL               string      `json:"image_url"`
	Iso                    string      `json:"iso"`
	Latitude               float32     `json:"latitude"`
	Lens                   string      `json:"lens"`
	LicenseRequestsEnabled bool        `json:"license_requests_enabled"`
	LicenseType            int         `json:"license_type"`
	LicensingRequested     bool        `json:"licensing_requested"`
	Liked                  bool        `json:"liked"`
	Location               string      `json:"location"`
	Longitude              float32     `json:"longitude"`
	Name                   string      `json:"name"`
	Nsfw                   bool        `json:"nsfw"`
	PositiveVotesCount     int         `json:"positive_votes_count"`
	Privacy                bool        `json:"privacy"`
	Profile                bool        `json:"profile"`
	Purchased              bool        `json:"purchased"`
	Rating                 float32     `json:"rating"`
	RequestToBuyEnabled    bool        `json:"request_to_buy_enabled"`
	SalesCount             int         `json:"sales_count"`
	ShutterSpeed           string      `json:"shutter_speed"`
	Status                 int         `json:"status"`
	StoreDownload          bool        `json:"store_download"`
	StoreLicense           bool        `json:"store_license"`
	StorePrint             bool        `json:"store_print"`
	Tags                   []string    `json:"tags"`
	TakenAt                string      `json:"taken_at"`
	TimesViewed            int         `json:"times_viewed"`
	URL                    string      `json:"url"`
	User                   User        `json:"user"`
	UserID                 int         `json:"user_id"`
	Voted                  bool        `json:"voted"`
	VotesCount             int         `json:"votes_count"`
	Watermark              bool        `json:"watermark"`
	Width                  int         `json:"width"`
}

Photo is an array of photos for selected criterias

type PhotoInfo

type PhotoInfo struct {
	ImageSize    Size
	Comments     bool
	CommentsPage int
}

PhotoInfo is used for providing extra information about photo

func (*PhotoInfo) Vals

func (p *PhotoInfo) Vals() url.Values

Vals representation for PhotoInfo

type Photos

type Photos struct {
	CurrentPage int     `json:"current_page"`
	Feature     Feature `json:"feature"`
	Filters     Filters `json:"filters"`
	Photos      []Photo `json:"photos"`
	TotalItems  int     `json:"total_items"`
	TotalPages  int     `json:"total_pages"`
}

Photos structure contains a listing of (up to one hundred) photos for a specified photo stream.

type Search struct {
	Users       []User `json:"users"`
	CurrentPage int    `json:"current_page"`
	TotalPages  int    `json:"total_pages"`
	TotalItems  int    `json:"total_items"`
}

Search structure (up to one hundred) users from search results for a specified search term.

type SearchCriterias

type SearchCriterias struct {
	Term        string
	Tag         string
	Geo         Geo
	Only        Categories
	Exclude     Categories
	ImageSize   Size
	LicenseType License
	Sort        SortBy
}

SearchCriterias intro information for photo search request

func NewSearchCriterias

func NewSearchCriterias() *SearchCriterias

NewSearchCriterias is helper function for predefining vlaues for SearchCriterias

func (*SearchCriterias) Valid

func (s *SearchCriterias) Valid() bool

Valid if SearchCriterias contains acceptable values

func (*SearchCriterias) Vals

func (s *SearchCriterias) Vals() url.Values

Vals converts SearchCriterias to url.Values

type Size

type Size int

Size helper type

func (Size) String

func (s Size) String() string

Size to string

func (Size) Valid

func (s Size) Valid() bool

Valid if Size contains valid size

type SortBy

type SortBy string

SortBy helper type

func (SortBy) String

func (s SortBy) String() string

String representation for SortBy

func (SortBy) Valid

func (s SortBy) Valid() bool

Valid if SortBy contains acceptable value

type SortOrder

type SortOrder string

SortOrder helper type

func (SortOrder) String

func (s SortOrder) String() string

String representation for SortOrder

func (SortOrder) Valid

func (s SortOrder) Valid() bool

Valid if SortOrder contains acceptable value

type StreamCriterias

type StreamCriterias struct {
	Feature       Feature
	Only          Categories
	Exclude       Categories
	Sort          SortBy
	SortDirection SortOrder
	ImageSize     Size
}

StreamCriterias structure is used for photo stream selection

func NewStreamCriterias

func NewStreamCriterias() *StreamCriterias

NewStreamCriterias is helper function for predefining StreamCriterias values

func (*StreamCriterias) Valid

func (p *StreamCriterias) Valid() bool

Valid returns true if PhotoCriterias a valid for futher usage

func (*StreamCriterias) Vals

func (p *StreamCriterias) Vals() url.Values

Vals converts PhotoCriterias to url.Values

type URLInfo

type URLInfo struct {
	HTTP  string `json:"http"`
	HTTPS string `json:"https"`
}

URLInfo is used in Avatars structure

type Units

type Units string

Units helper type

func (Units) String

func (u Units) String() string

func (Units) Valid

func (u Units) Valid() bool

Valid units are km and mi

type UploadInfo

type UploadInfo struct {
	FileName     string
	PhotoStream  io.Reader
	Aperture     string
	Camera       string
	Category     Category
	Description  string
	FocalLength  string
	Iso          string
	Latitude     float32
	Lens         string
	Longitude    float32
	Name         string
	Privacy      bool
	ShutterSpeed string
	Tags         []string
}

UploadInfo contains values for new photo uploading

func (*UploadInfo) Valid

func (i *UploadInfo) Valid() bool

Valid uf UploadInfo contains acceptable values

func (*UploadInfo) Vals

func (i *UploadInfo) Vals() url.Values

Vals representation for UploadInfo

type User

type User struct {
	About               string    `json:"about"`
	Affection           int       `json:"affection"`
	AllowSaleRequests   int       `json:"allow_sale_requests"`
	AnalyticsCode       string    `json:"analytics_code"`
	Auth                Auth      `json:"auth"`
	Avatars             Avatars   `json:"avatars"`
	Birthday            string    `json:"birthday"`
	City                string    `json:"city"`
	Contacts            Contacts  `json:"contacts"`
	Country             string    `json:"country"`
	CoverURL            string    `json:"cover_url"`
	Domain              string    `json:"domain"`
	Email               string    `json:"email"`
	Equipment           Equipment `json:"equipment"`
	Firstname           string    `json:"firstname"`
	FollowersCount      int       `json:"followers_count"`
	Following           bool      `json:"following"`
	FotomotoOn          bool      `json:"fotomoto_on"`
	FriendsCount        int       `json:"friends_count"`
	Fullname            string    `json:"fullname"`
	GalleriesCount      int       `json:"galleries_count"`
	ID                  int       `json:"id"`
	InFavoritesCount    int       `json:"in_favorites_count"`
	InviteAccepted      bool      `json:"invite_accepted"`
	InvitePending       bool      `json:"invite_pending"`
	Lastname            string    `json:"lastname"`
	Locale              string    `json:"locale"`
	PhotosCount         int       `json:"photos_count"`
	RegistrationDate    string    `json:"registration_date"`
	Sex                 int       `json:"sex"`
	ShowNude            bool      `json:"show_nude"`
	State               string    `json:"state"`
	StoreOn             bool      `json:"store_on"`
	UpgradeStatus       int       `json:"upgrade_status"`
	UpgradeStatusExpiry string    `json:"upgrade_status_expiry"`
	UpgradeType         int       `json:"upgrade_type"`
	UploadLimit         int       `json:"upload_limit"`
	UploadLimitExpiry   string    `json:"upload_limit_expiry"`
	Username            string    `json:"username"`
	UserpicHTTPSURL     string    `json:"userpic_https_url"`
	UserpicURL          string    `json:"userpic_url"`
	Usertype            int       `json:"usertype"`
}

User 500px structure. See https://github.com/500px/api-documentation/blob/master/basics/formats_and_terms.md#full-format for additional information.

type Validator

type Validator interface {
	Valid() bool
}

Validator interface provides ability to test argument validity

type ValsConverter

type ValsConverter interface {
	Vals() url.Values
}

ValsConverter converts type to url.Values

type Votes

type Votes struct {
	CurrentPage int    `json:"current_page"`
	TotalItems  int    `json:"total_items"`
	TotalPages  int    `json:"total_pages"`
	Users       []User `json:"users"`
}

Votes contains list of voted Users

Jump to

Keyboard shortcuts

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