google

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

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

Go to latest
Published: Oct 17, 2017 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGoogleHTTPRoutes

func RegisterGoogleHTTPRoutes(srv Server, service *Service, jwtKey []byte, authClient *auth.Client)

func TestRepository

func TestRepository(t *testing.T, repo UserRepository)

Types

type AuthUser

type AuthUser struct {
	User

	Name  string `json:"-"`
	Email string `json:"-"`
}

type DriveFile

type DriveFile struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	URL      string `json:"url"`
	MimeType string `json:"mimeType"`
}

type DriveService

type DriveService interface {
	UserHasAllowedDrive() (bool, error)
	GetFolderID(name string) (string, error)

	ListFiles(folderID string, pageToken string) ([]DriveFile, string, error)
	CreateFile(name, typ, folderID string, data []byte) (DriveFile, error)
	CreateFolder(name string) (string, error)
}

func NewGDriveService

func NewGDriveService(client *http.Client) (DriveService, error)

type DriveServiceFactory

type DriveServiceFactory func(*http.Client) (DriveService, error)

type GDriveService

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

func (*GDriveService) CreateFile

func (ds *GDriveService) CreateFile(name, typ, folderID string, data []byte) (DriveFile, error)

func (*GDriveService) CreateFolder

func (ds *GDriveService) CreateFolder(name string) (string, error)

func (*GDriveService) GetFolderID

func (ds *GDriveService) GetFolderID(name string) (string, error)

func (*GDriveService) ListFiles

func (ds *GDriveService) ListFiles(folderID, name string) ([]DriveFile, string, error)

func (*GDriveService) UserHasAllowedDrive

func (ds *GDriveService) UserHasAllowedDrive() (bool, error)

type GoogleLoginRequest

type GoogleLoginRequest struct {
	State string `json:"state"`
	Code  string `json:"code"`
}

type InmemRepository

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

func NewInmemRepository

func NewInmemRepository() *InmemRepository

func (InmemRepository) GetByGoogleID

func (r InmemRepository) GetByGoogleID(googleID string) (User, error)

func (InmemRepository) GetByID

func (r InmemRepository) GetByID(id int) (User, error)

func (*InmemRepository) Upsert

func (r *InmemRepository) Upsert(user User) error

type Server

type Server interface {
	RegisterHandler(path, method string, f http.Handler)
}

Server defines the interface to register the http handlers.

type Service

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

func NewService

func NewService(repo UserRepository, configPath string, dsf DriveServiceFactory, userClient *UserClient) (*Service, error)

func (*Service) Login

func (s *Service) Login(state, code string) (string, string, error)

func (*Service) LoginURL

func (s *Service) LoginURL() string

type User

type User struct {
	ID       int    `json:"id"`
	GoogleID string `json:"googleId"`

	Tokens map[string]*oauth2.Token `json:"tokens"`
}

type UserClient

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

func NewUserClient

func NewUserClient(client *auth.Client) *UserClient

func (*UserClient) Token

func (c *UserClient) Token(user AuthUser) (string, error)

func (*UserClient) Upsert

func (c *UserClient) Upsert(user AuthUser) (AuthUser, error)

type UserRepository

type UserRepository interface {
	GetByID(id int) (User, error)
	GetByGoogleID(googleID string) (User, error)

	Upsert(User) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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