Skip to content
Browse files

Update readme to show trigger examples and cleanups, try 1.8.7 with t…

…ravis
  • Loading branch information...
1 parent ffa7d70 commit 425a0a1d013b4cea11c4acf81afb3f5cf69eb577 @kyledrake kyledrake committed Oct 9, 2012
Showing with 50 additions and 82 deletions.
  1. +1 −0 .travis.yml
  2. +49 −82 README.md
View
1 .travis.yml
@@ -1,4 +1,5 @@
rvm:
+ - 1.8.7
- 1.9.2
- 1.9.3
- jruby-18mode
View
131 README.md
@@ -8,102 +8,73 @@ This library was developed with two goals in mind: to be as simple as possible,
gem install geoloqi
##Basic Usage
-Geoloqi uses OAuth2 for authentication, but if you're only working with your own account, you don't need to go through the authorization steps. Simply go to your account settings on the [Geoloqi Developers Site](https://developers.geoloqi.com), click on "Get Started" and copy the permanent access token. You can use this token to run the following examples.
-
-If you just need to make simple requests, you can just make a simple get or post request from Geoloqi:
-
- require 'geoloqi'
- result = Geoloqi.get 'YOUR ACCESS TOKEN', 'layer/info/Gx'
- p result
-
- # or a POST!
- result = Geoloqi.post 'YOUR ACCESS TOKEN', 'layer/create', :name => 'Test Layer'
-
-If you're using Geoloqi with OAuth or making multiple requests, we recommend using the Geoloqi::Session class:
-
- require 'geoloqi'
- geoloqi = Geoloqi::Session.new :access_token => 'YOUR ACCESS TOKEN'
- response = geoloqi.get 'layer/info/Gx'
- puts response.inspect
+Retrieve the client ID, client secret and application access token from your [Geoloqi Applications page](https://developers.geoloqi.com/applications) on the [Geoloqi Developers Site](https://developers.geoloqi.com).
+
+Then you can use Geoloqi::Session to do things like create triggers:
+
+ require "geoloqi"
+
+ geoloqi_session = Geoloqi::Session.new({
+ :access_token => "YOUR APPLICATION ACCESS TOKEN",
+ :config => {
+ :client_id => "YOUR CLIENT ID",
+ :client_secret => "YOUR CLIENT SECRET",
+ }
+ })
+
+ result = geoloqi_session.post("trigger/create", {
+ :key => "powells_books",
+ :type => "message",
+ :latitude => 45.523334,
+ :longitude => -122.681612,
+ :radius => 150,
+ :text => "Welcome to Powell's Books!",
+ :place_name => "Powell's Books"
+ })
Which returns a hash with the following:
- {:layer_id => "Gx",
- :user_id => "4",
- :type => "normal",
- :name => "USGS Earthquakes",
- :description => "Real-time notifications of earthquakes near you.",
- :icon => "http://beta.geoloqi.com/images/earthquake-layer.png",
- :public => "1",
- :url => "https://a.geoloqi.com/layer/description/Gx",
- :subscription => false,
- :settings => false}
-
-Both GET and POST are supported. To send a POST to create a place (in this case, the entire city of Portland, Oregon):
-
- response = geoloqi.post 'place/create', {
- :layer_id => "1Wn",
- :name => "3772756364",
- :latitude => "45.5037078163837",
- :longitude => "-122.622699737549",
- :radius => "3467.44",
- :extra => {
- :description => "Portland",
- :url => "http://en.wikipedia.org/wiki/Portland"
- }
- }
-
-You can send query string parameters with get requests too:
-
- geoloqi.get 'location/history', :count => 2
- # or
- geoloqi.get 'location/history?count=2'
+ {
+ :trigger_id => "2sSW",
+ :place_id => "2Urq",
+ :key => "powells_books",
+ :type => "message",
+ :trigger_on => "enter",
+ :trigger_after => 0,
+ :one_time => 0,
+ :text => "Welcome to Powell's Books!",
+ :extra => {},
+ :place => {
+ :place_id => "2Urq",
+ :name => "Powell's Books",
+ :latitude => 45.523334,
+ :longitude => -122.681612,
+ :radius => 150,
+ :display_name => "Powell's Books",
+ :active => 1,
+ :extra => {},
+ :description => ""
+ }
+ }
##Hashie::Mash support
Want to access in a more OOP/JSON style way? Use Hashie::Mash as the response object:
require 'hashie'
require 'geoloqi'
- geoloqi = Geoloqi::Session.new :access_token => 'YOUR OAUTH2 ACCESS TOKEN GOES HERE', :config => {:use_hashie_mash => true}
+ geoloqi = Geoloqi::Session.new :access_token => 'YOUR ACCESS TOKEN GOES HERE', :config => {:use_hashie_mash => true}
response = geoloqi.get 'layer/info/Gx'
response.layer_id # this works
response['layer_id'] # this works too
response[:layer_id] # so does this
-##Implementing OAuth2
-
-We have integrated OAuth2 support into the gem for your convenience, and provided a Geoloqi plugin for Sinatra. This is all it takes to get a "Hello World" for OAuth2 with Geoloqi:
-
-Implementing OAuth2 is not difficult, because we've done all the hard work for you. Here is a code example:
-
- require 'sinatra'
- require 'sinatra/geoloqi'
-
- set :geoloqi_client_id, 'YOUR_APP_ID_GOES_HERE'
- set :geoloqi_client_secret, 'YOUR_APP_SECRET_GOES_HERE'
- set :geoloqi_redirect_uri, 'http://127.0.0.1:4567'
- set :session_secret, 'ENTER_RANDOM_TEXT_HERE'
-
- before do
- require_geoloqi_login
- end
-
- get '/?' do
- username = geoloqi.get('account/username')[:username]
- "You have successfully logged in as #{username}!"
- end
-
-Visit the [Geoloqi Sinatra plugin](http://github.com/geoloqi/sinatra-geoloqi) page to see instructions on usage.
-
-A lower-level demonstration of the OAuth2 code can be found in the examples folder. This may be useful for anyone working to embed with other frameworks (such as Ruby on Rails).
-
##Making requests on behalf of the application
-Some actions (such as creating a user account for your application) require escalated privileges. To use these, call app\_get and app\_post:
+Some actions (such as "user/create") require escalated privileges. To use these, call app\_get and app\_post:
geoloqi.app_post 'user/create_anon'
## API Documentation
-The API has been extensively documented at [our developers site](https://developers.geoloqi.com/api).
+The API has been extensively documented on [our developers site](https://developers.geoloqi.com/api).
## RDoc/YARD Documentation
The code has been fully documented, and the latest version is always available at the [Rubydoc Site](http://rubydoc.info/gems/geoloqi).
@@ -113,15 +84,11 @@ The code has been fully documented, and the latest version is always available a
$ bundle install
$ bundle exec rake
-In addition to a full test suite, there is Travis integration for 1.9, JRuby and Rubinius. 1.8 is supported, however Travis tests have been disabled because 1.8's random hashing sometimes breaks Webmock. I highly recommend looking into upgrading to Ruby 1.9.. it's awesomer.
+In addition to a full test suite, there is Travis integration for 1.8, 1.9, JRuby and Rubinius.
##Found a bug?
Let us know! Send a pull request or a patch. Questions? Ask! We're here to help. File issues, we'll respond to them!
##Authors
* Kyle Drake
* Aaron Parecki
-
-##TODO / Possible projects
-* Rails plugin (works fine as-is, but maybe we can make it easier?)
-* More Concrete API in addition to the simple one?

0 comments on commit 425a0a1

Please sign in to comment.
Something went wrong with that request. Please try again.