Sha256: cf7939d466ce71623a72d19acf0bc623a01923acb60fefdd44b5f1de5a62d893
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
module Idonethis::UseCases module New class << self def apply(credential, args={}) log = args[:log] || fail("You need to supply :internet adapter") internet = args[:internet] || fail("You need to supply :internet adapter") team = args[:team] date = args[:date] log.call "args: #{args}" log.call "overriding team <#{credential[:team]}> with <#{team}>" body = { "raw_text" => args[:message], "team" => (team || credential[:team]) } if date date = Calendar.yesterday.to_s if date == 'yesterday' body = body.merge({"done_date" => Calendar.day_string(Time.parse(date))}) end log.call body parse internet.post( Idonethis::Index.dones, { "Authorization" => "Token #{credential[:token]}", accept: "application/json"}, body ) end def usage %Q{new -m "Birthday shopping + sushi lunch" --date 1-Oct-2015} end private def parse(reply) require 'json' fail reply.body unless reply.code == 201 JSON.parse(reply.body) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
idonethis-cli-0.20.0 | lib/idonethis/use_cases/new.rb |
idonethis-cli-0.19.1 | lib/idonethis/use_cases/new.rb |
idonethis-cli-0.19.0 | lib/idonethis/use_cases/new.rb |