unsplash

package
v0.0.0-...-474fc02 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 12 Imported by: 5

Documentation

Overview

Package unsplash provides a RESTful go binding for https//:unsplash.com API.

Usage

Use the following import path:

import "github.com/hbagdi/go-unsplash/unsplash"

Authentication

Authentication is not handled by directly by go-unsplash. Instead, pass an http.Client that can handle authentication for you. You can use libraries such as https://godoc.org/golang.org/x/oauth2. Please note that all calls will include the OAuth token and hence, http.Client should not be shared between users. Note that if you're just using actions that require the public permission scope, only the AppID is required.

Creating an instance

An instance of unsplash can be created using New(). The http.Client supplied will be used to make requests to the API.

ts := oauth2.StaticTokenSource(
  &oauth2.Token{AccessToken: "Your-access-token"},
)
client := oauth2.NewClient(oauth2.NoContext, ts)
//use the http.Client to instantiate unsplash
unsplash := unsplash.New(client)
// requests can be now made to the API
randomPhoto, _ , err := unsplash.RandomPhoto(nil)

Error handling

All API calls return an error as second or third return object. All successful calls will return nil in place of this return. Further, go-unsplash has errors defined as types for better error handling.

randomPhoto, _ , err := unsplash.RandomPhoto(nil)
if err != nil {
  //handle error
}

Pagination

Pagination is supported by supplying a page number in the ListOpt. The NextPage field in Response can be used to get the next page number.

var allPhotos []*unsplash.Photo
searchOpt := &unsplash.SearchOpt{Query: "Batman"}
for {
	photos, resp, err := unsplash.Search.Photos(searchOpt)

	if err != nil {
		return
	}

	allPhotos = append(allPhotos, photos)

	if !resp.HasNextPage {
		break
	}
	searchOpt.Page = resp.NextPage
}

Index

Constants

View Source
const (
	//Public is default; gives access to read public data.
	Public = "public"
	//ReadUser gives access to read user’s private data.
	ReadUser = "read_user"
	//WriteUser gives access to update the user’s profile.
	WriteUser = "write_user"
	//ReadPhotos gives acess to read private data from the user’s photos.
	ReadPhotos = "read_photos"
	//WritePhotos gives access to update photos on the user’s behalf.
	WritePhotos = "write_photos"
	//WriteLikes gives access to  like/unlike a photo on the user’s behalf.
	WriteLikes = "write_likes"
	//WriteFollowers gives access to follow or unfollow a user on the user’s behalf.
	WriteFollowers = "write_followers"
	//ReadCollections gives access to view a user’s private collections.
	ReadCollections = "read_collections"
	//WriteCollections gives access to create and update a users's collections.
	WriteCollections = "write_collections"
)

These are permission scopes for the Unsplash API for OAuth.

View Source
const (
	// GET is HTTP GET request
	GET method = "GET"
	// POST is HTTP POST request
	POST method = "POST"
	// PUT is HTTP PUT request
	PUT method = "PUT"
	// DELETE is HTTP DELETE request
	DELETE method = "DELETE"
)
View Source
const (
	Latest  = "latest"
	Oldest  = "oldest"
	Popular = "popular"
)

These constants should be used for OrderBy searches/results.

View Source
const (
	Landscape orientation = "landscape"
	Portrait  orientation = "portrait"
	Squarish  orientation = "squarish"
)

These constants show possible Orientation types

Variables

This section is empty.

Functions

func SetupBaseUrl

func SetupBaseUrl(url string)

Types

type AuthorizationError

type AuthorizationError struct {
	ErrString string
}

AuthorizationError occurs for an Unauthorized request

func (AuthorizationError) Error

func (e AuthorizationError) Error() string

type Collection

type Collection struct {
	ID           *int    `json:"id"`
	Title        *string `json:"title"`
	Description  *string `json:"description"`
	PublishedAt  *string `json:"published_at"`
	Curated      *bool   `json:"curated"`
	Featured     *bool   `json:"featured"`
	TotalPhotos  *int    `json:"total_photos"`
	Private      *bool   `json:"private"`
	ShareKey     *string `json:"share_key"`
	CoverPhoto   *Photo  `json:"cover_photo"`
	Photographer *User   `json:"user"`
	Links        *struct {
		Self    *URL `json:"self"`
		HTML    *URL `json:"html"`
		Photos  *URL `json:"photos"`
		Related *URL `json:"related"`
	} `json:"links"`
}

Collection holds a collection on unsplash.com

func (*Collection) String

func (c *Collection) String() string

type CollectionOpt

type CollectionOpt struct {
	Title       *string `url:"title,omitempty"`
	Description *string `url:"description,omitempty"`
	Private     *bool   `url:"private,omitempty"`
}

CollectionOpt shows various available optional parameters available during creatioin of collection

type CollectionSearchResult

type CollectionSearchResult struct {
	Total      *int          `json:"total"`
	TotalPages *int          `json:"total_pages"`
	Results    *[]Collection `json:"results"`
}

CollectionSearchResult represnts the result for a search for collections.

type CollectionsService

type CollectionsService service

CollectionsService interacts with /users endpoint

func (*CollectionsService) AddPhoto

func (cs *CollectionsService) AddPhoto(collectionID int, photoID string) (*Response, error)

AddPhoto adds a photo to a collection owned by an authenticated user.

func (*CollectionsService) All

func (cs *CollectionsService) All(opt *ListOpt) (*[]Collection, *Response, error)

All returns a list of all collections on unsplash. Note that some fields in collection structs from this result will be missing. Use Collection() method to get all details of the Collection.

func (*CollectionsService) Collection

func (cs *CollectionsService) Collection(id string) (*Collection, *Response, error)

Collection returns a collection with id.

func (*CollectionsService) Create

func (cs *CollectionsService) Create(opt *CollectionOpt) (*Collection, *Response, error)

Create creates a new collection on the authenticated user's profile.

func (*CollectionsService) Curated

func (cs *CollectionsService) Curated(opt *ListOpt) (*[]Collection, *Response, error)

Curated returns a list of curated collections on unsplash. Note that some fields in collection structs from this result will be missing. Use Collection() method to get all details of the Collection.

func (*CollectionsService) Delete

func (cs *CollectionsService) Delete(collectionID int) (*Response, error)

Delete deletes a collection on the authenticated user's profile.

func (*CollectionsService) Featured

func (cs *CollectionsService) Featured(opt *ListOpt) (*[]Collection, *Response, error)

Featured returns a list of featured collections on unsplash. Note that some fields in collection structs from this result will be missing. Use Collection() method to get all details of the Collection.

func (*CollectionsService) Related

func (cs *CollectionsService) Related(id string, opt *ListOpt) (*[]Collection, *Response, error)

Related returns a list of collections related to collections with id.

func (*CollectionsService) RemovePhoto

func (cs *CollectionsService) RemovePhoto(collectionID int, photoID string) (*Response, error)

RemovePhoto removes a photo from a collection owned by an authenticated user.

func (*CollectionsService) Update

func (cs *CollectionsService) Update(collectionID int, opt *CollectionOpt) (*Collection, *Response, error)

Update updates an existing collection on the authenticated user's profile.

type ExifData

type ExifData struct {
	Make         *string `json:"make"`
	Model        *string `json:"model"`
	ExposureTime *string `json:"exposure_time"`
	Aperture     *string `json:"aperture"`
	FocalLength  *string `json:"focal_length"`
	Iso          *int    `json:"iso"`
}

ExifData for an image

type GlobalStats

type GlobalStats struct {
	TotalPhotos        uint64
	PhotoDownloads     uint64
	Photos             uint64 `json:"photos,omitempty"`
	Downloads          uint64 `json:"downloads,omitempty"`
	Views              uint64 `json:"views,omitempty"`
	Likes              uint64 `json:"likes,omitempty"`
	Photographers      uint64 `json:"photographers,omitempty"`
	Pixels             uint64 `json:"pixels,omitempty"`
	DownloadsPerSecond uint64 `json:"downloads_per_second,omitempty"`
	ViewsPerSecond     uint64 `json:"views_per_second,omitempty"`
	Developers         uint64 `json:"developers,omitempty"`
	Applications       uint64 `json:"applications,omitempty"`
	Requests           uint64 `json:"requests,omitempty"`
}

GlobalStats shows the total photo stats of Unsplash.com

func (*GlobalStats) String

func (gs *GlobalStats) String() string

func (*GlobalStats) UnmarshalJSON

func (gs *GlobalStats) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON string representation of GlobalStats into a struct

type IllegalArgumentError

type IllegalArgumentError struct {
	ErrString string
}

IllegalArgumentError occurs when the argument to a function are messed up

func (IllegalArgumentError) Error

func (e IllegalArgumentError) Error() string

type InvalidListOptError

type InvalidListOptError struct {
	ErrString string
}

InvalidListOptError occurs when ListOpt.Valid() fails.

func (InvalidListOptError) Error

func (e InvalidListOptError) Error() string

type InvalidPhotoOptError

type InvalidPhotoOptError struct {
	ErrString string
}

InvalidPhotoOptError occurs when PhotoOpt.Valid() fails.

func (InvalidPhotoOptError) Error

func (e InvalidPhotoOptError) Error() string

type InvalidStatsOptError

type InvalidStatsOptError struct {
	ErrString string
}

InvalidStatsOptError occurs when StatsOpt.Valid() fails.

func (InvalidStatsOptError) Error

func (e InvalidStatsOptError) Error() string

type JSONUnmarshallingError

type JSONUnmarshallingError struct {
	ErrString string
}

JSONUnmarshallingError occurs due to a unmarshalling error

func (JSONUnmarshallingError) Error

func (e JSONUnmarshallingError) Error() string

type ListOpt

type ListOpt struct {
	Page    int    `url:"page"`
	PerPage int    `url:"per_page"`
	OrderBy string `url:"order_by"`
}

ListOpt should be used for pagination over results

func (*ListOpt) String

func (opt *ListOpt) String() string

func (*ListOpt) Valid

func (opt *ListOpt) Valid() bool

Valid validates the values in a ListOpt

type MonthStats

type MonthStats struct {
	Downloads        uint64 `json:"downloads"`
	Views            uint64 `json:"views"`
	Likes            uint64 `json:"likes"`
	NewPhotos        uint64 `json:"new_photos"`
	NewPhotographers uint64 `json:"new_photographers"`
	NewPixels        uint64 `json:"new_pixels"`
	NewDevelopers    uint64 `json:"new_developers"`
	NewApplications  uint64 `json:"new_applications"`
	NewRequests      uint64 `json:"new_requests"`
}

MonthStats shows the overall Unsplash stats for the past 30 days.

func (*MonthStats) String

func (stats *MonthStats) String() string

func (*MonthStats) UnmarshalJSON

func (stats *MonthStats) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON string representation of GlobalStats into a struct

type NotFoundError

type NotFoundError struct {
	ErrString string
}

NotFoundError occurs when the resource queried returns a 404.

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Photo

type Photo struct {
	ID             *string    `json:"id"`
	CreatedAt      *time.Time `json:"created_at"`
	UpdatedAt      *time.Time `json:"updated_at"`
	Width          *int       `json:"width"`
	Height         *int       `json:"height"`
	Color          *string    `json:"color"`
	Description    *string    `json:"description"`
	AltDescription *string    `json:"alt_description"`
	Views          *int       `json:"views"`
	Downloads      *int       `json:"downloads"`
	Likes          *int       `json:"likes"`
	LikedByUser    *bool      `json:"liked_by_user"`
	Exif           *ExifData  `json:"exif"`
	Photographer   *User      `json:"user"`
	Location       *struct {
		Title    *string `json:"title"`
		Name     *string `json:"name"`
		City     *string `json:"city"`
		Country  *string `json:"country"`
		Position *struct {
			Latitude  *float64 `json:"latitude"`
			Longitude *float64 `json:"longitude"`
		} `json:"position"`
	} `json:"location"`
	Tags                   *[]Tag        `json:"tags"`
	CurrentUserCollections *[]Collection `json:"current_user_collections"`
	Urls                   *struct {
		Raw     *URL `json:"raw"`
		Full    *URL `json:"full"`
		Regular *URL `json:"regular"`
		Small   *URL `json:"small"`
		Thumb   *URL `json:"thumb"`
		Custom  *URL `json:"custom"`
	} `json:"urls"`
	Links *struct {
		Self             *URL `json:"self"`
		HTML             *URL `json:"html"`
		Download         *URL `json:"download"`
		DownloadLocation *URL `json:"download_location"`
	} `json:"links"`
}

Photo represents a photo on unsplash.com

func (*Photo) String

func (p *Photo) String() string

type PhotoOpt

type PhotoOpt struct {
	Height int `json:"h" url:"h"`
	Width  int `json:"w" url:"w"`
	CropX  int
	CropY  int
	Crop   bool
}

PhotoOpt denotes properties of any Image

func (*PhotoOpt) Valid

func (p *PhotoOpt) Valid() bool

Valid validates a PhotoOpt

type PhotoSearchResult

type PhotoSearchResult struct {
	Total      *int     `json:"total"`
	TotalPages *int     `json:"total_pages"`
	Results    *[]Photo `json:"results"`
}

PhotoSearchResult represnts the result for a search for photos.

type PhotoStatistics

type PhotoStatistics struct {
	ID        string `json:"id"`
	Downloads struct {
		Total      int `json:"total"`
		Historical struct {
			Change     int    `json:"change"`
			Resolution string `json:"resolution"`
			Quantity   int    `json:"quantity"`
			Values     []struct {
				Date  string `json:"date"`
				Value int    `json:"value"`
			} `json:"values"`
		} `json:"historical"`
	} `json:"downloads"`
	Views struct {
		Total      int `json:"total"`
		Historical struct {
			Change     int    `json:"change"`
			Resolution string `json:"resolution"`
			Quantity   int    `json:"quantity"`
			Values     []struct {
				Date  string `json:"date"`
				Value int    `json:"value"`
			} `json:"values"`
		} `json:"historical"`
	} `json:"views"`
	Likes struct {
		Total      int `json:"total"`
		Historical struct {
			Change     int    `json:"change"`
			Resolution string `json:"resolution"`
			Quantity   int    `json:"quantity"`
			Values     []struct {
				Date  string `json:"date"`
				Value int    `json:"value"`
			} `json:"values"`
		} `json:"historical"`
	} `json:"likes"`
}

PhotoStatistics represents statistics like downloads, views and likes of an unsplash photo

type PhotoStats

type PhotoStats struct {
	Downloads int `json:"downloads"`
	Likes     int `json:"likes"`
	Views     int `json:"views"`
	Links     struct {
		Self             string `json:"self"`
		HTML             string `json:"html"`
		Download         string `json:"download"`
		DownloadLocation string `json:"download_location"`
	} `json:"links"`
}

PhotoStats shows various stats of the photo returned by /photos/:id/stats endpoint

type PhotosService

type PhotosService service

PhotosService interacts with /photos endpoint

func (*PhotosService) All

func (ps *PhotosService) All(listOpt *ListOpt) (*[]Photo, *Response, error)

All returns a list of all photos on unsplash. Note that some fields in photo structs from this result will be missing. Use Photo() method to get all details of the Photo.

func (*PhotosService) Curated

func (ps *PhotosService) Curated(listOpt *ListOpt) (*[]Photo, *Response, error)

Curated return a list of all curated photos.

func (ps *PhotosService) DownloadLink(id string) (*URL, *Response, error)

DownloadLink return the download URL for a photo.

func (*PhotosService) Like

func (ps *PhotosService) Like(photoID string) (*Photo, *Response, error)

Like likes a photo on the currently authenticated user's behalf

func (*PhotosService) Photo

func (ps *PhotosService) Photo(id string, photoOpt *PhotoOpt) (*Photo, *Response, error)

Photo return a photo with id

func (*PhotosService) Random

func (ps *PhotosService) Random(opt *RandomPhotoOpt) (*[]Photo, *Response, error)

Random returns random photo(s). If opt is nil, then a single random photo is returned by default

func (*PhotosService) Statistics

func (ps *PhotosService) Statistics(id string, opt *StatsOpt) (*PhotoStatistics, *Response, error)

Statistics return a stats about a photo with id.

func (*PhotosService) Stats

func (ps *PhotosService) Stats(id string) (*PhotoStats, *Response, error)

Stats return a stats about a photo with id.

func (*PhotosService) Unlike

func (ps *PhotosService) Unlike(photoID string) (*Photo, *Response, error)

Unlike likes a photo on the currently authenticated user's behalf

type ProfileImage

type ProfileImage struct {
	Small  *URL `json:"small"`
	Medium *URL `json:"medium"`
	Large  *URL `json:"large"`
	Custom *URL `json:"custom"`
}

ProfileImage contains URLs to profile image of a user

type ProfileImageOpt

type ProfileImageOpt struct {
	Height int `json:"h,omitempty" url:"h"`
	Width  int `json:"w,omitempty" url:"w"`
}

ProfileImageOpt denotes properties of any Image

type RandomPhotoOpt

type RandomPhotoOpt struct {
	Height        int         `url:"h,omitempty"`
	Width         int         `url:"w,omitempty"`
	Featured      bool        `url:"featured,omitempty"`
	Username      string      `url:"username,omitempty"`
	SearchQuery   string      `url:"query,omitempty"`
	Count         int         `url:"count,omitempty"`
	Orientation   orientation `url:"orientation,omitempty"`
	CollectionIDs []int       `url:"collections,comma"`
	TopicIDs      []string    `url:"topics,comma"`
}

RandomPhotoOpt optional parameters for a random photo search

func (*RandomPhotoOpt) Valid

func (opt *RandomPhotoOpt) Valid() bool

Valid validates a RandomPhotoOpt

type RateLimitError

type RateLimitError struct {
	ErrString string
}

RateLimitError occurs when rate limit is reached for the API key.

func (RateLimitError) Error

func (e RateLimitError) Error() string

type Response

type Response struct {
	HasNextPage bool

	FirstPage, LastPage, NextPage, PrevPage int

	RateLimit          int
	RateLimitRemaining int
	// contains filtered or unexported fields
}

Response has pagination information whenever applicable

type SearchOpt

type SearchOpt struct {
	Page    int    `url:"page"`
	PerPage int    `url:"per_page"`
	Query   string `url:"query"`
}

SearchOpt should be used to query /search endpoint

func (*SearchOpt) Valid

func (opt *SearchOpt) Valid() bool

Valid validates a SearchOpt

type SearchService

type SearchService service

SearchService interacts with /search endpoint

func (*SearchService) Collections

func (ss *SearchService) Collections(opt *SearchOpt) (*CollectionSearchResult, *Response, error)

Collections queries the search endpoint to search for collections.

func (*SearchService) Photos

func (ss *SearchService) Photos(opt *SearchOpt) (*PhotoSearchResult, *Response, error)

Photos queries the search endpoint to search for photos.

func (*SearchService) Users

func (ss *SearchService) Users(opt *SearchOpt) (*UserSearchResult, *Response, error)

Users can be used to query any endpoint which returns an array of users.

type StatsOpt

type StatsOpt struct {
	Resolution string `url:"resolution"`
	Quantity   int    `url:"quantity"`
}

StatsOpt is used for custom statistics range

func (*StatsOpt) String

func (opt *StatsOpt) String() string

func (*StatsOpt) Valid

func (opt *StatsOpt) Valid() bool

Valid validates the values in a StatsOpt

type Tag

type Tag struct {
	Type  *string `json:"type"`
	Title *string `json:"title"`
}

Tag lists can be applied to any photo

type URL

type URL struct {
	*url.URL
}

URL is URL with custom JSON marshalling

func (*URL) MarshalJSON

func (u *URL) MarshalJSON() ([]byte, error)

MarshalJSON marshals the URL object into json string

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(b []byte) error

UnmarshalJSON takes a string and returns a URL struct

type Unsplash

type Unsplash struct {
	Users       *UsersService
	Photos      *PhotosService
	Collections *CollectionsService
	Search      *SearchService
	// contains filtered or unexported fields
}

Unsplash wraps the entire Unsplash.com API

func New

func New(client *http.Client) *Unsplash

New returns a new Unsplash struct

func NewWithClientID

func NewWithClientID(client *http.Client, client_id string) *Unsplash

New returns a new Unsplash struct using client_id for Authorization header This will only enable API that do not require user level authorization, but just application level.

func (*Unsplash) CurrentUser

func (u *Unsplash) CurrentUser() (*User, *Response, error)

CurrentUser returns details about the authenticated user

func (*Unsplash) MonthStats

func (u *Unsplash) MonthStats() (*MonthStats, *Response, error)

MonthStats returns various stats related to unsplash.com for last 30 days

func (*Unsplash) Stats

func (u *Unsplash) Stats() (*GlobalStats, *Response, error)

Stats gives the total photos,download since the inception of unsplash.com This method is DEPRECATED, USE TotalStats()

func (*Unsplash) TotalStats

func (u *Unsplash) TotalStats() (*GlobalStats, *Response, error)

TotalStats returns various stats related to unsplash.com since it's inception

func (*Unsplash) UpdateCurrentUser

func (u *Unsplash) UpdateCurrentUser(updateInfo *UserUpdateInfo) (*User, *Response, error)

UpdateCurrentUser updates the current user's private data and returns an update User struct

type User

type User struct {
	UID                 *string       `json:"uid"`
	ID                  *string       `json:"id"`
	Username            *string       `json:"username"`
	Name                *string       `json:"name"`
	FirstName           *string       `json:"first_name"`
	CompletedOnboarding *bool         `json:"completed_onboarding"`
	LastName            *string       `json:"last_name,omitempty"`
	PortfolioURL        *URL          `json:"portfolio_url"`
	Bio                 *string       `json:"bio"`
	Location            *string       `json:"location"`
	TotalLikes          *int          `json:"total_likes"`
	TotalPhotos         *int          `json:"total_photos"`
	TotalCollections    *int          `json:"total_collections"`
	FollowedByUser      *bool         `json:"followed_by_user"`
	NumericID           *int          `json:"numeric_id"`
	FollowersCount      *int          `json:"followers_count"`
	FollowingCount      *int          `json:"following_count"`
	Downloads           *int          `json:"downloads"`
	ProfileImage        *ProfileImage `json:"profile_image"`
	Badge               *UserBadge    `json:"badge"`
	Links               *UserLinks    `json:"links,omitempty"`
	Photos              *[]Photo      `json:"photos"`
	UpdatedAt           *string       `json:"updated_at"`
	InstagramUsername   *string       `json:"instagram_username"`
	TwitterUsername     *string       `json:"twitter_username"`
}

User represents a Unsplash.com user

func (*User) String

func (u *User) String() string

type UserBadge

type UserBadge struct {
	Title   *URL    `json:"title,omitempty"`
	Primary *bool   `json:"primary,omitempty"`
	Slug    *string `json:"slug,omitempty"`
	Link    *URL    `json:"link,omitempty"`
}

UserBadge contains information about badge for a user

type UserLinks struct {
	Followers *URL `json:"followers"`
	Following *URL `json:"following"`
	Self      *URL `json:"self"`
	HTML      *URL `json:"html"`
	Photos    *URL `json:"photos"`
	Likes     *URL `json:"likes"`
	Portfolio *URL `json:"portfolio"`
}

UserLinks contains URLs to

type UserSearchResult

type UserSearchResult struct {
	Total      *int    `json:"total"`
	TotalPages *int    `json:"total_pages"`
	Results    *[]User `json:"results"`
}

UserSearchResult represnts the result for a search for users.

type UserStatistics

type UserStatistics struct {
	Username  string `json:"username"`
	Downloads struct {
		Total      int `json:"total"`
		Historical struct {
			Change     int    `json:"change"`
			Average    int    `json:"average"`
			Resolution string `json:"resolution"`
			Quantity   int    `json:"quantity"`
			Values     []struct {
				Date  string `json:"date"`
				Value int    `json:"value"`
			} `json:"values"`
		} `json:"historical"`
	} `json:"downloads"`
	Views struct {
		Total      int `json:"total"`
		Historical struct {
			Change     int    `json:"change"`
			Average    int    `json:"average"`
			Resolution string `json:"resolution"`
			Quantity   int    `json:"quantity"`
			Values     []struct {
				Date  string `json:"date"`
				Value int    `json:"value"`
			} `json:"values"`
		} `json:"historical"`
	} `json:"views"`
	Likes struct {
		Total      int `json:"total"`
		Historical struct {
			Change     int    `json:"change"`
			Average    int    `json:"average"`
			Resolution string `json:"resolution"`
			Quantity   int    `json:"quantity"`
			Values     []struct {
				Date  string `json:"date"`
				Value int    `json:"value"`
			} `json:"values"`
		} `json:"historical"`
	} `json:"likes"`
}

UserStatistics represents statistics like downloads, views and likes of an unsplash user

type UserUpdateInfo

type UserUpdateInfo struct {
	Username          string `url:"username,omitempty"`
	FirstName         string `url:"first_name,omitempty"`
	LastName          string `url:"last_name,omitempty"`
	Bio               string `url:"bio,omitempty"`
	Email             string `url:"email,omitempty"`
	PortfolioURL      string `url:"url,omitempty"`
	Location          string `url:"location,omitempty"`
	InstagramUsername string `url:"instagram_username,omitempty"`
}

UserUpdateInfo is used to update private data of a user

func (*UserUpdateInfo) String

func (u *UserUpdateInfo) String() string

type UsersService

type UsersService service

UsersService interacts with /users endpoint

func (*UsersService) Collections

func (us *UsersService) Collections(username string, opt *ListOpt) (*[]Collection, *Response, error)

Collections return an array of user's collections.

func (*UsersService) LikedPhotos

func (us *UsersService) LikedPhotos(username string, opt *ListOpt) (*[]Photo, *Response, error)

LikedPhotos return an array of liked photos

func (*UsersService) Photos

func (us *UsersService) Photos(username string, opt *ListOpt) (*[]Photo, *Response, error)

Photos return an array of photos uploaded by the user.

func (*UsersService) Portfolio

func (us *UsersService) Portfolio(username string) (*URL, error)

Portfolio returns a User with username and optional profile image size ImageOpt

func (*UsersService) Statistics

func (us *UsersService) Statistics(username string, opt *StatsOpt) (*UserStatistics, *Response, error)

Statistics return a stats about a photo with id.

func (*UsersService) User

func (us *UsersService) User(username string, imageOpt *ProfileImageOpt) (*User, error)

User returns a User with username and optional profile image size ImageOpt

Jump to

Keyboard shortcuts

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