lib/pupil/schemes.rb in pupil-0.2.2 vs lib/pupil/schemes.rb in pupil-0.3.0
- old
+ new
@@ -12,11 +12,11 @@
def initialize(element, access_token=nil)
@access_token = access_token
@element = element
end
- def methods() @element.keys.map{|k|k.to_sym} ; end
+ def params() @element.keys.map{|k|k.to_sym} ; end
end
class User < Scheme
def status
Pupil::Status.new(@element["status"], @access_token) rescue nil
@@ -40,15 +40,45 @@
{:url => $1, :name => $2}
end
def entities() Pupil::Entities.new(@element["entities"]) rescue nil; end
- def destroy()
- self.post("/1/statuses/destroy/#{@element["id"]}.json")
+ def destroy(param={})
+ self.post("/1/statuses/destroy/#{@element["id"]}.json", param)
end
alias_method :delete, :destroy
+
+ def retweet(param={})
+ self.post("/1/statuses/retweet/#{@element["id"]}.json", param)
+ end
+
+ def retweets(param={})
+ response = self.get("/1/statuses/retweets/#{@element["id"]}.json", param)
+ return false unless response
+ statuses = []
+ response.each do |status|
+ statuses << Pupil::Status.new(status, @access_token)
+ end
+ return statuses
+ end
+
+ def retweeted_by(param={})
+ response = self.get("/1/statuses/#{@element["id"]}/retweeted_by.json", param)
+ return false unless response
+ users = []
+ response.each do |user|
+ users << Pupil::User.new(user, @access_token)
+ end
+ return users
+ end
+
+ def retweeted_by_user_ids(param={})
+ response = self.get("/1/statuses/#{@element["id"]}/retweeted_by/ids.json", param)
+ return false unless response
+ return response
+ end
end
class List < Scheme
def user() Pupil::User.new(@element["user"], @access_token) rescue nil; end
@@ -143,7 +173,19 @@
class UserMention < Scheme; end
class DirectMessage < Scheme
def sender() Pupil::User.new(@element["sender"], @access_token) rescue nil; end
def recipient() Pupil::User.new(@element["recipient"], @access_token) rescue nil; end
+
+ # Delete direct message
+ # @param [Fixnum] dm_id message id that you want to delete
+ # @return [Hash] response
+ def destroy()
+ begin
+ response = self.post("/1/direct_messages/destroy/#{@element["id"]}.json")
+ rescue
+ return false
+ end
+ return response
+ end
end
end
\ No newline at end of file