class IdonethisCli::Entry
Public Instance Methods
list()
click to toggle source
# File lib/idonethis_cli/entry.rb, line 31 def list return nil unless authenticated? return nil unless team_set? if entries = entry_client.list(settings.team['hash_id']) entries.each.with_index(1) do |entry, idx| cli.say "#{entry['created_at']} : #{entry['status']} : #{entry['body']}" end else cli.say "Could not retrieve entries. #{entry_client.error}" end end
new(body)
click to toggle source
# File lib/idonethis_cli/entry.rb, line 7 def new(body) return nil unless authenticated? return nil unless team_set? post_entry body end
prompt()
click to toggle source
# File lib/idonethis_cli/entry.rb, line 15 def prompt return nil unless authenticated? return nil unless team_set? cli.say "Enter your entries. Hit <enter> when done." body = cli.ask "What did you get done?" while body.length > 1 post_entry body body = cli.ask "What did you get done?" end end
Private Instance Methods
entry_client()
click to toggle source
# File lib/idonethis_cli/entry.rb, line 45 def entry_client @client ||= IdonethisCli::Client::Entry.new(token) end
post_entry(body)
click to toggle source
# File lib/idonethis_cli/entry.rb, line 49 def post_entry(body) response = entry_client.create(settings.team['hash_id'], body) if response cli.say "Entry created for #{response['user']['full_name']} on #{settings.team['name']}" else cli.say "Entry could not be created #{entry_client.error}" end end