Class: Rnvivo::Nvivo

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rnvivo.rb

Constant Summary collapse

API_URL =
"http://www.nvivo.es/api/request.php"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, timeout = 30) ⇒ Nvivo

Returns a new instance of Nvivo.



25
26
27
28
# File 'lib/rnvivo.rb', line 25

def initialize(key, timeout = 30)
  @api_key = key
  @timeout = timeout
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



23
24
25
# File 'lib/rnvivo.rb', line 23

def api_key
  @api_key
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



23
24
25
# File 'lib/rnvivo.rb', line 23

def timeout
  @timeout
end

Instance Method Details

#artistGetEvents(artist, country = 'all', past = false) ⇒ Object

Raises:

  • (ArgumentError)


42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rnvivo.rb', line 42

def artistGetEvents(artist, country='all', past = false)
  raise ArgumentError, 'You must indicate an artist' if artist.blank?

  options = query 'artist.getEvents',
                  :artist => artist,
                  :county_iso => country,
                  :past => past

  deal_with_response_for options do |r|
    return nested_result r, 'response', 'events', 'event'
  end
end

#cityGetEvents(city, country = 'all') ⇒ Object

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rnvivo.rb', line 30

def cityGetEvents(city, country = 'all')
  raise ArgumentError, 'You must indicate a city' if city.blank?

  options = query 'city.getEvents',
                  :city => city,
                  :country_iso => country

  deal_with_response_for options do |r|
    return nested_result r, 'response', 'events', 'event'
  end
end

#userGetEvents(user) ⇒ Object

Raises:

  • (ArgumentError)


67
68
69
70
71
72
73
74
75
76
# File 'lib/rnvivo.rb', line 67

def userGetEvents(user)
  raise ArgumentError, 'You must indicate a user' if user.blank?

  options = query 'user.getEvents',
                  :user => user

  deal_with_response_for(options) do |r|
    return nested_result r, 'response', 'events', 'event'
  end
end

#venueFind(venue_name, country = 'all') ⇒ Object

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rnvivo.rb', line 78

def venueFind(venue_name, country='all')
  raise ArgumentError, 'You must indicate a venue name' if venue_name.blank?

  options = query 'venue.find',
                  :venue_name => venue_name,
                  :country_iso => country

  deal_with_response_for options do |r|
    return nested_result r, 'response', 'venues', 'venue'
  end
end

#venueGet(venue_id) ⇒ Object

Raises:

  • (ArgumentError)


90
91
92
93
94
95
96
97
98
99
# File 'lib/rnvivo.rb', line 90

def venueGet(venue_id)
  raise ArgumentError, 'You must inidicate a venue id' if venue_id.blank?

  options = query 'venue.get',
                  :venue_id => venue_id

  deal_with_response_for options do |r|
    return nested_result r, 'response', 'venue'
  end
end

#venueGetEvents(venue_id, past = false) ⇒ Object

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rnvivo.rb', line 55

def venueGetEvents(venue_id, past = false)
  raise ArgumentError, 'You must indicate a venue' if venue_id.blank?

  options = query 'venue.getEvents',
                  :venue_id => venue_id,
                  :past => past

  deal_with_response_for options do |r|
    return nested_result r, 'response', 'events', 'event'
  end
end