unsplash

package
Version: v0.0.0-...-473bd5b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionsService

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

CollectionsService contains an underlying Unsplash client to be used for http methods

func (*CollectionsService) AddPhoto

func (cs *CollectionsService) AddPhoto(collectionID string, data map[string]string) (*client.CollectionActionResponse, error)

AddPhoto takes in a `photo_id` in the data map, to add the Photo to the given collection

func (*CollectionsService) All

func (cs *CollectionsService) All(queryParams client.QueryParams) ([]client.Collection, error)

All returns a paginated list of all Collections on Unsplash

func (*CollectionsService) Create

func (cs *CollectionsService) Create(data map[string]string) (*client.Collection, error)

Create creates a new collection using the data provided in the map, returning it if the creation process is successful

func (*CollectionsService) Delete

func (cs *CollectionsService) Delete(collectionID string) error

Delete removes the given collection

func (*CollectionsService) Get

func (cs *CollectionsService) Get(collectionID string) (*client.Collection, error)

Get returns a specific Collection, given its id

func (*CollectionsService) Photos

func (cs *CollectionsService) Photos(collectionID string, queryParams client.QueryParams) ([]client.Photo, error)

Photos returns a paginated list of Photos under the given collection

func (*CollectionsService) Related

func (cs *CollectionsService) Related(collectionID string) ([]client.Collection, error)

Related returns a paginated list of collections related to the given collection

func (*CollectionsService) RemovePhoto

func (cs *CollectionsService) RemovePhoto(collectionID string, data map[string]string) (*client.CollectionActionResponse, error)

RemovePhoto takes in a `photo_id` in the data map, to remove the Photo from the given collection

func (*CollectionsService) Search

func (cs *CollectionsService) Search(searchQuery string, queryParams client.QueryParams) (*client.CollectionSearchResult, error)

Search takes in a search query under the given query parameters to return a list of Collection search results

func (*CollectionsService) Update

func (cs *CollectionsService) Update(collectionID string, data map[string]string) (*client.Collection, error)

Update uses the data provided in the map to update the given collection returning the updated collection

type CollectionsServiceClient

type CollectionsServiceClient interface {
	GetCollectionsList(context.Context, client.QueryParams) ([]client.Collection, error)
	GetCollection(context.Context, string) (*client.Collection, error)
	GetCollectionPhotos(context.Context, string, client.QueryParams) ([]client.Photo, error)
	GetRelatedCollections(context.Context, string) ([]client.Collection, error)
	SearchCollections(context.Context, client.QueryParams) (*client.CollectionSearchResult, error)
	CreateCollection(context.Context, map[string]string) (*client.Collection, error)
	UpdateCollection(context.Context, string, map[string]string) (*client.Collection, error)
	DeleteCollection(context.Context, string) error
	AddPhotoToCollection(context.Context, string, map[string]string) (*client.CollectionActionResponse, error)
	RemovePhotoFromCollection(context.Context, string, map[string]string) (*client.CollectionActionResponse, error)
}

CollectionsServiceClient defines client methods used to get collection resources

type PhotosService

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

PhotosService contains an underlying Unsplash client to be used for http methods

func (*PhotosService) All

func (ps *PhotosService) All(queryParams client.QueryParams) ([]client.Photo, error)

All returns a paginated list of all the Photos on Unsplash

func (*PhotosService) Get

func (ps *PhotosService) Get(photoID string) (*client.Photo, error)

Get returns a single Photo, requested using the photo's ID

func (*PhotosService) Like

func (ps *PhotosService) Like(photoID string) (*client.LikeResponse, error)

Like adds a like on the photo whose photo ID is provided on behalf of the authenticated user

func (*PhotosService) Random

func (ps *PhotosService) Random(queryParams client.QueryParams) (interface{}, error)

Random returns a random Photo. Returns a paginated list of Photos if `count` query parameter is provided in the query parameters.

Example
cl := client.New(os.Getenv("CLIENT_ID"), nil, client.NewConfig())
unsplash := New(cl)
res, err := unsplash.Photos.Random(nil)
if err != nil {
	fmt.Println(err)
}

randomPhoto := res.(*client.Photo)
randomPhoto.ID = "losemycool"
fmt.Println(randomPhoto.URLs)
// losemycool
Output:

func (*PhotosService) Search

func (ps *PhotosService) Search(searchQuery string, queryParams client.QueryParams) (*client.PhotoSearchResult, error)

Search takes in a search query in the query parameters and returns a list of Photo search results

func (*PhotosService) Stats

func (ps *PhotosService) Stats(photoID string, queryParams client.QueryParams) (*client.PhotoStats, error)

Stats returns the requested Photo's Stats

func (*PhotosService) Unlike

func (ps *PhotosService) Unlike(photoID string) error

Unlike removes a like on the photo whose photo ID is provided on behalf of the authenticated user

func (*PhotosService) Update

func (ps *PhotosService) Update(photoID string, updatedData map[string]string) (*client.Photo, error)

Update uses the data provided to update info on the requested Photo

type PhotosServiceClient

type PhotosServiceClient interface {
	GetPhotoList(context.Context, client.QueryParams) ([]client.Photo, error)
	GetPhoto(context.Context, string) (*client.Photo, error)
	GetRandomPhoto(context.Context, client.QueryParams) (interface{}, error)
	GetPhotoStats(context.Context, string, client.QueryParams) (*client.PhotoStats, error)
	SearchPhotos(context.Context, client.QueryParams) (*client.PhotoSearchResult, error)
	UpdatePhoto(context.Context, string, map[string]string) (*client.Photo, error)
	LikePhoto(context.Context, string) (*client.LikeResponse, error)
	UnlikePhoto(context.Context, string) error
}

PhotosServiceClient defines client methods used to get or work with photo resources

type TopicsService

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

TopicsService contains an underlying Unsplash client to be used for http methods

func (*TopicsService) All

func (ts *TopicsService) All(queryParams client.QueryParams) ([]client.Topic, error)

All returns a paginated list of all Topics on unsplash

func (*TopicsService) Get

func (ts *TopicsService) Get(topicIDOrSlug string) (*client.Topic, error)

Get returns a specific Topic, using the topic's ID or slug

func (*TopicsService) Photos

func (ts *TopicsService) Photos(topicIDOrSlug string, queryParams client.QueryParams) ([]client.Photo, error)

Photos returns a paginated list of Photos under the Topic requested using the topic's ID or slug

type TopicsServiceClient

type TopicsServiceClient interface {
	GetTopicsList(context.Context, client.QueryParams) ([]client.Topic, error)
	GetTopic(context.Context, string) (*client.Topic, error)
	GetTopicPhotos(context.Context, string, client.QueryParams) ([]client.Photo, error)
}

TopicsServiceClient defines client methods used to get topic resources

type Unsplash

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

Unsplash wraps the whole API

func New

func New(c *client.Client) *Unsplash

New constructs a new Unsplash object

type UsersService

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

UsersService contains an underlying Unsplash client to be used for http methods

func (*UsersService) Collections

func (us *UsersService) Collections(username string, queryParams client.QueryParams) ([]client.Collection, error)

Collections returns a paginated list of collections created by the user

func (*UsersService) LikedPhotos

func (us *UsersService) LikedPhotos(username string, queryParams client.QueryParams) ([]client.Photo, error)

LikedPhotos returns a paginated list of photos liked by the user

func (*UsersService) Photos

func (us *UsersService) Photos(username string, queryParams client.QueryParams) ([]client.Photo, error)

Photos returns a paginated list of Photos uploaded by the user

func (*UsersService) PortfolioURL

func (us *UsersService) PortfolioURL(username string) (*url.URL, error)

PortfolioURL returns a parsed URL of the user

func (*UsersService) PrivateProfile

func (us *UsersService) PrivateProfile() (*client.User, error)

PrivateProfile returns the authenticated user's private profile

func (*UsersService) PublicProfile

func (us *UsersService) PublicProfile(username string) (*client.User, error)

PublicProfile returns the public profile of the user

func (*UsersService) Search

func (us *UsersService) Search(searchQuery string, queryParams client.QueryParams) (*client.UserSearchResult, error)

Search takes in a search query under the given query parameters to return a list of User search results

func (*UsersService) Stats

func (us *UsersService) Stats(username string, queryParams client.QueryParams) (*client.UserStats, error)

Stats returns the user's stats

func (*UsersService) UpdateProfile

func (us *UsersService) UpdateProfile(updatedData map[string]string) (*client.User, error)

UpdateProfile updates the authenticated user's profile using the data map provided

type UsersServiceClient

type UsersServiceClient interface {
	GetUserPublicProfile(context.Context, string) (*client.User, error)
	GetUserPortfolioLink(context.Context, string) (*url.URL, error)
	GetUserPhotos(context.Context, string, client.QueryParams) ([]client.Photo, error)
	GetUserLikedPhotos(context.Context, string, client.QueryParams) ([]client.Photo, error)
	GetUserCollections(context.Context, string, client.QueryParams) ([]client.Collection, error)
	GetUserStats(context.Context, string, client.QueryParams) (*client.UserStats, error)
	SearchUsers(context.Context, client.QueryParams) (*client.UserSearchResult, error)
	GetUserPrivateProfile(context.Context) (*client.User, error)
	UpdateUserProfile(context.Context, map[string]string) (*client.User, error)
}

UsersServiceClient defines client methods used to get user resources

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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