Sha256: a84a1902f9dcb3c4546453d678e1f477f2d47e6566eefd242a6948f2d48dae9f

Contents?: true

Size: 671 Bytes

Versions: 8

Compression:

Stored size: 671 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")

        log.call "args: #{args}"
        
        parse internet.post(
          Idonethis::Index.dones,
          { "Authorization" => "Token #{credential[:token]}", accept: "application/json"},
          { "raw_text"      => args[:message], "team" => credential[:team]})
      end

      private

      def parse(reply)
        require 'json'
        
        JSON.parse(reply.body)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
idonethis-cli-0.6.0 lib/idonethis/use_cases/new.rb
idonethis-cli-0.5.0 lib/idonethis/use_cases/new.rb
idonethis-cli-0.4.1 lib/idonethis/use_cases/new.rb
idonethis-cli-0.4.0 lib/idonethis/use_cases/new.rb
idonethis-cli-0.3.0 lib/idonethis/use_cases/new.rb
idonethis-cli-0.2.2 lib/idonethis/use_cases/new.rb
idonethis-cli-0.2.1 lib/idonethis/use_cases/new.rb
idonethis-cli-0.2.0 lib/idonethis/use_cases/new.rb