Sha256: 750e38bd13416acf19b6a41d946e155f3246267f0fdde207704adff0ccbb5264

Contents?: true

Size: 736 Bytes

Versions: 7

Compression:

Stored size: 736 Bytes

Contents

require 'dude/time_trackers/toggl/base'

module Dude
  module Toggl
    class StopTimeEntry < Dude::Toggl::Base
      def call
        stop_current_time_entry
        print_success_message
      rescue NoMethodError
        print_error_message
      end

      def stop_current_time_entry
        toggl_api.put("api/v8/time_entries/#{current_time_entry['id']}/stop", '')
      end

      def current_time_entry
        JSON.parse(toggl_api.get('api/v8/time_entries/current').body)['data']
      end

      def print_success_message
        puts 'Suspended current time entry in Toggl'.colorize(:green)
      end

      def print_error_message
        puts 'No runned time entries in Toggl'.colorize(:yellow)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dude-cli-2.0.6 lib/dude/time_trackers/toggl/stop_time_entry.rb
dude-cli-2.0.5 lib/dude/time_trackers/toggl/stop_time_entry.rb
dude-cli-2.0.4 lib/dude/time_trackers/toggl/stop_time_entry.rb
dude-cli-2.0.3 lib/dude/time_trackers/toggl/stop_time_entry.rb
dude-cli-2.0.2 lib/dude/time_trackers/toggl/stop_time_entry.rb
dude-cli-2.0.1 lib/dude/time_trackers/toggl/stop_time_entry.rb
dude-cli-2.0.0 lib/dude/time_trackers/toggl/stop_time_entry.rb