Class: GolfSwitch::CancelGolf

Inherits:
Request
  • Object
show all
Defined in:
lib/golf_switch/cancel_golf.rb

Instance Attribute Summary collapse

Attributes inherited from Request

#client, #config, #request, #response, #soap_error

Instance Method Summary collapse

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_idObject

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_noObject

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_idObject

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_dateObject

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

#commitObject



28
29
30
# File 'lib/golf_switch/cancel_golf.rb', line 28

def commit
  super("cancel_golf")
end

#get_optionsObject



12
13
14
15
16
17
# File 'lib/golf_switch/cancel_golf.rb', line 12

def get_options
  {
    "Req"=>
      option_attributes
  }
end

#option_attributesObject



19
20
21
22
23
24
25
26
# File 'lib/golf_switch/cancel_golf.rb', line 19

def option_attributes
  options = {}
  options.merge!("CourseId"=>@course_id)
  options.merge!("TeeDate"=>DateTime.parse(@tee_date).strftime("%Y-%m-%dT00:00:00"))
  options.merge!("ConfirmationNo"=>@confirmation_no) unless @confirmation_no.blank?
  options.merge!("BookingId"=>@booking_id) unless @booking_id.blank?
  options
end

#parse_errorObject



32
33
34
# File 'lib/golf_switch/cancel_golf.rb', line 32

def parse_error
  @response[:cancel_golf_response][:cancel_golf_result]
end

#parse_responseObject



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 #{error_message}"
    end
  rescue
    puts "Parse Error On Cancel Golf Response"
  end
end