Class: CS::Request
- Inherits:
-
Object
- Object
- CS::Request
- Defined in:
- lib/csapi/request.rb
Instance Attribute Summary collapse
-
#arrival ⇒ Object
Returns the value of attribute arrival.
-
#arrival_flexible ⇒ Object
Returns the value of attribute arrival_flexible.
-
#departure ⇒ Object
Returns the value of attribute departure.
-
#departure_flexible ⇒ Object
Returns the value of attribute departure_flexible.
-
#from ⇒ Object
Returns the value of attribute from.
-
#is_open_couchrequest ⇒ Object
Returns the value of attribute is_open_couchrequest.
-
#message ⇒ Object
Returns the value of attribute message.
-
#number ⇒ Object
Returns the value of attribute number.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #send! ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
24 25 26 27 28 29 |
# File 'lib/csapi/request.rb', line 24 def initialize ={} = @defaults.merge() .each do |k,v| self.send "@#{k}=", val end end |
Instance Attribute Details
#arrival ⇒ Object
Returns the value of attribute arrival.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def arrival @arrival end |
#arrival_flexible ⇒ Object
Returns the value of attribute arrival_flexible.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def arrival_flexible @arrival_flexible end |
#departure ⇒ Object
Returns the value of attribute departure.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def departure @departure end |
#departure_flexible ⇒ Object
Returns the value of attribute departure_flexible.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def departure_flexible @departure_flexible end |
#from ⇒ Object
Returns the value of attribute from.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def from @from end |
#is_open_couchrequest ⇒ Object
Returns the value of attribute is_open_couchrequest.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def is_open_couchrequest @is_open_couchrequest end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def @message end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def number @number end |
#subject ⇒ Object
Returns the value of attribute subject.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def subject @subject end |
#to ⇒ Object
Returns the value of attribute to.
6 7 8 |
# File 'lib/csapi/request.rb', line 6 def to @to end |
Instance Method Details
#send! ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/csapi/request.rb', line 51 def send! raise CS::APIError('You have not authenticated with the service or did not provide a :username and :password') unless CS.instance data = self.to_h data[:arrival] = data[:arrival].strftime("%FT%TZ") data[:departure] = data[:departure].strftime("%FT%TZ") me = CS.instance.userdata['uid'] data[:from] ||= me data[:to] ||= me CS::HTTP.post('/couchrequests', body: data) end |
#to_h ⇒ Object
44 45 46 47 48 |
# File 'lib/csapi/request.rb', line 44 def to_h params = {} @options.each {|key| params[key.to_sym] = instance_variable_get("@#{key}") } params end |