Class: Jammed::Likes

Inherits:
API
  • Object
show all
Defined in:
lib/jammed/likes.rb

Overview

Provides methods for calling API endpoint /likes.json?

Class Method Summary collapse

Methods inherited from API

request

Class Method Details

.likes(username, api_key, opts = {}) ⇒ Object

Calls API for user specific data concerning likes

Attributes

  • username - The username of the user whose followings you want to retrieve

  • api_key - The key to use with the API call

  • opts - Options for which data is shown

Options

  • :show - A symbol determining what data is shown like :past or :current

Examples

Jammed::Likes.likes('IFTFOM', '08972935872035') #returns all likes
Jammed::Likes.likes('IFTFOM', '08972935872035', :show => :past) # returns only past likes


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jammed/likes.rb', line 22

def self.likes(username, api_key, opts={})
  case(opts[:show])
  when nil
    response = request(:get, "/#{username}/likes.json", {:https => opts[:https],
      :query => {:key => api_key}})
  when :current
    response = request(:get, "/#{username}/likes.json", {:https => opts[:https],
      :query => {:show => 'current', :key => api_key}})
  when :past
    response = request(:get, "/#{username}/likes.json", {:https => opts[:https],
      :query => {:show => 'past', :key => api_key}})
  end
  JSON.parse(response.body)['jams']
end