Class: GolfSwitch::CourseAvailRequest
- Defined in:
- lib/golf_switch/course_avail_request.rb
Instance Attribute Summary collapse
-
#api_response ⇒ Object
Returns the value of attribute api_response.
-
#course_avails ⇒ Object
Returns the value of attribute course_avails.
Attributes inherited from Request
#client, #config, #request, #response, #soap_error
Instance Method Summary collapse
- #commit ⇒ Object
- #course_avail_attributes ⇒ Object
- #get_options ⇒ Object
-
#initialize ⇒ CourseAvailRequest
constructor
A new instance of CourseAvailRequest.
- #parse_error ⇒ Object
- #parse_response ⇒ Object
Methods inherited from Request
#error?, #error_message, #get_authentication_header
Constructor Details
#initialize ⇒ CourseAvailRequest
Returns a new instance of CourseAvailRequest.
10 11 12 |
# File 'lib/golf_switch/course_avail_request.rb', line 10 def initialize @course_avails = [] end |
Instance Attribute Details
#api_response ⇒ Object
Returns the value of attribute api_response.
8 9 10 |
# File 'lib/golf_switch/course_avail_request.rb', line 8 def api_response @api_response end |
#course_avails ⇒ Object
Returns the value of attribute course_avails.
8 9 10 |
# File 'lib/golf_switch/course_avail_request.rb', line 8 def course_avails @course_avails end |
Instance Method Details
#commit ⇒ Object
14 15 16 |
# File 'lib/golf_switch/course_avail_request.rb', line 14 def commit super("course_avail") end |
#course_avail_attributes ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/golf_switch/course_avail_request.rb', line 18 def course_avail_attributes option_attributes = [] Array(@course_avails).flatten.compact.each do |avail| if avail.is_a?(GolfSwitch::CourseAvail) option_attributes << avail.option_attributes else # Raise an error it should be an object of course Avail end end option_attributes end |
#get_options ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/golf_switch/course_avail_request.rb', line 30 def { "Req"=>{ "CourseAvailRequest"=>course_avail_attributes } } end |
#parse_error ⇒ Object
39 40 41 |
# File 'lib/golf_switch/course_avail_request.rb', line 39 def parse_error @response[:course_avail_response][:course_avail_result] end |
#parse_response ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/golf_switch/course_avail_request.rb', line 43 def parse_response begin unless error? @api_response = AvailableCourse.parse_courses(@response[:course_avail_response][:course_avail_result]) else puts "Error #{}" end rescue end end |