Sha256: b643b4a007c1a23ae1d5f40dd0fa05fd6f2e2028031e7120bb6158b6a1e3802f

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

class Pupil
  # Returning direct messages
  # @param [Hash] param
  # @return [Hash] directmessages
  def direct_messages(param = {})
    response = self.get("/1/direct_messages.json", param)
    return false unless response
    directmessages = Array.new
    response.each do |element|
      dm = DirectMessage.new(element, @access_token)
      directmessages << dm
    end

    return directmessages
  end

  # Returning direct messages you sent
  # @param [Hash] param
  # @return [Hash] directmessage you sent
  def sent_direct_messages(param = {})
    response = self.get("/1/direct_messages/sent.json", param)
    return false unless response
    directmessages = Array.new
    response.each do |element|
      dm = DirectMessage.new(element, @access_token)
      directmessages << dm
    end

    return directmessages
  end
  
  def send_direct_message(sentence, opts)
    raise ArgumentError, ":to parameter not given" unless opts[:to]
    response = self.post("/1/direct_messages/new.json", {:text => sentence, guess_parameter(opts[:to]) => opts[:to]})
    return false unless response
    response
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pupil-0.6.2 lib/pupil/direct_messages.rb
pupil-0.6.1 lib/pupil/direct_messages.rb
pupil-0.6 lib/pupil/direct_messages.rb
pupil-0.5 lib/pupil/direct_messages.rb
pupil-0.4.1 lib/pupil/direct_messages.rb
pupil-0.4 lib/pupil/direct_messages.rb
pupil-0.3.3 lib/pupil/direct_messages.rb
pupil-0.3.2 lib/pupil/direct_messages.rb
pupil-0.3.1 lib/pupil/direct_messages.rb
pupil-0.3.0 lib/pupil/direct_messages.rb