Sha256: b85f36a3a4d2da37854698e7cdc689c5039625a67427dbc4a80e715a842e1b7c

Contents?: true

Size: 695 Bytes

Versions: 4

Compression:

Stored size: 695 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

4 entries across 4 versions & 1 rubygems

Version Path
idonethis-cli-0.9.0 lib/idonethis/use_cases/new.rb
idonethis-cli-0.8.1 lib/idonethis/use_cases/new.rb
idonethis-cli-0.8.0 lib/idonethis/use_cases/new.rb
idonethis-cli-0.7.0 lib/idonethis/use_cases/new.rb