Module: Geoloqi

Defined in:
lib/geoloqi.rb,
lib/geoloqi/batch.rb,
lib/geoloqi/error.rb,
lib/geoloqi/config.rb,
lib/geoloqi/session.rb,
lib/geoloqi/version.rb,
lib/geoloqi/response.rb

Defined Under Namespace

Classes: ApiError, ArgumentError, Batch, Config, Error, Response, Session

Constant Summary collapse

SSL_CERT_FILE =

Location of the Bundle of CA Root Certificates.

File.join(File.dirname(__FILE__), 'geoloqi', 'data', 'ca-certificates.crt')
@@config =

Location of the global Config object

Config.new

Class Method Summary collapse

Class Method Details

.api_urlString

API URL for the Geoloqi Platform.

Returns:

  • (String)


32
33
34
# File 'lib/geoloqi.rb', line 32

def api_url
  'https://api.geoloqi.com'
end

.api_versionFixnum

Which API version to use.

Returns:

  • (Fixnum)


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

def api_version
  1
end

.authorize_url(client_id = nil, redirect_uri = @@config.redirect_uri, opts = {}) ⇒ String

Returns the OAuth2 authorize url.

Examples:

Geoloqi.authorize_url 'YOUR_CLIENT_ID'

Returns:

  • (String)


92
93
94
95
96
97
# File 'lib/geoloqi.rb', line 92

def authorize_url(client_id=nil, redirect_uri=@@config.redirect_uri, opts={})
  raise "client_id required to authorize url. Pass with Geoloqi.config" unless client_id
  url = "#{oauth_url}?response_type=code&client_id=#{Rack::Utils.escape client_id}&redirect_uri=#{Rack::Utils.escape redirect_uri}"
  url += "&#{Rack::Utils.build_query opts}" unless opts.empty?
  url
end

.config(opts = nil) ⇒ Geoloqi::Config

Global config object accessor, which is used for Geoloqi.get/post. Geoloqi::Session inherits this config by default.

Examples:

# Setup the OAuth2 id/secret and use Hashie::Mash for output.
Geoloqi.config :client_id => 'CLIENT ID', :client_secret => 'CLIENT SECRET', :use_hashie_mash => true

Returns:



49
50
51
52
# File 'lib/geoloqi.rb', line 49

def config(opts=nil)
  return @@config if opts.nil?
  @@config = Config.new opts
end

.get(access_token, path, args = {}, headers = {}) ⇒ Hash

Makes a one-time GET request to the Geoloqi API. You can retreive your access token from the Geoloqi Developers Site.

Examples:

# Get your user profile
Geoloqi.get 'YOUR_ACCESS_TOKEN', 'account/profile'

# Get the last 5 locations
Geoloqi.get 'YOUR_ACCESS_TOKEN', 'account/profile', :count => 5

Returns:

  • (Hash)


63
64
65
# File 'lib/geoloqi.rb', line 63

def get(access_token, path, args={}, headers={})
  run :get, access_token, path, args, headers
end

.oauth_urlString

OAuth2 authorize URL for the Geoloqi Platform.

Returns:

  • (String)


39
40
41
# File 'lib/geoloqi.rb', line 39

def oauth_url
  'https://geoloqi.com/oauth/authorize'
end

.post(access_token, path, args = {}, headers = {}) ⇒ Hash

Makes a one-time POST request to the Geoloqi API. You can retreive your access token from the Geoloqi Developers Site.

Examples:

# Create a new layer
Geoloqi.post 'YOUR ACCESS TOKEN', 'layer/create', :name => 'Portland Food Carts'

Returns:

  • (Hash)

    by default, [Hashie::Mash] if enabled in config.



73
74
75
# File 'lib/geoloqi.rb', line 73

def post(access_token, path, args={}, headers={})
  run :post, access_token, path, args, headers
end

.run(meth, access_token, path, args = {}, headers = {}) ⇒ Hash

Makes a one-time request to the Geoloqi API. You can retreive your access token from the Geoloqi Developers Site.

Examples:

# Retrieve your profile
Geoloqi.run :get, 'YOUR ACCESS TOKEN', 'account/profile'

Returns:

  • (Hash)

    by default, [Hashie::Mash] if enabled in config.



83
84
85
# File 'lib/geoloqi.rb', line 83

def run(meth, access_token, path, args={}, headers={})
  Session.new(:access_token => access_token).run meth, path, args, headers
end

.versionString

Returns the current version of the Geoloqi ruby gem.

Returns:

  • (String)


5
6
7
# File 'lib/geoloqi/version.rb', line 5

def self.version
  '0.9.44'
end