Sha256: 3e0e97bddee58067f09c2a66ffbfc681e780215cd2721898faf3081933b97461

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class Pupil
  # Returning direct messages
  # @param [Hash] param
  # @return [Hash] directmessages
  def direct_messages(param = {})
    response = self.get("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("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("direct_messages/new.json", {:text => sentence, guess_parameter(opts[:to]) => opts[:to]})
    return false unless response
    response
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pupil-0.7 lib/pupil/direct_messages.rb