Module: Idonethis::UseCases::New

Defined in:
lib/idonethis/use_cases/new.rb

Class Method Summary collapse

Class Method Details

.apply(credential, args = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/idonethis/use_cases/new.rb', line 4

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