Documentation ¶
Index ¶
- Constants
- type AccessToken
- type AppToken
- type Client
- func (c *Client) DoRequestContent(urlStr string, form url.Values) (*http.Response, error)
- func (c *Client) DoRequestDecoding(method string, urlStr string, form url.Values, v interface{}) (*http.Response, error)
- func (c *Client) DoRequestMultipart(filePath, uploadPath, filename, method string) (*http.Response, error)
- type Count
- type Creator
- type Email
- type FileService
- func (fs *FileService) CreateDirectory(path string, overwrite bool) error
- func (fs *FileService) DeleteFile(path string) error
- func (fs *FileService) GetFile(path string) (io.ReadCloser, error)
- func (fs *FileService) GetMeta(path string) (*Meta, error)
- func (fs *FileService) GetRevisionMeta(path string, time int) (*Meta, error)
- func (fs *FileService) GetThumbnail(path string, size int) (io.ReadCloser, error)
- func (fs *FileService) GetTopLevelMeta() (*Meta, error)
- func (fs *FileService) ListRevisionsMeta(path string) ([]Revision, error)
- func (fs *FileService) MoveFile(path string, newPath string, overwrite bool) error
- func (fs *FileService) RenameFile(path string, newName string, overwrite bool) error
- func (fs *FileService) UpdateFile(filePath, uploadPath string) error
- func (fs *FileService) UploadFile(filePath, uploadPath string, overwrite bool) error
- type Link
- type LinkService
- func (ls *LinkService) AddPaths(token string, paths []string) error
- 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 Recipient
- type Revision
- type Session
- func (s *Session) Delete(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)
- func (s *Session) Do(request *http.Request, httpClient *http.Client) (*http.Response, error)
- func (s *Session) Get(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)
- func (s *Session) Post(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)
- func (s *Session) Put(urlStr string, form url.Values, httpClient *http.Client) (*http.Response, error)
- type Storage
- type ThumbOriginalDimensions
- type User
- type UserService
Constants ¶
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 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 ¶
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)
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 ¶
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) AddRecipients ¶
func (ls *LinkService) AddRecipients(token string, recipients []Recipient) error
func (*LinkService) CreateLink ¶
func (ls *LinkService) CreateLink(name string, paths []string, public bool) error
func (*LinkService) DeleteLink ¶
func (ls *LinkService) DeleteLink(token string) error
func (*LinkService) GetFilesMetaFromLink ¶
func (ls *LinkService) GetFilesMetaFromLink(token string) (*Meta, error)
func (*LinkService) GetLinks ¶
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"` 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
type ThumbOriginalDimensions ¶
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