Class: GolfSwitch::CancelGolf
- Defined in:
- lib/golf_switch/cancel_golf.rb
Instance Attribute Summary collapse
-
#booking_id ⇒ Object
Returns the value of attribute booking_id.
-
#confirmation_no ⇒ Object
Returns the value of attribute confirmation_no.
-
#course_id ⇒ Object
Returns the value of attribute course_id.
-
#tee_date ⇒ Object
Returns the value of attribute tee_date.
Attributes inherited from Request
#client, #config, #request, #response, #soap_error
Instance Method Summary collapse
- #commit ⇒ Object
- #get_options ⇒ Object
-
#initialize(course_id, tee_date, confirmation_no = nil, booking_id = nil) ⇒ CancelGolf
constructor
A new instance of CancelGolf.
- #option_attributes ⇒ Object
- #parse_error ⇒ Object
- #parse_response ⇒ Object
Methods inherited from Request
#error?, #error_message, #get_authentication_header
Constructor Details
#initialize(course_id, tee_date, confirmation_no = nil, booking_id = nil) ⇒ CancelGolf
Returns a new instance of CancelGolf.
5 6 7 8 9 10 |
# File 'lib/golf_switch/cancel_golf.rb', line 5 def initialize(course_id,tee_date,confirmation_no=nil,booking_id=nil) @course_id = course_id @tee_date = tee_date @confirmation_no = confirmation_no @booking_id = booking_id end |
Instance Attribute Details
#booking_id ⇒ Object
Returns the value of attribute booking_id.
3 4 5 |
# File 'lib/golf_switch/cancel_golf.rb', line 3 def booking_id @booking_id end |
#confirmation_no ⇒ Object
Returns the value of attribute confirmation_no.
3 4 5 |
# File 'lib/golf_switch/cancel_golf.rb', line 3 def confirmation_no @confirmation_no end |
#course_id ⇒ Object
Returns the value of attribute course_id.
3 4 5 |
# File 'lib/golf_switch/cancel_golf.rb', line 3 def course_id @course_id end |
#tee_date ⇒ Object
Returns the value of attribute tee_date.
3 4 5 |
# File 'lib/golf_switch/cancel_golf.rb', line 3 def tee_date @tee_date end |
Instance Method Details
#commit ⇒ Object
28 29 30 |
# File 'lib/golf_switch/cancel_golf.rb', line 28 def commit super("cancel_golf") end |
#get_options ⇒ Object
12 13 14 15 16 17 |
# File 'lib/golf_switch/cancel_golf.rb', line 12 def { "Req"=> option_attributes } end |
#option_attributes ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/golf_switch/cancel_golf.rb', line 19 def option_attributes = {} .merge!("CourseId"=>@course_id) .merge!("TeeDate"=>DateTime.parse(@tee_date).strftime("%Y-%m-%dT00:00:00")) .merge!("ConfirmationNo"=>@confirmation_no) unless @confirmation_no.blank? .merge!("BookingId"=>@booking_id) unless @booking_id.blank? end |
#parse_error ⇒ Object
32 33 34 |
# File 'lib/golf_switch/cancel_golf.rb', line 32 def parse_error @response[:cancel_golf_response][:cancel_golf_result] end |
#parse_response ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/golf_switch/cancel_golf.rb', line 36 def parse_response begin unless error? @api_response = GolfSwitch::CancelGolfResponse.new(@response[:cancel_golf_response][:cancel_golf_result]) else puts "Error #{}" end rescue puts "Parse Error On Cancel Golf Response" end end |