copy

package
v0.0.0-...-11ca894 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceURL = "https://api.copy.com/rest/"
	AuthURL     = "https://www.copy.com/applications/authorize"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	Token string
	Key   string
}

type AppToken

type AppToken struct {
	Token string
	Key   string
}

type Client

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

Client has the session (Session) for calling the REST API with Oauth the Http client and the URL to call

func NewClient

func NewClient(httpClient *http.Client, resourcesUrl string,
	appToken string, appSecret string,
	accessToken string, accessSecret string) (*Client, error)

Creates a new client. If no http client and URL the client will use the default ones

func NewDefaultClient

func NewDefaultClient(appToken string, appSecret string,
	accessToken string, accessSecret string) (*Client, error)

Returns a default client, normally we will use this

func (*Client) DoRequestContent

func (c *Client) DoRequestContent(urlStr string, form url.Values) (*http.Response, error)

Makes the client request based on the url.

This will be binary data body so we don't process the request

func (*Client) DoRequestDecoding

func (c *Client) DoRequestDecoding(method string, urlStr string, form url.Values, v interface{}) (*http.Response, error)

Makes the client request based on the url, method, values and returns the response is the response of the call the value is inside the v param (you should pass a pointer because will mutate inside the method)

func (*Client) DoRequestMultipart

func (c *Client) DoRequestMultipart(filePath, uploadPath, filename, method string) (*http.Response, error)

Makes the client request for uploading multipart request

type Count

type Count struct {
	New    int `json:"new,omitempty"`
	Viewed int `json:"viewed,omitempty"`
	Hidden int `json:"hidden,omitempty"`
}

type Creator

type Creator struct {
	UserId      string `json:"user_id,omitempty"`
	CreatedTime int    `json:"created_time,omitempty"`
	Email       string `json:"email,omitempty"`
	FirstName   string `json:"first_name,omitempty"`
	LastName    string `json:"last_name,omitempty"`
	Confirmed   bool   `json:"confirmed,omitempty"`
}

type Email

type Email struct {
	Primary   bool   `json:"primary,omitempty"`
	Confirmed bool   `json:"confirmed,omitempty"`
	Email     string `json:"Email,omitempty"`
	Gravatar  string `json:"gravatar,omitempty"`
}

type FileService

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

func NewFileService

func NewFileService(client *Client) *FileService

func (*FileService) CreateDirectory

func (fs *FileService) CreateDirectory(path string, overwrite bool) error

Creates a directory

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) DeleteFile

func (fs *FileService) DeleteFile(path string) error

Deletes the file content

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) GetFile

func (fs *FileService) GetFile(path string) (io.ReadCloser, error)

Returns the file content. the user NEEDS TO CLOSE the buffer after using it

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) GetMeta

func (fs *FileService) GetMeta(path string) (*Meta, error)

Returns the metadata of a file

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) GetRevisionMeta

func (fs *FileService) GetRevisionMeta(path string, time int) (*Meta, error)

Returns the metadata in an specified revision

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) GetThumbnail

func (fs *FileService) GetThumbnail(path string, size int) (io.ReadCloser, error)

Gets the thumbnail asociated to the file. Size can be: 32, 64, 128, 256, 512, 1024 User must close the returned readcloser

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) GetTopLevelMeta

func (fs *FileService) GetTopLevelMeta() (*Meta, error)

Returns the top level metadata (this is root folder, cannot change, see docs)

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) ListRevisionsMeta

func (fs *FileService) ListRevisionsMeta(path string) ([]Revision, error)

Returns all the metadata revisions of a file

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) MoveFile

func (fs *FileService) MoveFile(path string, newPath string, overwrite bool) error

Moves the file

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) RenameFile

func (fs *FileService) RenameFile(path string, newName string, overwrite bool) error

Renames the file

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) UpdateFile

func (fs *FileService) UpdateFile(filePath, uploadPath string) error

Uploads the file (updating it). Loads the file from the file path and uploads to the uploadPath. For example:

filePath: /home/slok/myFile.txt
UploadPath: test/uploads/something.txt

https://www.copy.com/developer/documentation#api-calls/filesystem

func (*FileService) UploadFile

func (fs *FileService) UploadFile(filePath, uploadPath string, overwrite bool) error

Uploads the file. Loads the file from the file path and uploads to the uploadPath. For example:

filePath: /home/slok/myFile.txt
UploadPath: test/uploads/something.txt

https://www.copy.com/developer/documentation#api-calls/filesystem

type Link struct {
	Id                   string      `json:"id,omitempty"`
	Public               bool        `json:"public,omitempty"`
	Expires              bool        `json:"expires,omitempty"`
	Expired              bool        `json:"expired,omitempty"`
	Url                  string      `json:"url,omitempty"`
	UrlShort             string      `json:"url_short,omitempty"`
	Recipients           []Recipient `json:"recipients,omitempty"`
	CreatorId            string      `json:"creator_id,omitempty"`
	ConfirmationRequired bool        `json:"confirmation_required,omitempty"`
}

type LinkService

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

func NewLinkService

func NewLinkService(client *Client) *LinkService

func (*LinkService) AddPaths

func (ls *LinkService) AddPaths(token string, paths []string) error

func (*LinkService) AddRecipients

func (ls *LinkService) AddRecipients(token string, recipients []Recipient) error
func (ls *LinkService) CreateLink(name string, paths []string, public bool) error
func (ls *LinkService) DeleteLink(token string) error
func (ls *LinkService) GetFilesMetaFromLink(token string) (*Meta, error)
func (ls *LinkService) GetLink(token string) (*Meta, error)
func (ls *LinkService) GetLinks() ([]Meta, error)

type Meta

type Meta struct {
	Id                      string                  `json:"id,omitempty"`
	Path                    string                  `json:"path,omitempty"`
	Name                    string                  `json:"name,omitempty"`
	LinkName                string                  `json:"link_name,omitempty"`
	Token                   string                  `json:"token,omitempty"`
	Permissions             string                  `json:"permissions,omitempty"`
	Public                  bool                    `json:"public,omitempty"`
	Type                    string                  `json:"type,omitempty"`
	Size                    int                     `json:"size,omitempty"`
	DateLastSynced          int                     `json:"date_last_synced,omitempty"`
	ModifiedTime            int                     `json:"modified_time,omitempty"`
	Stub                    bool                    `json:"stub,omitempty"`
	Share                   bool                    `json:"share,omitempty"`
	Children                []Meta                  `json:"children,omitempty"` // Inception :D
	Counts                  Count                   `json:"counts,omitempty"`   // Array? (sometimes? ask copy.com)
	RecipientConfirmed      bool                    `json:"recipient_confirmed",omitempty"`
	MimeType                string                  `json:"mime_type",omitempty"`
	Syncing                 bool                    `json:"syncing",omitempty"`
	ObjectAvailable         bool                    `json:"object_available,omitempty"`
	Links                   []Link                  `json:"links,omitempty"`
	Revisions               []Revision              `json:"revisions,omitempty"`
	Url                     string                  `json:"url,omitempty"`
	RevisionId              int                     `json:"revision_id,omitempty"`
	Thumb                   string                  `json:"thumb,omitempty"`
	ThumbOriginalDimensions ThumbOriginalDimensions `json:"thumb_original_dimensions,omitempty"`
	ChildrenCount           int                     `json:"children_count",omitempty"`
	Revision                int                     `json:"revision",omitempty"`
	ListIndex               int                     `json:"list_index",omitempty"`
}

File Meta data representation

type Recipient

type Recipient struct {
	ContactType   string  `json:"contact_type,omitempty"`
	ContactId     string  `json:"contact_id,omitempty"`
	ContactSource string  `json:"contact_source,omitempty"`
	UserId        string  `json:"user_id,omitempty"`
	FirstName     string  `json:"first_name,omitempty"`
	LastName      string  `json:"last_name,omitempty"`
	Email         string  `json:"email,omitempty"`
	Permissions   string  `json:"permissions,omitempty"`
	Emails        []Email `json:"emails,omitempty"` // In users.go
}

type Revision

type Revision struct {
	RevisionId   string  `json:"revision_id,omitempty"`
	ModifiedTime string  `json:"modified_time,omitempty"`
	Size         int     `json:"size,omitempty"`
	Latest       bool    `json:"latest,omitempty"`
	Conflict     int     `json:"conflict,omitempty"`
	Id           string  `json:"id,omitempty"`
	Type         string  `json:"type,omitempty"`
	Creator      Creator `json:"creator,omitempty"`
}

type Session

type Session struct {
	OauthClient oauth.Client
	TokenCreds  oauth.Credentials
}

func NewSession

func NewSession(appToken AppToken, accessToken AccessToken) (*Session, error)

Creates a new Ouath session for making requests

func (*Session) Delete

func (s *Session) Delete(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)

func (*Session) Do

func (s *Session) Do(request *http.Request, httpClient *http.Client) (*http.Response, error)

func (*Session) Get

func (s *Session) Get(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)

func (*Session) Post

func (s *Session) Post(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)

func (*Session) Put

func (s *Session) Put(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)

type Storage

type Storage struct {
	Used  int `json:"used,omitempty"`
	Quota int `json:"quota,omitempty"`
	Saved int `json:"saved,omitempty"`
}

type ThumbOriginalDimensions

type ThumbOriginalDimensions struct {
	Width  int `json:"width,omitempty"`
	Height int `json:"Height,omitempty"`
}

type User

type User struct {
	Id          string  `json:"id,omitempty"`
	FirstName   string  `json:"first_name,omitempty"`
	LastName    string  `json:"last_name,omitempty"`
	Developer   bool    `json:"developer,omitempty"`
	CreatedTime int     `json:"created_time,omitempty"`
	Email       string  `json:"email,omitempty"`
	Emails      []Email `json:"emails,omitempty"`
	Storage     Storage `json:"storage,omitempty"`
}

User represents the current user at Copy

type UserService

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

func NewUserService

func NewUserService(client *Client) *UserService

func (*UserService) Get

func (us *UserService) Get() (*User, error)

Get fetches the authenticated user

https://www.copy.com/developer/documentation#api-calls/profile

func (*UserService) Update

func (us *UserService) Update(user *User) error

Updates the authenticated user

https://www.copy.com/developer/documentation#api-calls/profile

Jump to

Keyboard shortcuts

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