Class: Geotrigger::Application

Inherits:
Model
  • Object
show all
Defined in:
lib/geotrigger/application.rb

Overview

Application objects offer top-level, ORM-ish access to various other model objects, as well as updating of application specific settings.

a = Geotrigger::Application.new client_id: 'abcde', client_secret: '12345'
#=> <Geotrigger::Application ...>

# or

s = Geotrigger::Session.new client_id: 'abcde', client_secret: '12345'
a = Geotrigger::Application.new session: s
#=> <Geotrigger::Application ...>

Instance Attribute Summary

Attributes inherited from Model

#data, #session

Instance Method Summary collapse

Methods inherited from Model

#==, from_api, #initialize, #method_missing, #post_list

Constructor Details

This class inherits a constructor from Geotrigger::Model

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Geotrigger::Model

Instance Method Details

#devices(params = {}) ⇒ Object

Return an Array of Device model objects that belong to this application.

params

Hash optional parameters to send with the request

a.devices tags: 'foo'
#=> [<Geotrigger::Device ...>, ...] # (devices that have the tag 'foo' on them)

a.devices geo: { geojson: { type: "Feature", properties: nil, geometry: {
  type:"Polygon",coordinates:[[[-122.669085113593,45.4999973537201], ... ,[-122.669085113593,45.4999973537201]]]
}}}
#=> [<Geotrigger::Device ...>, ...] # (devices whose last location was inside the given polygon)


51
52
53
# File 'lib/geotrigger/application.rb', line 51

def devices params = {}
  post_list 'devices', params
end

#permissionsObject

Return this application’s default tag permissions as a Hash.

a.permissions
#=> {"deviceTagging"=>true, "deviceLocation"=>false, ... }


22
23
24
# File 'lib/geotrigger/application.rb', line 22

def permissions
  post 'application/permissions'
end

#permissions=(perms) ⇒ Object

Update this application’s default tag permissions with a Hash.

a.permissions = { deviceTagging: false }
#=> {:deviceTagging => false }

a.permissions
#=> {"deviceTagging"=>false, "deviceLocation"=>false, ... }


34
35
36
# File 'lib/geotrigger/application.rb', line 34

def permissions= perms
  post 'application/permissions/update', perms
end

#tags(params = {}) ⇒ Object

Return an Array of Tag model objects that belong to this application.

params

Hash optional parameters to send with the request

a.tags
#=> [<Geotrigger::Tag...>, ...]


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

def tags params = {}
  post_list 'tags', params
end

#triggers(params = {}) ⇒ Object

Return an Array of Trigger model objects that belong to this application.

params

Hash optional parameters to send with the request

a.triggers tags: 'foo'
#=> [<Geotrigger::Trigger ...>, ...] # (triggers that have the tag 'foo' on them)

a.triggers geo: { geojson: { type: "Feature", properties: nil, geometry: {
  type:"Polygon",coordinates:[[[-122.669085113593,45.4999973537201], ... ,[-122.669085113593,45.4999973537201]]]
}}}
#=> [<Geotrigger::Trigger ...>, ...] # (triggers whose condition polygon is inside the given polygon)


80
81
82
# File 'lib/geotrigger/application.rb', line 80

def triggers params = {}
  post_list 'triggers', params
end