albums

package
v3.0.0-...-7efd0d3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlbumNotFound is the error returned when an album is not found.
	ErrAlbumNotFound = errors.New("album not found")
)

Functions

This section is empty.

Types

type Album

type Album struct {
	// CoverPhotoBaseURL: [Output only] A BaseURL to the cover photo's bytes.
	// This should not be used as is.
	// Parameters should be appended to this BaseURL before use. For example,
	// '=w2048-h1024' will set the dimensions of the cover photo to have a
	// width of 2048 px and height of 1024 px.
	CoverPhotoBaseURL string

	// Id: [Output only] Identifier for the album. This is a persistent
	// identifier that can be used to identify this album.
	ID string

	// IsWriteable: [Output only] True if media items can be created in the
	// album.
	// This field is based on the scopes granted and permissions of the
	// album. If the scopes are changed or permissions of the album are changed, this
	// field will be updated.
	IsWriteable bool

	// ProductURL: [Output only] Google Photos BaseURL for the album. The user
	// needs to be signed in to their Google Photos account to access this link.
	ProductURL string

	// Title: Name of the album displayed to the user in their Google Photos
	// account.
	// This string should not be more than 500 characters.
	Title string

	// TotalMediaItems: [Output only] The number of media items in the album.
	TotalMediaItems int64
}

An Album represents a Google Photos album. Albums are a container for media items.

See: https://developers.google.com/photos/library/reference/rest/v1/albums.

type Config

type Config struct {
	// HTTP client used to communicate with the API.
	Client *http.Client

	// [Optional] Base URL for API requests.
	// BaseURL should always be specified with a trailing slash.
	BaseURL string

	// [Optional] User agent used when communicating with the Google Photos API.
	UserAgent string
}

Config holds the configuration parameters for the service.

type PaginatedListOptions

type PaginatedListOptions struct {
	Limit     int64
	PageToken string
}

PaginatedListOptions set the options for the PaginatedList call.

type PhotosLibraryClient

type PhotosLibraryClient interface {
	BatchAddMediaItems(albumId string, albumBatchAddMediaItemsRequest *photoslibrary.AlbumBatchAddMediaItemsRequest) *photoslibrary.AlbumBatchAddMediaItemsCall
	Create(createAlbumRequest *photoslibrary.CreateAlbumRequest) *photoslibrary.AlbumsCreateCall
	Get(albumId string) *photoslibrary.AlbumsGetCall
	List() *photoslibrary.AlbumsListCall
}

PhotosLibraryClient represents a Google Photos client using `gphotosuploader/googlemirror/api/photoslibrary`.

type Service

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

Service implements an albums Google Photos client.

func New

func New(config Config) (*Service, error)

New returns an albums Google Photos service.

func (*Service) AddMediaItems

func (s *Service) AddMediaItems(ctx context.Context, albumID string, mediaItemIDs []string) error

AddMediaItems add one or more existing media items to an existing Album.

func (*Service) Create

func (s *Service) Create(ctx context.Context, title string) (*Album, error)

Create creates an album in Google Photos.

func (*Service) GetById

func (s *Service) GetById(ctx context.Context, albumID string) (*Album, error)

GetById returns the album specified by the given album id.

func (*Service) GetByTitle

func (s *Service) GetByTitle(ctx context.Context, title string) (*Album, error)

GetByTitle searches for an album with the specified title in the list of all albums. It paginates through all albums until finding one with the matching title.

Returns ErrAlbumNotFound if the album does not exist.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Album, error)

List lists all albums in created by this app.

func (*Service) PaginatedList

func (s *Service) PaginatedList(ctx context.Context, options *PaginatedListOptions) (albums []Album, nextPageToken string, err error)

PaginatedList retrieves a specific page of albums, allowing for efficient retrieval of albums in pages. Each page contains the predetermined number of albums.

Jump to

Keyboard shortcuts

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