Class: GolfSwitch::CourseList
- Defined in:
- lib/golf_switch/course_list.rb
Instance Attribute Summary collapse
-
#api_response ⇒ Object
Returns the value of attribute api_response.
-
#area ⇒ Object
Returns the value of attribute area.
-
#country_id ⇒ Object
Returns the value of attribute country_id.
-
#featured_only ⇒ Object
Returns the value of attribute featured_only.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#max_distance ⇒ Object
Returns the value of attribute max_distance.
-
#max_distance_type ⇒ Object
Returns the value of attribute max_distance_type.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#region_id ⇒ Object
Returns the value of attribute region_id.
-
#show_all_status ⇒ Object
Returns the value of attribute show_all_status.
-
#show_dis_connected ⇒ Object
Returns the value of attribute show_dis_connected.
-
#sort ⇒ Object
Returns the value of attribute sort.
Attributes inherited from Request
#client, #config, #request, #response, #soap_error
Instance Method Summary collapse
- #commit ⇒ Object
- #get_options ⇒ Object
-
#initialize(attributes = {}) ⇒ CourseList
constructor
A new instance of CourseList.
- #option_attributes ⇒ Object
- #parse_error ⇒ Object
- #parse_response ⇒ Object
Methods inherited from Request
#error?, #error_message, #get_authentication_header
Constructor Details
#initialize(attributes = {}) ⇒ CourseList
Returns a new instance of CourseList.
6 7 8 9 10 11 12 13 14 |
# File 'lib/golf_switch/course_list.rb', line 6 def initialize(attributes = {}) attributes.each do |name, value| begin send("#{name}=", value) end end @max_distance_type = "M" unless ["M","K"].include?(@max_distance_type) @country_id ||="USA" end |
Instance Attribute Details
#api_response ⇒ Object
Returns the value of attribute api_response.
5 6 7 |
# File 'lib/golf_switch/course_list.rb', line 5 def api_response @api_response end |
#area ⇒ Object
Returns the value of attribute area.
3 4 5 |
# File 'lib/golf_switch/course_list.rb', line 3 def area @area end |
#country_id ⇒ Object
Returns the value of attribute country_id.
3 4 5 |
# File 'lib/golf_switch/course_list.rb', line 3 def country_id @country_id end |
#featured_only ⇒ Object
Returns the value of attribute featured_only.
4 5 6 |
# File 'lib/golf_switch/course_list.rb', line 4 def featured_only @featured_only end |
#latitude ⇒ Object
Returns the value of attribute latitude.
3 4 5 |
# File 'lib/golf_switch/course_list.rb', line 3 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
3 4 5 |
# File 'lib/golf_switch/course_list.rb', line 3 def longitude @longitude end |
#max_distance ⇒ Object
Returns the value of attribute max_distance.
4 5 6 |
# File 'lib/golf_switch/course_list.rb', line 4 def max_distance @max_distance end |
#max_distance_type ⇒ Object
Returns the value of attribute max_distance_type.
4 5 6 |
# File 'lib/golf_switch/course_list.rb', line 4 def max_distance_type @max_distance_type end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
3 4 5 |
# File 'lib/golf_switch/course_list.rb', line 3 def postal_code @postal_code end |
#region_id ⇒ Object
Returns the value of attribute region_id.
3 4 5 |
# File 'lib/golf_switch/course_list.rb', line 3 def region_id @region_id end |
#show_all_status ⇒ Object
Returns the value of attribute show_all_status.
4 5 6 |
# File 'lib/golf_switch/course_list.rb', line 4 def show_all_status @show_all_status end |
#show_dis_connected ⇒ Object
Returns the value of attribute show_dis_connected.
4 5 6 |
# File 'lib/golf_switch/course_list.rb', line 4 def show_dis_connected @show_dis_connected end |
#sort ⇒ Object
Returns the value of attribute sort.
4 5 6 |
# File 'lib/golf_switch/course_list.rb', line 4 def sort @sort end |
Instance Method Details
#commit ⇒ Object
40 41 42 |
# File 'lib/golf_switch/course_list.rb', line 40 def commit super("course_list") end |
#get_options ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/golf_switch/course_list.rb', line 32 def { "Req"=> option_attributes } end |
#option_attributes ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/golf_switch/course_list.rb', line 16 def option_attributes = {} .merge!("CountryId"=>@country_id) unless @country_id.blank? .merge!("RegionId"=>@region_id) unless @region_id.blank? .merge!("Area"=>@area) unless @area.blank? .merge!("Latitude"=>@latitude) unless @latitude.blank? .merge!("Longitude"=>@longitude) unless @longitude.blank? .merge!("PostalCode"=>@postal_code) unless @postal_code.blank? .merge!("MaxDistance"=>@max_distance) unless @max_distance.blank? .merge!("MaxDistanceType"=>@max_distance_type) if !@max_distance.blank? && !@max_distance_type.blank? .merge!("ShowDisConnected"=>@show_dis_connected) unless @show_dis_connected.blank? .merge!("FeaturedOnly"=>@featured_only) unless @featured_only.blank? .merge!("Sort"=>@sort) if !@sort.blank? && ["N",""].include?(@sort) end |
#parse_error ⇒ Object
44 45 46 |
# File 'lib/golf_switch/course_list.rb', line 44 def parse_error @response[:course_list_response][:course_list_result] end |
#parse_response ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/golf_switch/course_list.rb', line 48 def parse_response begin unless error? @api_response = CourseListCourse.parse_courses(@response[:course_list_response][:course_list_result]) else puts "Error #{}" end rescue end end |