Class: Jammed::Jams

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

Overview

Provides methods for calling API endpoint /jams.json?

Class Method Summary (collapse)

Methods inherited from API

request

Class Method Details

+ (Object) jams(username, api_key, opts = {})

Calls API for user specific data concerning jams

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::Jams.jams('IFTFOM', '08972935872035') #returns all jams
Jammed::Jams.jams('IFTFOM', '08972935872035', :show => :past) # returns only past jams


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

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