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] log.call "args: #{args}" log.call "overriding team <#{credential[:team]}> with <#{team}>" parse internet.post( Idonethis::Index.dones, { "Authorization" => "Token #{credential[:token]}", accept: "application/json"}, { "raw_text" => args[:message], "team" => (team || credential[:team])}) end private def parse(reply) require 'json' JSON.parse(reply.body) end end end end