Class: Antaeus::Resources::Appointment
- Inherits:
-
Antaeus::Resource
- Object
- Antaeus::Resource
- Antaeus::Resources::Appointment
- Defined in:
- lib/antaeus-sdk/resources/appointment.rb
Instance Attribute Summary
Attributes inherited from Antaeus::Resource
Class Method Summary collapse
-
.report(options = {}) ⇒ Object
Generate a report of appointments based on some criteria.
-
.upcoming(options = {}) ⇒ Object
A collection of all upcoming appointments.
Instance Method Summary collapse
-
#approve ⇒ Object
Approve an Appointment.
-
#checkin ⇒ Object
Checkin a Guest.
-
#checkout ⇒ Object
Checkout a Guest.
-
#guest ⇒ Object
Hidden property used to lookup related resource.
-
#guest=(guest_or_guest_id) ⇒ Object
Set the guest associated with this appointment.
-
#location ⇒ Object
Hidden property used to lookup related resource.
-
#location=(location_or_location_id) ⇒ Object
Set the location associated with this appointment.
-
#unapprove ⇒ Object
Unapprove an Appointment.
-
#undo_checkin ⇒ Object
Checkin a Guest.
-
#undo_checkout ⇒ Object
Checkout a Guest.
-
#user ⇒ Object
User related to an appointment.
-
#user=(username) ⇒ Object
Set the user related to an appointment.
Methods inherited from Antaeus::Resource
#<=>, all, delayed_property, #destroy, #fresh?, gen_property_methods, get, human, i18n_key, #id, immutable, #immutable?, immutable?, #initialize, #model_name, #new?, param_key, path, path_for, #path_for, paths, #paths, #persisted?, properties, property, #reload, route_key, #save, search, singular_route_key, #tainted?, #to_key, #to_model, #to_param, #update, where
Constructor Details
This class inherits a constructor from Antaeus::Resource
Class Method Details
.report(options = {}) ⇒ Object
Generate a report of appointments based on some criteria
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 38 def self.report( = {}) () ResourceCollection.new( [:client].post("/reports/generate", q: [:criteria])['appointments'].collect do |record| self.new( entity: record, lazy: false, tainted: false, client: [:client] ) end, type: self, client: [:client] ) end |
.upcoming(options = {}) ⇒ Object
A collection of all upcoming appointments
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 21 def self.upcoming( = {}) () ResourceCollection.new( [:client].get("#{path_for(:all)}/upcoming")['appointments'].collect do |record| self.new( entity: record, lazy: true, tainted: false, client: [:client] ) end, type: self, client: [:client] ) end |
Instance Method Details
#approve ⇒ Object
Approve an Appointment
55 56 57 58 59 60 61 62 63 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 55 def approve if @client.patch("#{path_for(:all)}/#{id}/approve", approve: true) true else fail Exceptions::ApprovalChangeFailed end reload return true end |
#checkin ⇒ Object
Checkin a Guest
66 67 68 69 70 71 72 73 74 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 66 def checkin if @client.patch("#{path_for(:all)}/#{id}/checkin", email: guest.email) true else raise Exceptions::CheckinChangeFailed end reload return true end |
#checkout ⇒ Object
Checkout a Guest
77 78 79 80 81 82 83 84 85 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 77 def checkout if @client.patch("#{path_for(:all)}/#{id}/checkout", email: guest.email) true else raise Exceptions::CheckoutChangeFailed end reload return true end |
#guest ⇒ Object
Hidden property used to lookup related resource
88 89 90 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 88 def guest Guest.get(@entity['guest_id'], client: @client) end |
#guest=(guest_or_guest_id) ⇒ Object
Set the guest associated with this appointment
93 94 95 96 97 98 99 100 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 93 def guest=(guest_or_guest_id) @entity['guest_id'] = if guest_or_guest_id.is_a?(Guest) guest_or_guest_id.id else guest_or_guest_id end @tainted = true end |
#location ⇒ Object
Hidden property used to lookup related resource
103 104 105 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 103 def location Location.get(@entity['location_id'], client: @client) end |
#location=(location_or_location_id) ⇒ Object
Set the location associated with this appointment
108 109 110 111 112 113 114 115 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 108 def location=(location_or_location_id) @entity['location_id'] = if location_or_location_id.is_a?(Location) location_or_location_id.id else location_or_location_id end @tainted = true end |
#unapprove ⇒ Object
Unapprove an Appointment
118 119 120 121 122 123 124 125 126 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 118 def unapprove if @client.patch("#{path_for(:all)}/#{id}/approve", approve: false) true else fail Exceptions::ApprovalChangeFailed end reload return true end |
#undo_checkin ⇒ Object
Checkin a Guest
129 130 131 132 133 134 135 136 137 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 129 def undo_checkin if @client.delete("#{path_for(:all)}/#{id}/checkin") true else raise Exceptions::CheckinChangeFailed end reload return true end |
#undo_checkout ⇒ Object
Checkout a Guest
140 141 142 143 144 145 146 147 148 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 140 def undo_checkout if @client.delete("#{path_for(:all)}/#{id}/checkout") true else raise Exceptions::CheckoutChangeFailed end reload return true end |
#user ⇒ Object
User related to an appointment
151 152 153 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 151 def user User.get(contact, client: @client) end |
#user=(username) ⇒ Object
Set the user related to an appointment
156 157 158 159 160 161 162 163 |
# File 'lib/antaeus-sdk/resources/appointment.rb', line 156 def user=(username) contact = if username.is_a?(User) username.id else username end @tainted = true end |