Sha256: 616a523da7e6b7bc52b4fb498b797fb629ca172b13e69195e63128500402aa53

Contents?: true

Size: 821 Bytes

Versions: 7

Compression:

Stored size: 821 Bytes

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]
        
        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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
idonethis-cli-0.14.2 lib/idonethis/use_cases/new.rb
idonethis-cli-0.14.1 lib/idonethis/use_cases/new.rb
idonethis-cli-0.14.0 lib/idonethis/use_cases/new.rb
idonethis-cli-0.13.3 lib/idonethis/use_cases/new.rb
idonethis-cli-0.13.2 lib/idonethis/use_cases/new.rb
idonethis-cli-0.13.1 lib/idonethis/use_cases/new.rb
idonethis-cli-0.13.0 lib/idonethis/use_cases/new.rb