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.2"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
- #anchor(timestamp = Time.now.to_i) ⇒ Object
- #categories ⇒ Object
- #category_groups ⇒ Object
- #data_sources ⇒ Object
- #default_params ⇒ Object
- #locations(level = 'country') ⇒ Object
- #log=(io) ⇒ Object
- #lookup_location(code) ⇒ Object
- #poll(*args) ⇒ Object
- #request(url, params = {}) ⇒ Object
- #retvals ⇒ 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 |
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
69 70 71 |
# File 'lib/threetaps_client.rb', line 69 def default_params { :auth_token => api_key, :retvals => retvals } end |
#locations(level = 'country') ⇒ Object
52 53 54 |
# File 'lib/threetaps_client.rb', line 52 def locations(level='country') request LOCATIONS_URL, :level => level end |
#log=(io) ⇒ Object
79 80 81 |
# File 'lib/threetaps_client.rb', line 79 def log=(io) RestClient.log = io end |
#lookup_location(code) ⇒ Object
56 57 58 |
# File 'lib/threetaps_client.rb', line 56 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 |
#request(url, params = {}) ⇒ Object
73 74 75 76 77 |
# File 'lib/threetaps_client.rb', line 73 def request(url, params={}) params = default_params.merge params.flatten response = RestClient.get url, :params => params, :accept => :json response.decode_json end |
#retvals ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/threetaps_client.rb', line 60 def retvals %w[ id account_id source category category_group location external_id external_url heading body timestamp expires language price currency images annotations status immortal deleted ].join(',') end |
#search(criteria = {}) ⇒ Object
25 26 27 |
# File 'lib/threetaps_client.rb', line 25 def search(criteria={}) request SEARCH_END_POINT, criteria end |