diff options
author | kballou <kballou@devnulllabs.io> | 2016-06-21 11:35:11 -0600 |
---|---|---|
committer | kballou <kballou@devnulllabs.io> | 2016-06-21 11:35:11 -0600 |
commit | 77e4e8647d565218bfc72fbe569eb7eb00c4d8e6 (patch) | |
tree | 59e270b417e88374aad365e70f2992af410fb662 | |
parent | 4ca1b6dbdd1c58155faddde18908e6b09e80c757 (diff) | |
download | toglx-77e4e8647d565218bfc72fbe569eb7eb00c4d8e6.tar.gz toglx-77e4e8647d565218bfc72fbe569eb7eb00c4d8e6.tar.xz |
Add discard command to discard current time entry
Add a `discard` option for discontinue tracking on the current time entry.
-rw-r--r-- | lib/toglx.ex | 9 | ||||
-rw-r--r-- | lib/toglx/escript.ex | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/toglx.ex b/lib/toglx.ex index 454233b..9bb086c 100644 --- a/lib/toglx.ex +++ b/lib/toglx.ex @@ -24,6 +24,15 @@ defmodule Toglx do end end + def submit_discard_event do + case current do + %{data: nil} -> :ok + %{data: %{id: time_entry_id}} -> + create_togglex_client + |> Togglex.Api.TimeEntries.delete(time_entry_id) + end + end + def current do create_togglex_client |> Togglex.Api.TimeEntries.current diff --git a/lib/toglx/escript.ex b/lib/toglx/escript.ex index 5ccc40c..a50c5b1 100644 --- a/lib/toglx/escript.ex +++ b/lib/toglx/escript.ex @@ -15,4 +15,9 @@ defmodule Toglx.Escript do |> IO.inspect end + def run(%{cmd: "discard"}) do + Toglx.submit_discard_event + |> IO.inspect + end + end |