Class: GolfSwitch::CourseAvail

Inherits:
Request
  • Object
show all
Defined in:
lib/golf_switch/course_avail.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(attributes = {}) ⇒ CourseAvail

Returns a new instance of CourseAvail.



7
8
9
10
11
12
13
14
# File 'lib/golf_switch/course_avail.rb', line 7

def initialize(attributes = {})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    end
  end
  @play_end_date||= @play_beg_date
end

Instance Attribute Details

#alt_rate_typeObject

Returns the value of attribute alt_rate_type.



3
4
5
# File 'lib/golf_switch/course_avail.rb', line 3

def alt_rate_type
  @alt_rate_type
end

#api_responseObject

Returns the value of attribute api_response.



5
6
7
# File 'lib/golf_switch/course_avail.rb', line 5

def api_response
  @api_response
end

#barter_onlyObject

Returns the value of attribute barter_only.



5
6
7
# File 'lib/golf_switch/course_avail.rb', line 5

def barter_only
  @barter_only
end

#charging_onlyObject

Returns the value of attribute charging_only.



5
6
7
# File 'lib/golf_switch/course_avail.rb', line 5

def charging_only
  @charging_only
end

#course_idObject

Returns the value of attribute course_id.



3
4
5
# File 'lib/golf_switch/course_avail.rb', line 3

def course_id
  @course_id
end

#member_noObject

Returns the value of attribute member_no.



4
5
6
# File 'lib/golf_switch/course_avail.rb', line 4

def member_no
  @member_no
end

#member_no2Object

Returns the value of attribute member_no2.



4
5
6
# File 'lib/golf_switch/course_avail.rb', line 4

def member_no2
  @member_no2
end

#member_no3Object

Returns the value of attribute member_no3.



4
5
6
# File 'lib/golf_switch/course_avail.rb', line 4

def member_no3
  @member_no3
end

#member_no4Object

Returns the value of attribute member_no4.



4
5
6
# File 'lib/golf_switch/course_avail.rb', line 4

def member_no4
  @member_no4
end

#play_beg_dateObject

Returns the value of attribute play_beg_date.



3
4
5
# File 'lib/golf_switch/course_avail.rb', line 3

def play_beg_date
  @play_beg_date
end

#play_end_dateObject

Returns the value of attribute play_end_date.



3
4
5
# File 'lib/golf_switch/course_avail.rb', line 3

def play_end_date
  @play_end_date
end

#playersObject

Returns the value of attribute players.



3
4
5
# File 'lib/golf_switch/course_avail.rb', line 3

def players
  @players
end

#profile_idObject

Returns the value of attribute profile_id.



5
6
7
# File 'lib/golf_switch/course_avail.rb', line 5

def profile_id
  @profile_id
end

#promo_codeObject

Returns the value of attribute promo_code.



3
4
5
# File 'lib/golf_switch/course_avail.rb', line 3

def promo_code
  @promo_code
end

#regular_rate_onlyObject

Returns the value of attribute regular_rate_only.



5
6
7
# File 'lib/golf_switch/course_avail.rb', line 5

def regular_rate_only
  @regular_rate_only
end

#show_all_timesObject

Returns the value of attribute show_all_times.



5
6
7
# File 'lib/golf_switch/course_avail.rb', line 5

def show_all_times
  @show_all_times
end

#specials_onlyObject

Returns the value of attribute specials_only.



5
6
7
# File 'lib/golf_switch/course_avail.rb', line 5

def specials_only
  @specials_only
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/golf_switch/course_avail.rb', line 3

def time
  @time
end

Instance Method Details

#commitObject



40
41
42
# File 'lib/golf_switch/course_avail.rb', line 40

def commit
  super("course_avail")
end

#get_optionsObject



44
45
46
47
48
49
50
51
# File 'lib/golf_switch/course_avail.rb', line 44

def get_options
  {
    "Req"=>{
      "CourseAvailRequest"=>option_attributes
    }

  }
end

#option_attributesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/golf_switch/course_avail.rb', line 16

def option_attributes
  options = {}
  options.merge!("CourseId"=>@course_id) unless @course_id.blank?
  options.merge!("PlayBegDate"=>(DateTime.parse(@play_beg_date).strftime("%Y-%m-%dT00:00:00"))) unless @play_beg_date.blank?
  options.merge!("PlayEndDate"=>(DateTime.parse(@play_end_date).strftime("%Y-%m-%dT00:00:00"))) unless @play_end_date.blank?

  options.merge!("MemberNo"=>@member_no) unless @member_no.blank?
  options.merge!("MemberNo2"=>@member_no2) unless @member_no2.blank?
  options.merge!("MemberNo3"=>@member_no3) unless @member_no3.blank?
  options.merge!("MemberNo4"=>@member_no4) unless @member_no4.blank?

  options.merge!("Time"=>@time) unless @time.blank?
  options.merge!("Players"=>@players) unless @players.blank?
  options.merge!("AltRateType"=>@alt_rate_type) unless @alt_rate_type.blank?
  options.merge!("PromoCode"=>@promo_code) unless @promo_code.blank?
  options.merge!("ShowAllTimes"=>@show_all_times) unless @show_all_times.blank?
  options.merge!("BarterOnly"=>@barter_only) unless @barter_only.blank?
  options.merge!("ChargingOnly"=>@charging_only) unless @charging_only.blank?
  options.merge!("SpecialsOnly"=>@specials_only) unless @specials_only.blank?
  options.merge!("RegularRateOnly"=>@regular_rate_only) unless @regular_rate_only.blank?
  options.merge!("ProfileId"=>@profile_id) unless @profile_id.blank?
  options
end

#parse_errorObject



53
54
55
56
57
58
59
# File 'lib/golf_switch/course_avail.rb', line 53

def parse_error
  begin
    @response[:course_avail_response][:course_avail_result]
  rescue
    "Error on Parsing error messsage"
  end
end

#parse_responseObject



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/golf_switch/course_avail.rb', line 61

def parse_response
  begin
    unless error?
      @api_response = AvailableCourse.parse_courses(@response[:course_avail_response][:course_avail_result])
    else
      puts "Error #{error_message}"
    end
  rescue

  end
end