-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26d535a
commit fe41374
Showing
80 changed files
with
2,815 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Requires -Modules psake | ||
Invoke-PSake $PSScriptRoot\build.psake.ps1 -taskList BeforeBuild,GenerateMarkdown,Build,NewVersionDir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Class TodoistTask { | ||
[int64]$Id | ||
[int64]$ProjectID | ||
[string]$Content | ||
[Array]$due | ||
[Array]$LabelIDs | ||
[System.Collections.ArrayList]$Labels | ||
[int32]$CommentCount | ||
[int32]$Order | ||
[int32]$Indent | ||
[int32]$Priority | ||
[string]$Url | ||
|
||
hidden [Array]$Output | ||
|
||
TodoistTask($Item) { | ||
$this.Id = $item.Id | ||
$this.ProjectID = $item.project_id | ||
$this.Content = $item.content | ||
if ($item.comment_count -ne $null) { | ||
$this.CommentCount = $item.comment_count | ||
} | ||
|
||
if ($item.due -ne $null) { | ||
$this.due = $item.due | ||
} | ||
|
||
$item.label_ids | foreach {$this.LabelIDs += [string]$_} | ||
|
||
|
||
$this.Order = $item.order | ||
$this.Indent = $item.indent | ||
$this.Priority = $item.priority | ||
$this.Url = $item.url | ||
} | ||
close() { | ||
Close-TodoistTask -Id $this.Id | ||
} | ||
open() { | ||
Open-TodoistTask -Id $this.Id | ||
} | ||
remove() { | ||
Remove-TodoistTask -Id $this.Id | ||
} | ||
update() { | ||
Update-TodoistTask -Id $this.Id -Content $this.Content -Priority $this.Priority -ProjectID $this.ProjectID -LabelIDs $this.LabelIDs | ||
} | ||
updatewithduestring($DueString) { | ||
Update-TodoistTask -Id $this.Id -Content $this.Content -Priority $this.Priority -ProjectID $this.ProjectID -LabelIDs $this.LabelIDs -DueString $DueString | ||
} | ||
refresh() { | ||
$task = Get-TodoistTask | ? {$_.Id -eq $this.id} | ||
$this = $task | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# | ||
# Module manifest for module 'PSGet_PSTodoist' | ||
# | ||
# Generated by: Alex Asplund | ||
# | ||
# Generated on: 2018-07-31 | ||
# | ||
|
||
@{ | ||
|
||
# Script module or binary module file associated with this manifest. | ||
RootModule = 'PSTodoist.psm1' | ||
|
||
# Version number of this module. | ||
ModuleVersion = '0.0.0' | ||
|
||
# Supported PSEditions | ||
# CompatiblePSEditions = @() | ||
|
||
# ID used to uniquely identify this module | ||
GUID = '1814fced-426c-44ec-a0b8-0f0c02fb6147' | ||
|
||
# Author of this module | ||
Author = 'Alex Asplund' | ||
|
||
# Company or vendor of this module | ||
CompanyName = 'automativity.com' | ||
|
||
# Copyright statement for this module | ||
Copyright = '(c) 2018 Alex Asplund. All rights reserved.' | ||
|
||
# Description of the functionality provided by this module | ||
Description = 'A powershell module that uses the Todoist V8 BETA api' | ||
|
||
# Minimum version of the Windows PowerShell engine required by this module | ||
# PowerShellVersion = '' | ||
|
||
# Name of the Windows PowerShell host required by this module | ||
# PowerShellHostName = '' | ||
|
||
# Minimum version of the Windows PowerShell host required by this module | ||
# PowerShellHostVersion = '' | ||
|
||
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. | ||
# DotNetFrameworkVersion = '' | ||
|
||
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. | ||
# CLRVersion = '' | ||
|
||
# Processor architecture (None, X86, Amd64) required by this module | ||
# ProcessorArchitecture = '' | ||
|
||
# Modules that must be imported into the global environment prior to importing this module | ||
# RequiredModules = @() | ||
|
||
# Assemblies that must be loaded prior to importing this module | ||
# RequiredAssemblies = @() | ||
|
||
# Script files (.ps1) that are run in the caller's environment prior to importing this module. | ||
# ScriptsToProcess = @() | ||
|
||
# Type files (.ps1xml) to be loaded when importing this module | ||
# TypesToProcess = @() | ||
|
||
# Format files (.ps1xml) to be loaded when importing this module | ||
# FormatsToProcess = @() | ||
|
||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess | ||
# NestedModules = @() | ||
|
||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. | ||
FunctionsToExport = 'Close-TodoistTask', 'Get-TestString', 'Get-TodoistComment', | ||
'Get-TodoistLabel', 'Get-TodoistProject', 'Get-TodoistTask', | ||
'New-TodoistComment', 'New-TodoistLabel', 'New-TodoistProject', | ||
'New-TodoistTask', 'Open-TodoistTask', 'Remove-TodoistComment', | ||
'Remove-TodoistLabel', 'Remove-TodoistProject', 'Remove-TodoistTask', | ||
'Set-TodoistToken', 'Update-TodoistComment', 'Update-TodoistLabel', | ||
'Update-TodoistProject', 'Update-TodoistTask' | ||
|
||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. | ||
CmdletsToExport = @() | ||
|
||
# Variables to export from this module | ||
# VariablesToExport = @() | ||
|
||
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. | ||
AliasesToExport = @() | ||
|
||
# DSC resources to export from this module | ||
# DscResourcesToExport = @() | ||
|
||
# List of all modules packaged with this module | ||
# ModuleList = @() | ||
|
||
# List of all files packaged with this module | ||
# FileList = @() | ||
|
||
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. | ||
PrivateData = @{ | ||
|
||
PSData = @{ | ||
|
||
# Tags applied to this module. These help with module discovery in online galleries. | ||
# Tags = @() | ||
|
||
# A URL to the license for this module. | ||
# LicenseUri = '' | ||
|
||
# A URL to the main website for this project. | ||
# ProjectUri = '' | ||
|
||
# A URL to an icon representing this module. | ||
# IconUri = '' | ||
|
||
# ReleaseNotes of this module | ||
ReleaseNotes = '# Release notes | ||
## 0.0.1 | ||
Initial creation of project with plaster template' | ||
|
||
# External dependent modules of this module | ||
# ExternalModuleDependencies = '' | ||
|
||
} # End of PSData hashtable | ||
|
||
} # End of PrivateData hashtable | ||
|
||
# HelpInfo URI of this module | ||
# HelpInfoURI = '' | ||
|
||
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. | ||
# DefaultCommandPrefix = '' | ||
|
||
} | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<# | ||
.SYNOPSIS | ||
Sets the SSL-setting of powershell to "tls12, tls11, tls" so that it supports pages with newer TLS settings | ||
.EXAMPLE | ||
Set-TodoistSSLSettings | ||
#> | ||
function Set-TodoistSSLSettings | ||
{ | ||
if ([Net.ServicePointManager]::SecurityProtocol -ne "tls12, tls11, tls") | ||
{ | ||
Write-Verbose "Running command Set-TodoistSSLSettings" | ||
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<# | ||
.SYNOPSIS | ||
Closes a Todoist task | ||
.DESCRIPTION | ||
Closes a Todoist task, can either be via array or INT array. | ||
Can also be supplied through pipeline | ||
.EXAMPLE | ||
Close-TodoistTask -Id 123456789 | ||
.EXAMPLE | ||
Close-TodoistTask -Id 098765432,123466721 | ||
.EXAMPLE | ||
Get-TodoistTask | ? {$_.Content -match "Stop Procrastinating"} | Close-TodoistTask | ||
#> | ||
function Close-TodoistTask | ||
{ | ||
[cmdletbinding()] | ||
param( | ||
# Id of the todoist task | ||
[Parameter( | ||
ValueFromPipelineByPropertyName = $True, | ||
Mandatory = $True )] | ||
[int64[]]$Id, | ||
|
||
# Todoist token if it's not set as a global variable with Set-TodoistToken | ||
[string]$Token = $Global:TodoistToken | ||
) | ||
|
||
begin | ||
{ | ||
|
||
$Header = @{ | ||
"Authorization" = "Bearer $($token)" | ||
} | ||
$Requests = $() | ||
} | ||
|
||
process | ||
{ | ||
|
||
$Id | Foreach { | ||
|
||
$Uri = "https://beta.todoist.com/API/v8/tasks/$_/close" | ||
Write-Output $Uri | ||
$Request = Invoke-RestMethod -Headers $Header -Method Post -Uri $Uri | ||
$Requests += $Request | ||
} | ||
} | ||
|
||
end | ||
{ | ||
return $Requests | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets all comments for a project or task | ||
.DESCRIPTION | ||
Gets all comments for a project or task. Selection if Id is for a project or task is done through parameter "category" | ||
.EXAMPLE | ||
Get-TodoistComment -Id 1234 -Category "Task" | ||
.EXAMPLE | ||
Get-TodoistComment -Id 5678 -Category "Category" | ||
#> | ||
function Get-TodoistComment | ||
{ | ||
[CmdletBinding()] | ||
param ( | ||
[parameter(ValueFromPipelineByPropertyName, Mandatory = $True)] | ||
[int64]$Id, | ||
[parameter(Mandatory)] | ||
[ValidateSet("Project", "Task")] | ||
[String]$Category, | ||
|
||
[string]$Token = $Global:TodoistToken | ||
) | ||
|
||
begin | ||
{ | ||
|
||
$Category = $Category.ToLower() | ||
|
||
Write-Verbose "Beginning to fetch comments for $Category $Id" | ||
|
||
$Header = @{ | ||
'Content-Type' = "application/json" | ||
"Authorization" = "Bearer $($Token)" | ||
} | ||
|
||
} | ||
|
||
process | ||
{ | ||
$Uri = ("https://beta.todoist.com/API/v8/comments?" + $Category + "_id=" + $Id) | ||
Write-Verbose $Uri | ||
$Request = Invoke-RestMethod -Headers $Header -Method Get -Uri $Uri | ||
|
||
$Comments = @() | ||
|
||
foreach ($Comment in $Request) | ||
{ | ||
try | ||
{ | ||
$Comments += $Comment | ||
} | ||
catch | ||
{ | ||
Write-Error $_ | ||
|
||
} | ||
} | ||
} | ||
|
||
end | ||
{ | ||
Return $Comments | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets all todoist labels | ||
.DESCRIPTION | ||
Gets all todoist labels | ||
.EXAMPLE | ||
Get-Todoistlabel | ||
.EXAMPLE | ||
Get-Todoistlabel -Token 1q2w3e4r5t6y7u8i99o0p | ||
.EXAMPLE | ||
$labels = Get-Todoistlabel | ? {$_.Content -match "My label"} | ||
#> | ||
function Get-TodoistLabel | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
# Todoist token if it's not set as a global variable with Set-TodoistToken | ||
[parameter(ValueFromPipelineByPropertyName = $True)] | ||
[string]$Token = $Global:TodoistToken | ||
) | ||
|
||
begin | ||
{ | ||
|
||
Write-Verbose "Beginning to fetch labels" | ||
|
||
$Header = @{ | ||
'Content-Type' = "application/json" | ||
"Authorization" = "Bearer $($Token)" | ||
} | ||
} | ||
|
||
process | ||
{ | ||
$Request = Invoke-RestMethod -Headers $Header -Method Get -Uri 'https://beta.todoist.com/API/v8/labels' | ||
|
||
$labels = @() | ||
|
||
foreach ($label in $Request) | ||
{ | ||
try | ||
{ | ||
$labels += $Label | ||
} | ||
catch | ||
{ | ||
Write-Error $_ | ||
|
||
} | ||
} | ||
} | ||
|
||
end | ||
{ | ||
Return $labels | ||
} | ||
|
||
} |
Oops, something went wrong.