37 lines
653 B
Go
37 lines
653 B
Go
package raindrop
|
|
|
|
import "fmt"
|
|
|
|
type ClientConfig struct {
|
|
ClientId string
|
|
ClientSecret string
|
|
RedirectURI string
|
|
}
|
|
|
|
type ApiToken struct {
|
|
Type string
|
|
Value string
|
|
}
|
|
|
|
type Client struct {
|
|
config ClientConfig
|
|
token *ApiToken
|
|
}
|
|
|
|
func NewClient(config ClientConfig) (*Client, error) {
|
|
if config.ClientId == "" || config.ClientSecret == "" || config.RedirectURI == "" {
|
|
return nil, fmt.Errorf("some environment variables missing")
|
|
}
|
|
return &Client{
|
|
config: config,
|
|
}, nil
|
|
}
|
|
|
|
func (c *Client) baseURL() string {
|
|
return "https://api.raindrop.io/rest/v1"
|
|
}
|
|
|
|
func (c *Client) getApiURL(path string) string {
|
|
return c.baseURL() + path
|
|
}
|