Class: Amiando::Event
Overview
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.activate(id) ⇒ Result
Activate an event.
-
.create(attributes) ⇒ Event
Creates an event.
-
.delete(id) ⇒ Boolean
Deletes an event.
-
.exists?(identifier) ⇒ Boolean
See if an event id exists.
-
.find(id) ⇒ Event
Fetch an event.
-
.find_all_by_user_id(user_id) ⇒ Result
Find all events from a user.
-
.search(by) ⇒ Result
Search by identifier or title.
-
.update(id, attributes) ⇒ Result
Updates an event.
Methods inherited from Resource
#==, #extract_attributes_from, #initialize, method_missing, #populate_create
Methods included from Attributes
#[], #id, included, #method_missing, #respond_to?, #type
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::Attributes
Class Method Details
.activate(id) ⇒ Result
Activate an event
86 87 88 89 90 91 |
# File 'lib/amiando/event.rb', line 86 def self.activate(id) object = Result.new post object, "/api/event/#{id}/activate" object end |
.create(attributes) ⇒ Event
Creates an event.
18 19 20 21 22 23 24 25 |
# File 'lib/amiando/event.rb', line 18 def self.create(attributes) object = new post object, '/api/event/create', :params => attributes, :populate_method => :populate_create object end |
.delete(id) ⇒ Boolean
Deletes an event
73 74 75 76 77 78 |
# File 'lib/amiando/event.rb', line 73 def self.delete(id) object = Boolean.new('deleted') do_request object, :delete, "/api/event/#{id}" object end |
.exists?(identifier) ⇒ Boolean
See if an event id exists
60 61 62 63 64 65 |
# File 'lib/amiando/event.rb', line 60 def self.exists?(identifier) object = Boolean.new('exists') get object, "api/event/exists", :params => { :identifier => identifier } object end |
.find(id) ⇒ Event
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 |
.find_all_by_user_id(user_id) ⇒ Result
Find all events from a user
117 118 119 120 121 122 123 |
# File 'lib/amiando/event.rb', line 117 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 |
.search(by) ⇒ Result
Search by identifier or title.
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/amiando/event.rb', line 100 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 |