Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountInfo ¶
type AccountInfo struct { // The user's unique Dropbox ID. ID string `json:"account_id"` // The user's name Name Username `json:"name"` // The user's e-mail. Email string `json:"email"` // The user's two-letter country code, if available. Country string `json:"country"` // Locale preference set by the user (e.g. en-us). Locale string `json:"locale"` // The user's referral link. ReferralLink string `json:"referral_link"` // If true, there is a paired account associated with this user. IsPaired bool `json:"is_paired"` }
AccountInfo contains a Dropbox user account information.
type Client ¶
type Client struct { // Base URL for API requests. Defaults to the public Dropbox API. BaseURL *url.URL // Base URL for content API request. Defaults to the public Dropbox content // API. ContentURL *url.URL // User agent used when communicating with the Dropbox API. UserAgent string // Used to specify language settings for user error messages and other // language specific text. If your app supports any language other than // English, insert the appropriate IETF language tag. // // More info at https://www.dropbox.com/developers/core/docs#param.locale Locale string // Services used for talking to different parts of the Dropbox API. Users *UsersService Files *FilesService // contains filtered or unexported fields }
A Client manages communication with the Dropbox API.
func NewClient ¶
NewClient returns a new Dropbox API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
func (*Client) DoRPC ¶
func (c *Client) DoRPC(req *RPCRequest, v interface{}) (*http.Response, error)
DoRPC sends a RPC style request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (*Client) NewRPCRequest ¶
func (c *Client) NewRPCRequest(method, urlStr string, body interface{}) (*RPCRequest, error)
NewRPCRequest returns a new RPC style request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. Body, if specified, must be a valid JSON marshable value.
type FilesService ¶
type FilesService struct {
// contains filtered or unexported fields
}
FilesService handles communication with the files and metadata related methods of the Dropbox API.
func (*FilesService) ListFolder ¶
Example ¶
// Use golang.org/x/oauth2 for authentication: // ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: ACCESS_TOKEN}) // tc := oauth2.NewClient(oauth2.NoContext, ts) // c := dropbox.NewClient(tc) c := dropbox.NewClient(nil) entries, _, err := c.Files.ListFolder("/photos") if err != nil { fmt.Printf("Error: %s\n", err.Error()) return } for _, entry := range entries { fmt.Println(entry.Name) }
Output: James.jpg Mary.jpg Richard.jpg Susan.jpg
type RPCRequest ¶
RPCRequest is a RPC Style Request. The request and response bodies are both JSON.
type UnexpectedError ¶
type UnexpectedError struct{}
UnexpectedError is an error returned by go-dropbox when no more information is provided.
func (*UnexpectedError) Error ¶
func (e *UnexpectedError) Error() string
type Username ¶
type Username struct { // The user's given name. GivenName string `json:"given_name"` // The user's surname. Surname string `json:"surname"` // The locale-dependent familiar name for the user. FamiliarName string `json:"familiar_name"` // The user's display name. DisplayName string `json:"display_name"` }
Username contains information about an user name.
type UsersService ¶
type UsersService struct {
// contains filtered or unexported fields
}
UsersService handles communication with the users related methods of the Dropbox API.
func (*UsersService) GetAccount ¶
func (s *UsersService) GetAccount() (*AccountInfo, *http.Response, error)
GetAccount retrieves information about the current user account.
Example ¶
// Use golang.org/x/oauth2 for authentication: // ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: ACCESS_TOKEN}) // tc := oauth2.NewClient(oauth2.NoContext, ts) // c := dropbox.NewClient(tc) c := dropbox.NewClient(nil) account, _, err := c.Users.GetAccount() if err != nil { fmt.Printf("Error: %s\n", err.Error()) return } fmt.Printf("Hello %s!\n", account.Name.DisplayName)
Output: Hello Drew!