Module: ThreetapsClient
- Extended by:
- ThreetapsClient
- Included in:
- ThreetapsClient
- Defined in:
- lib/threetaps_client.rb,
lib/threetaps_client/version.rb
Constant Summary collapse
- DOMAIN =
'3taps.com'
- SEARCH_END_POINT =
"http://search.#{DOMAIN}"
- POLLING_END_POINT =
"http://polling.#{DOMAIN}"
- REFERENCE_END_POINT =
"http://reference.#{DOMAIN}"
- ANCHOR_URL =
"#{POLLING_END_POINT}/anchor"
- POLL_URL =
"#{POLLING_END_POINT}/poll"
- DATA_SOURCES_URL =
"#{REFERENCE_END_POINT}/sources"
- CATEGORY_GROUPS_URL =
"#{REFERENCE_END_POINT}/category_groups"
- CATEGORIES_URL =
"#{REFERENCE_END_POINT}/categories"
- LOCATIONS_URL =
"#{REFERENCE_END_POINT}/locations"
- LOCATION_LOOKUP_URL =
"#{REFERENCE_END_POINT}/locations/lookup"
- VERSION =
"0.0.5"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
Instance Method Summary collapse
- #anchor(timestamp = Time.now.to_i) ⇒ Object
- #categories ⇒ Object
- #category_groups ⇒ Object
- #data_sources ⇒ Object
- #default_params ⇒ Object
- #locations(*args) ⇒ Object
- #log=(io) ⇒ Object
- #lookup_location(code) ⇒ Object
- #poll(*args) ⇒ Object
- #raw_data? ⇒ Boolean
- #request(url, params = {}) ⇒ Object
- #search(criteria = {}) ⇒ Object
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
23 24 25 |
# File 'lib/threetaps_client.rb', line 23 def api_key @api_key end |
#raw_data ⇒ Object
Returns the value of attribute raw_data.
23 24 25 |
# File 'lib/threetaps_client.rb', line 23 def raw_data @raw_data end |
Instance Method Details
#anchor(timestamp = Time.now.to_i) ⇒ Object
29 30 31 |
# File 'lib/threetaps_client.rb', line 29 def anchor(=Time.now.to_i) request ANCHOR_URL, :timestamp => end |
#categories ⇒ Object
48 49 50 |
# File 'lib/threetaps_client.rb', line 48 def categories request CATEGORIES_URL end |
#category_groups ⇒ Object
44 45 46 |
# File 'lib/threetaps_client.rb', line 44 def category_groups request CATEGORY_GROUPS_URL end |
#data_sources ⇒ Object
40 41 42 |
# File 'lib/threetaps_client.rb', line 40 def data_sources request DATA_SOURCES_URL end |
#default_params ⇒ Object
63 64 65 |
# File 'lib/threetaps_client.rb', line 63 def default_params { :auth_token => api_key } end |
#locations(*args) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/threetaps_client.rb', line 52 def locations(*args) = args. level = args.first || [:level] || args.first || 'country' .merge! :level => level request LOCATIONS_URL, end |
#log=(io) ⇒ Object
77 78 79 |
# File 'lib/threetaps_client.rb', line 77 def log=(io) RestClient.log = io end |
#lookup_location(code) ⇒ Object
59 60 61 |
# File 'lib/threetaps_client.rb', line 59 def lookup_location(code) request LOCATION_LOOKUP_URL, :code => code end |
#poll(*args) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/threetaps_client.rb', line 33 def poll(*args) criteria = args. anchor = args.first || criteria[:anchor] anchor = self.anchor['anchor'] if anchor.nil? request POLL_URL, criteria.merge(:anchor => anchor) end |
#raw_data? ⇒ Boolean
73 74 75 |
# File 'lib/threetaps_client.rb', line 73 def raw_data? !!raw_data end |
#request(url, params = {}) ⇒ Object
67 68 69 70 71 |
# File 'lib/threetaps_client.rb', line 67 def request(url, params={}) params = default_params.merge params.flatten response = RestClient.get url, :params => params, :accept => :json, :accept_charset => 'utf-8' JSON.parse(response) end |
#search(criteria = {}) ⇒ Object
25 26 27 |
# File 'lib/threetaps_client.rb', line 25 def search(criteria={}) request SEARCH_END_POINT, criteria end |