Sha256: 656676d0b9ff841516458a410781f9c965a251e36747dbdf8376adbed3af405b

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module Twitterland
  class Mrtweet
    include HTTParty
    base_uri 'api.mrtweet.com/v1'
    format :json
    
    attr_reader :is_user, :profile, :recommendations, :most_attention_towards
    
    def initialize(api_key, username)
      @username = username
      @api_key = api_key
      @is_user = self.is_user
    end
  
    def is_user
      Mash.new(self.class.get("/is_user/#{@username}/#{@api_key}.json")).is_user
    end
    
    def is_user?
      @is_user
    end
    
    def profile
      if is_user?
        @profile ||= Mash.new(self.class.get("/profile/#{@username}/#{@api_key}.json")).profile
      end
    end
    
    def recommendations
      if is_user?
        @recommendations ||= Mash.new(self.class.get("/recommendations/#{@username}/#{@api_key}.json")).recommendations
      end
    end
    
    def most_attention_towards
      if is_user?
        @most_attention_towards ||= Mash.new(self.class.get("/most_attention_towards/#{@username}/#{@api_key}.json")).most_attention_towards
      end
    end
    
    def recommend(reason, friend_name)
      if is_user?
        Mash.new(self.class.post("/recommend/#{@username}/#{@api_key}.json", :body => { :reason => reason, :friend_name => friend_name})).status == "success"
      end
    end
   
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
squeejee-twitterland-0.1.1 lib/twitterland/mrtweet.rb
twitterland-0.1.0 lib/twitterland/mrtweet.rb
twitterland-0.1.1 lib/twitterland/mrtweet.rb