Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

addToDo from Things #332

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions __tests__/actions/addToDo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { addToDo } from '../../src/actions';

const id = 'com.culturedcode.ThingsiPhone.TINAddTodoIntent';

describe('addToDo function', () => {

it('is a function', () => {
expect(typeof addToDo).toBe('function');
});

it('builds an addToDo action when no options are passed', () => {
const expected = {
WFWorkflowActionIdentifier: id,
WFWorkflowActionParameters: {},
};
const actual = addToDo({});

expect(actual).toEqual(expected);
});

it('builds an addToDo action with evening option given', () => {
const evening = true;
const expected = {
WFWorkflowActionIdentifier: id,
WFWorkflowActionParameters: {
WFEvening: evening,
},
};
const actual = addToDo({ evening });

expect(actual).toEqual(expected);
});

});
38 changes: 38 additions & 0 deletions src/actions/addToDo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction';

/**
* @action Add To-Do
* @section Content Types > Apps > Things > Add To-Do
* @icon Things
*
* Adds a new to-do to Things.
*
* ```js
* addToDo();
* ```
*/

const cleanObject = (obj: {[key: string]: unknown}) => {
Object.keys(obj).forEach((key) => {
if (obj[key] === undefined) {
delete obj[key];
}
});
return obj;
};

const addToDo = ({
evening = undefined,
editInThings = undefined,
}: {
evening?: boolean,
editInThings?: boolean,
}): WFWorkflowAction => ({
WFWorkflowActionIdentifier: 'com.culturedcode.ThingsiPhone.TINAddTodoIntent',
WFWorkflowActionParameters: cleanObject({
WFEvening: evening,
WFEditInThings: editInThings,
}),
});

export default addToDo;
2 changes: 2 additions & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import addToDo from './addToDo';
import addToReadingList from './addToReadingList';
import addToVariable from './addToVariable';
import airDrop from './airDrop';
Expand Down Expand Up @@ -130,6 +131,7 @@ import waitToReturn from './waitToReturn';
import * as pythonista from './pythonista';

export {
addToDo,
addToReadingList,
addToVariable,
airDrop,
Expand Down
13 changes: 7 additions & 6 deletions src/interfaces/WF/WFWorkflowActionIdentifier.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
type WFWorkflowActionIdentifier = (
'com.apple.facetime.facetime'
| 'com.apple.facetime.facetime'
| 'com.apple.iBooks.openin'
| 'com.apple.mobilephone.call'
| 'com.apple.mobilenotes.SharingExtension'
| 'com.apple.mobilephone.call'
| 'com.burbn.instagram.openin'
| 'com.culturedcode.ThingsiPhone.TINAddTodoIntent'
| 'com.google.chrome.ios.openurl'
| 'com.omz-software.Pythonista.editscript'
| 'com.omz-software.Pythonista.runscript'
| 'is.workflow.actions.appendvariable'
| 'is.workflow.actions.airdropdocument'
| 'is.workflow.actions.airplanemode.set'
| 'is.workflow.actions.alarm.create'
| 'is.workflow.actions.alert'
| 'is.workflow.actions.appendvariable'
| 'is.workflow.actions.appendvariable'
| 'is.workflow.actions.ask'
| 'is.workflow.actions.avairyeditphoto'
| 'is.workflow.actions.base64encode'
Expand Down Expand Up @@ -81,16 +82,16 @@ type WFWorkflowActionIdentifier = (
| 'is.workflow.actions.notification'
| 'is.workflow.actions.number'
| 'is.workflow.actions.number.random'
| 'is.workflow.actions.openurl'
| 'is.workflow.actions.openapp'
| 'is.workflow.actions.openurl'
| 'is.workflow.actions.pausemusic'
| 'is.workflow.actions.playsound'
| 'is.workflow.actions.postonfacebook'
| 'is.workflow.actions.previewdocument'
| 'is.workflow.actions.print'
| 'is.workflow.actions.readinglist'
| 'is.workflow.actions.repeat.count'
| 'is.workflow.actions.removereminders'
| 'is.workflow.actions.repeat.count'
| 'is.workflow.actions.runextension'
| 'is.workflow.actions.runjavascriptonwebpage'
| 'is.workflow.actions.runscene'
Expand Down Expand Up @@ -121,9 +122,9 @@ type WFWorkflowActionIdentifier = (
| 'is.workflow.actions.tweet'
| 'is.workflow.actions.unzip'
| 'is.workflow.actions.url'
| 'is.workflow.actions.urlencode'
| 'is.workflow.actions.url.expand'
| 'is.workflow.actions.url.getheaders'
| 'is.workflow.actions.urlencode'
| 'is.workflow.actions.vibrate'
| 'is.workflow.actions.viewresult'
| 'is.workflow.actions.waittoreturn'
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/WF/WFWorkflowActionParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ interface WFWorkflowActionParameters {
WFBase64LineBreakMode?: WFSerialization | WFBase64LineBreakMode;
WFBrightness?: number;
WFCaseType?: WFSerialization | string;
WFEvening?: boolean;
WFEditInThings?: boolean;
WFCommentActionText?: string;
WFCondition?: WFCondition;
WFConditionalActionString?: string;
Expand Down