Documentation
¶
Index ¶
- Constants
- func CheckResponse(r *http.Response) error
- type Authentication
- type AuthenticationService
- func (s *AuthenticationService) GetAuthenticationURL(permission string) (string, error)
- func (s *AuthenticationService) GetAuthenticationURLWithFrob(permission, frob string) (string, error)
- func (s *AuthenticationService) GetFrob(ctx context.Context) (string, *Response, error)
- func (s *AuthenticationService) GetToken(ctx context.Context, frob string) (*Authentication, *Response, error)
- type AuthenticationURLOptions
- type BaseAPIURLOptions
- type BaseResponse
- type Client
- func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, error)
- func (c *Client) Do(ctx context.Context, req *http.Request, v any) (*Response, error)
- func (c *Client) NewRequest(method, urlStr string, body any, opts ...RequestOption) (*http.Request, error)
- func (c *Client) SetAuthenticationToken(token string)
- func (c *Client) SignRequest(params url.Values) string
- type Contact
- type ContactList
- type ContactsGetListResponse
- type ContactsService
- type ErrorResponse
- type FailureResponse
- type GetFrobResponse
- type GetTokenOptions
- type GetTokenResponse
- type List
- type ListList
- type ListService
- type ListsGetListResponse
- type RequestOption
- type Response
- type Tag
- type TagList
- type TagService
- type TagsGetListResponse
- type Task
- type TaskAddResponse
- type TaskInput
- type TaskList
- type TaskService
- type Taskseries
- type TestLoginResponse
- type TestService
- type TimelineService
- type TimelinesCreateResponse
- type Transaction
- type User
Constants ¶
const ( // PermissionRead represents the read permission – gives the ability to read task, contact, group and list details and contents. PermissionRead = "read" // PermissionWrite represents the write permission – gives the ability to add and modify task, contact, group and list details and contents (also allows you to read). PermissionWrite = "write" // PermissionDelete represents the delete permission – gives the ability to delete tasks, contacts, groups and lists (also allows you to read and write). PermissionDelete = "delete" )
const ( StatOK = "ok" StatFail = "fail" ResponseFormatJSON = "json" )
const ( ParseWithoutSmartAdd = 0 ParseWithSmartAdd = 1 )
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error the response contains `stat`="fail".
Types ¶
type Authentication ¶
type AuthenticationService ¶
type AuthenticationService service
AuthorizationsService handles communication with the authorization related methods of the Remember The Milk API.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/authentication.rtm
func (*AuthenticationService) GetAuthenticationURL ¶
func (s *AuthenticationService) GetAuthenticationURL(permission string) (string, error)
GetAuthenticationURL returns the URL to redirect the user to for authentication with the given permission level. This is typically the first step in the authentication process for web-based applications.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/authentication.rtm
func (*AuthenticationService) GetAuthenticationURLWithFrob ¶
func (s *AuthenticationService) GetAuthenticationURLWithFrob(permission, frob string) (string, error)
GetAuthenticationURL returns the URL to redirect the user to for authentication with the given permission level. This is typically the first step in the authentication process for desktop applications. The frob is obtained by calling the GetFrob method first.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/authentication.rtm
func (*AuthenticationService) GetFrob ¶
GetFrob returns a frob to be used during authentication.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.auth.getFrob.rtm
func (*AuthenticationService) GetToken ¶
func (s *AuthenticationService) GetToken(ctx context.Context, frob string) (*Authentication, *Response, error)
GetToken returns the auth token for the given frob, if one has been attached.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.auth.getToken.rtm
type AuthenticationURLOptions ¶
type AuthenticationURLOptions struct { // APIKey represents the API key for the request. APIKey string `url:"api_key,omitempty"` // Permissions represents the level of access being requested. See constants Permission*. Permissions string `url:"perms,omitempty"` // Frob represents a frob to be associated with the authentication request. Frob string `url:"frob,omitempty"` // APISignature represents the API signature for the request. // See "Signing Requests" in https://www.rememberthemilk.com/services/api/authentication.rtm for more information. APISignature string `url:"api_sig,omitempty"` }
AuthenticationURLOptions specifies the parameters to the URL to start the authentication process (for web-based applications or desktop applications)
type BaseAPIURLOptions ¶
type BaseAPIURLOptions struct { Method string `url:"method,omitempty"` APIKey string `url:"api_key,omitempty"` AuthenticationToken string `url:"auth_token,omitempty"` Format string `url:"format,omitempty"` Version string `url:"v,omitempty"` }
BaseAPIURLOptions specifies the base options that are included in every API request.
type BaseResponse ¶
type BaseResponse struct { Stat string `json:"stat"` Error FailureResponse `json:"err,omitempty"` }
BaseResponse represents the common fields returned in every API response. Every specific response embeds this struct.
type Client ¶
type Client struct { // Web Base URL for authentication requests. Defaults to the public Remember The Milk API // WebBaseURL should always be specified with a trailing slash. WebBaseURL *url.URL // Base URL for API requests. Defaults to the public Remember The Milk API. // WebBaseURL should always be specified with a trailing slash. BaseURL *url.URL // User agent used when communicating with the Remember The Milk API. UserAgent string // Services used for talking to different parts of the Remember The Milk API. Authentication *AuthenticationService Tags *TagService Lists *ListService Contacts *ContactsService Timelines *TimelineService Tasks *TaskService Test *TestService // contains filtered or unexported fields }
A Client manages communication with the Remember The Milk API.
func NewClient ¶
NewClient returns a new Remember the Milk API client. If a nil httpClient is provided, a new http.Client will be used.
func (*Client) BareDo ¶
BareDo sends an API request and lets you handle the api response. If an error or API Error occurs, the error will contain more information. Otherwise you are supposed to read and close the response's Body.
The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) Do ¶
Do sends an API 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. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If v is nil, and no error happens, the response is returned as is.
The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(method, urlStr string, body any, opts ...RequestOption) (*http.Request, error)
NewRequest creates an API 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. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) SetAuthenticationToken ¶
SetAuthenticationToken sets the authentication token to be used in API requests.
This token is required for making authenticated requests to the Remember The Milk API.
func (*Client) SignRequest ¶
SignRequest signs a request according to the Remember The Milk API specification. It takes a map of parameters, sorts them by key, concatenates them with the shared secret, and returns the MD5 hash that should be used as the api_sig parameter.
Remember the Milk API docs: https://www.rememberthemilk.com/services/api/authentication.rtm
type ContactList ¶
type ContactList struct {
Contact []Contact `json:"contact"`
}
type ContactsGetListResponse ¶
type ContactsGetListResponse struct { Contacts ContactList `json:"contacts"` BaseResponse }
type ContactsService ¶
type ContactsService service
ContactsService handles communication with the contacts related methods of the Remember The Milk API.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods.rtm
func (*ContactsService) GetList ¶
GetList retrieves a list of contacts.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.contacts.getList.rtm
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response `json:"-"` Code int `json:"code"` Message string `json:"message"` }
ErrorResponse reports an error caused by an API request.
Remember the Milk API docs: https://www.rememberthemilk.com/services/api/response.rtm
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type FailureResponse ¶
type GetFrobResponse ¶
type GetFrobResponse struct { Frob string `json:"frob"` BaseResponse }
type GetTokenOptions ¶
type GetTokenOptions struct { Frob string `url:"frob"` BaseAPIURLOptions }
type GetTokenResponse ¶
type GetTokenResponse struct { Authentication Authentication `json:"auth"` BaseResponse }
type List ¶
type List struct { ID string `json:"id"` Name string `json:"name"` Deleted string `json:"deleted"` Locked string `json:"locked"` Archived string `json:"archived"` Position string `json:"position"` Smart string `json:"smart"` SortOrder string `json:"sort_order"` Permission string `json:"permission"` }
type ListService ¶
type ListService service
ListService handles communication with the lists related methods of the Remember The Milk API.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods.rtm
func (*ListService) GetList ¶
GetList retrieves a list of lists.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.lists.getList.rtm
type ListsGetListResponse ¶
type ListsGetListResponse struct { Lists ListList `json:"lists"` BaseResponse }
type RequestOption ¶
RequestOption represents an option that can modify an http.Request.
type Response ¶
Response is a Remember the Milk API response. This wraps the standard http.Response returned from Remember the Milk and provides convenient access to API specific things.
type TagService ¶
type TagService service
TagService handles communication with the tags related methods of the Remember The Milk API.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods.rtm
func (*TagService) GetList ¶
GetList retrieves a list of tags.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.tags.getList.rtm
type TagsGetListResponse ¶
type TagsGetListResponse struct { Tags TagList `json:"tags"` BaseResponse }
type Task ¶
type Task struct { ID string `json:"id"` Due string `json:"due"` HasDueTime string `json:"has_due_time"` Added string `json:"added"` Completed string `json:"completed"` Deleted string `json:"deleted"` Priority string `json:"priority"` Postponed string `json:"postponed"` Estimate string `json:"estimate"` Start string `json:"start"` HasStartTime string `json:"has_start_time"` }
type TaskAddResponse ¶
type TaskAddResponse struct { Transaction Transaction `json:"transaction"` List TaskList `json:"list"` BaseResponse }
type TaskInput ¶
type TaskInput struct { Timeline string `url:"timeline,omitempty"` ListID string `url:"list_id,omitempty"` Name string `url:"name,omitempty"` Parse int `url:"parse,omitempty"` ParentID string `url:"parent_task_id,omitempty"` ExternalID string `url:"external_id,omitempty"` GiveTo string `url:"give_to,omitempty"` BaseAPIURLOptions }
type TaskList ¶
type TaskList struct { ID string `json:"id"` Taskseries []Taskseries `json:"taskseries"` }
type TaskService ¶
type TaskService service
TagService handles communication with the tasks related methods of the Remember The Milk API.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/tasks.rtm
func (*TaskService) Add ¶
func (s *TaskService) Add(ctx context.Context, task TaskInput) (*TaskAddResponse, *Response, error)
Add adds a task, TaskInput.Name, to the list specified by TaskInput.ListID. If TaskInput.ListID is omitted, the task will be added to the Inbox. If TaskInput.Parse is ParseWithSmartAdd (1), Smart Add will be used to process the task. If TaskInput.ParentTaskID is provided and the user has a Pro account, the new task is created as a sub-task, with the list of the TaskInput.ParentTaskID taking priority over the provided TaskInput.ListID.
This method requires a timeline.
Docs about Smart Add: https://www.rememberthemilk.com/help/?ctx=basics.smartadd.whatis Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.tasks.add.rtm
type Taskseries ¶
type Taskseries struct { ID string `json:"id"` Created string `json:"created"` Modified string `json:"modified"` Name string `json:"name"` Source string `json:"source"` URL string `json:"url"` LocationID string `json:"location_id"` ParentTaskID string `json:"parent_task_id"` Task []Task `json:"task"` }
type TestLoginResponse ¶
type TestLoginResponse struct { User User `json:"user"` BaseResponse }
type TestService ¶
type TestService service
TestService handles communication with the test related methods of the Remember The Milk API.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods.rtm
func (*TestService) Login ¶
Login represents a testing method which checks if the caller is logged in.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.test.login.rtm
type TimelineService ¶
type TimelineService service
TimelineService handles communication with the timeline related methods of the Remember The Milk API.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/timelines.rtm
func (*TimelineService) Create ¶
Create returns a new timeline.
Remember The Milk API docs: https://www.rememberthemilk.com/services/api/methods/rtm.timelines.create.rtm
type TimelinesCreateResponse ¶
type TimelinesCreateResponse struct { Timeline string `json:"timeline"` BaseResponse }