Module: Zvents
- Defined in:
- lib/zvents.rb,
lib/zvents/event.rb,
lib/zvents/venue.rb,
lib/zvents/errors.rb,
lib/zvents/version.rb,
lib/zvents/connection.rb,
lib/zvents/configuration.rb,
lib/zvents/search_results.rb
Defined Under Namespace
Classes: Event, EventNotFoundError, SearchError, SearchResults, Venue, VenueNotFoundError
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
- .api_key ⇒ Object
- .api_key=(api_key) ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .connection ⇒ Object
-
.search(parameters = {}) ⇒ Object
Zvents.search(parameters) => an instance of SearchResults.
Class Method Details
.api_key ⇒ Object
10 11 12 |
# File 'lib/zvents/configuration.rb', line 10 def self.api_key @@api_key end |
.api_key=(api_key) ⇒ Object
6 7 8 |
# File 'lib/zvents/configuration.rb', line 6 def self.api_key=(api_key) @@api_key = api_key end |
.configure {|_self| ... } ⇒ Object
2 3 4 |
# File 'lib/zvents/configuration.rb', line 2 def self.configure yield self end |
.connection ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/zvents/connection.rb', line 2 def self.connection @connection ||= Faraday.new(url: 'http://www.zvents.com/') do |faraday| faraday.request :url_encoded # form-encode POST params faraday.response :logger # log requests to STDOUT faraday.adapter Faraday.default_adapter # make requests with Net::HTTP faraday.response :json end end |
.search(parameters = {}) ⇒ Object
Zvents.search(parameters) => an instance of SearchResults
can search by these parameters what = parameters e.g. “parade” where = parameters e.g. “San Francisco”, “94131”,
"-74.0BY:40.9" (Latitude by longitude), "California"
when = parameters e.g. “monday to thursday”,
"10/30/2007 to 11/4/2007"
radius = parameters
(number of miles around where field to search)
limit = parameters (max number of items to return) offset = parameters (number of items to skip from
beginning of the search results)
spn_limit = parameters (max number of sponsored
items to return)
cat = parameters (restrict your search to a specific
category)
has_kids = parameters (1 or 0.
1 means kid friendly. Events only)
city = parameters neighborhood = parameters trim = parameters (0 or 1. 1 trims repeat events.
default = 1)
has_tickets = parameters (0 or 1. 1 retuns
only events with tickets for sale)
sequence = parameters (restrict search to events
within a sequence. Multiple sequence ids can be provided
separated by a comma)
42 43 44 45 46 47 48 49 50 |
# File 'lib/zvents.rb', line 42 def self.search(parameters = {}) resource_url = "/partner_rest/search" response = find(resource_url, parameters) if response.body['rsp']['status'] != 'ok' raise Zvents::SearchError.new("search failed") end search_hash = response.body['rsp']['content'] SearchResults.new(search_hash) end |