ConcatDK / elm-todoist / TodoistRest

This library provides functions for integration with the Todoist rest Api.

Data types


type alias Token =
String

A todoist access token. This is needed for all calls to the api. This can be found on: https://todoist.com/prefs/integrations at the very bottom of the page.


type alias Project =
{ id : Basics.Int
, name : String
, order : Basics.Int
, indent : Basics.Int
, commentCount : Basics.Int 
}

The Todoist Project type represents a project in todoist. It has the following values:

* id: Integer - The project unique id on the Todoist platform
* name: String - The name of the project
* order: Int - The order of the projects in the users setup
* indent: Int - An int ranging from 1 to 4 for the project indentation level.
* commentCount: Int - The amount of comments on a project.


type alias Task =
{ id : Basics.Int
, projectId : Basics.Int
, completed : Basics.Bool
, content : String
, labelIds : List Basics.Int
, order : Basics.Int
, indent : Basics.Int
, priority : Basics.Int
, due : Maybe Due
, url : String
, commentCount : Basics.Int 
}

The task type represents a todoist task. It has the following values:

* id : Int - The task unique id in Todoist
* projectId : Int - The id of the project the task is in
* completed : Bool - If the task is completed or not
* labelIds : List Int - A list of all associated label ids
* order : Int - The order of the task in the project it is in
* indent : Int - Indention level of the task in the project
* priority : Int - The priority of the task, takes on a value from 1 to 4.
* due : Maybe Due - A due object telling when the task is due, Nothing if no due date is specified
* url : String - The permanent link to the task page on Todoist.com
* commentCount : Int - The amount of comments on the task.


type alias Due =
{ date : String
, string : String
, datetime : Maybe String
, timezone : Maybe String 
}

The Due type represents a due date. It has the following values:

* date : String - This is a String telling when the due time is.
* string : String - A human readable representation of the due date
* datetime : String - A datetime representing the die date
* timezone : String - The timezone the datetime is set in


type alias Label =
{ id : Basics.Int
, name : String
, order : Basics.Int 
}

The label type represents a Todoist label. It has the following values:

* id : Int - The label unique id in Todoist
* name : String - The label name
* order : Int - The order number of the label in the list of all labels.

Api calls

Projects

getAllProjects : (Result Http.Error (List Project) -> msg) -> Token -> Platform.Cmd.Cmd msg

Makes a get request for all the projects associated with the provided token.

getProject : (Result Http.Error Project -> msg) -> Basics.Int -> Token -> Platform.Cmd.Cmd msg

Makes a get request for the project associated with the provided id. Will fail if the provided token does not grant access to the project.

Tasks

getActiveTasks : (Result Http.Error (List Task) -> msg) -> Token -> Platform.Cmd.Cmd msg

Makes a get request for all the active tasks associated with the provided token.

getActiveTask : (Result Http.Error (List Task) -> msg) -> Basics.Int -> Token -> Platform.Cmd.Cmd msg

Makes a get request for the task associated with the provided id.

getActiveTasksWithFilter : (Result Http.Error (List Task) -> msg) -> String -> Token -> Platform.Cmd.Cmd msg

Gets all active tasks that satisfies a todoist query (for help visit: https://get.todoist.help/hc/en-us/articles/205248842-Filters)

getActiveTasksWithFilter FetchShoppingTasks "@buy | #Shopping" myToken

Labels

getLabel : (Result Http.Error Label -> msg) -> Basics.Int -> Token -> Platform.Cmd.Cmd msg

Makes a get request for the label associated with the provided id.

getAllLabels : (Result Http.Error (List Label) -> msg) -> Token -> Platform.Cmd.Cmd msg

Makes a get request for all the labels associated with the provided token.