Class: Amiando::Event
Overview
Instance Attribute Summary
Attributes inherited from Resource
#attributes, #request, #response, #success
Class Method Summary (collapse)
-
+ (Result) activate(id)
Activate an event.
-
+ (Event) create(attributes)
Creates an event.
-
+ (Boolean) delete(id)
Deletes an event.
-
+ (Boolean) exists?(identifier)
See if an event id exists.
-
+ (Object) find(id)
Fetch an event.
-
+ (Result) find_all_by_user_id(user_id)
With a list of the event ids by this user.
-
+ (Result) search(by)
Search by identifier or title.
-
+ (Boolean) update(id, attributes)
Updates an event.
Methods inherited from Resource
#==, #[], #extract_attributes_from, #id, #initialize, map, map_params, mapping, #method_missing, method_missing, #populate_create, reverse_map_params, typecasting
Methods included from Autorun
Constructor Details
This class inherits a constructor from Amiando::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Amiando::Resource
Class Method Details
+ (Result) activate(id)
Activate an event
82 83 84 85 86 87 |
# File 'lib/amiando/event.rb', line 82 def self.activate(id) object = Result.new post object, "/api/event/#{id}/activate" object end |
+ (Event) create(attributes)
Creates an event.
25 26 27 28 29 30 31 32 |
# File 'lib/amiando/event.rb', line 25 def self.create(attributes) object = new post object, '/api/event/create', :params => map_params(attributes), :populate_method => :populate_create object end |
+ (Boolean) delete(id)
Deletes an event
69 70 71 72 73 74 |
# File 'lib/amiando/event.rb', line 69 def self.delete(id) object = Boolean.new('deleted') do_request object, :delete, "/api/event/#{id}" object end |
+ (Boolean) exists?(identifier)
See if an event id exists
56 57 58 59 60 61 |
# File 'lib/amiando/event.rb', line 56 def self.exists?(identifier) object = Boolean.new('exists') get object, "api/event/exists", :params => { :identifier => identifier } object end |
+ (Object) find(id)
Fetch an event
47 48 49 50 51 52 |
# File 'lib/amiando/event.rb', line 47 def self.find(id) object = new get object, "/api/event/#{id}" object end |
+ (Result) find_all_by_user_id(user_id)
With a list of the event ids by this user
110 111 112 113 114 115 116 |
# File 'lib/amiando/event.rb', line 110 def self.find_all_by_user_id(user_id) object = Result.new do |response_body| response_body['events'] end get object, "/api/user/#{user_id}/events" object end |
+ (Result) search(by)
Search by identifier or title.
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/amiando/event.rb', line 95 def self.search(by) unless by[:identifier].nil? ^ by[:title].nil? # XOR raise ArgumentError.new('Events can be searched either by identifier or by title, include only one.') end object = Result.new { |response_body| response_body['ids'] } get object, '/api/event/find', :params => by object end |
+ (Boolean) update(id, attributes)
Updates an event.
38 39 40 41 42 43 |
# File 'lib/amiando/event.rb', line 38 def self.update(id, attributes) object = Result.new post object, "/api/event/#{id}", :params => map_params(attributes) object end |